Глобальное обновление #1

Merged
kozhilya merged 33 commits from dev into master 2025-06-01 22:28:15 +04:00
5 changed files with 68 additions and 49 deletions
Showing only changes of commit b49be9883e - Show all commits
+2
View File
@@ -30,6 +30,8 @@ internal static class Program
ImportApplication app = ActivatorUtilities.CreateInstance<ImportApplication>(
serviceProvider
);
Application.Run(app);
}
private static IServiceCollection RegisterServices()
@@ -40,27 +40,56 @@
<DockPanel Style="{StaticResource {x:Type DockPanel}}">
<DockPanel.Height>
<DynamicResource ResourceKey="ItemHeight" />
<Binding Path="ItemHeight" RelativeSource="{RelativeSource AncestorType=local:EntityViewControl}" />
</DockPanel.Height>
<StackPanel Width="200" Orientation="Horizontal">
<Image>
<Image Margin="0,0,2,0">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<MultiBinding Converter="{StaticResource LadderToImageConverter}" ConverterParameter="{Binding ItemHeight, RelativeSource={RelativeSource AncestorType=local:EntityViewControl}}">
<Binding Path="Depth" />
<Binding Path="ItemHeight" RelativeSource="{RelativeSource AncestorType=local:EntityViewControl}"></Binding>
<DynamicResource ResourceKey="ItemHeight" />
<MultiBinding Converter="{StaticResource LadderToImageConverter}">
<Binding Path="Ladder" />
<Binding Path="ItemHeight" RelativeSource="{RelativeSource AncestorType=local:EntityViewControl}" />
</MultiBinding>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Text="{Binding Name}" />
<Button
Width="15"
Height="15"
Margin="-24,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderThickness="1"
Visibility="{Binding ButtonVisibility}">
<Button.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="3" />
<Setter Property="LineHeight" Value="15" />
</Style>
</Button.Resources>
<!--<Button.Width>
<Binding Path="ButtonSize" RelativeSource="{RelativeSource AncestorType=local:EntityViewControl}" />
</Button.Width>
<Button.Height>
<Binding Path="ButtonSize" RelativeSource="{RelativeSource AncestorType=local:EntityViewControl}" />
</Button.Height>-->
+
</Button>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding Name}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock HorizontalAlignment="Center" Text="{Binding Type}" />
<TextBlock HorizontalAlignment="Center" Text="{Binding Value}" />
<TextBlock
Margin="0,0,5,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="{Binding TypeFontSize, RelativeSource={RelativeSource AncestorType=local:EntityViewControl}}"
FontStyle="Italic"
Text="{Binding Type}" />
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding Value}" />
</StackPanel>
</DockPanel>
@@ -24,7 +24,7 @@ namespace Pf2eDataScrapper.WPF.Components;
internal partial class EntityViewControl : System.Windows.Controls.UserControl
{
public EntityViewViewModel ViewModel
public EntityViewViewModel? ViewModel
{
get => _viewModel;
set
@@ -33,7 +33,7 @@ internal partial class EntityViewControl : System.Windows.Controls.UserControl
DataContext = ViewModel;
}
}
private EntityViewViewModel _viewModel;
private EntityViewViewModel? _viewModel;
#region "Поля элемента управления"
@@ -1,13 +1,10 @@
using System.CodeDom;
using System.Globalization;
using System.Security.Cryptography;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header;
using Brush = System.Windows.Media.Brush;
using Brushes = System.Windows.Media.Brushes;
using Color = System.Windows.Media.Color;
using Image = System.Windows.Controls.Image;
namespace Pf2eDataScrapper.WPF.ViewModels.EntityViewStructure;
@@ -33,6 +30,11 @@ internal class StructureRow(StructureField item)
/// </summary>
public bool Visible => Item.Visible;
/// <summary>
/// Флаг, указывающий, отображается ли строка.
/// </summary>
public Visibility ButtonVisibility => HasButton ? Visibility.Visible : Visibility.Collapsed;
/// <summary>
/// Глубина отображения поля.
/// </summary>
@@ -68,9 +70,6 @@ internal class StructureRow(StructureField item)
// [ValueConversion(typeof(IEnumerable<LadderType>), typeof(Image), ParameterType = typeof(int))]
public class LadderToImageConverter : IMultiValueConverter
{
#region IValueConverter Members
public object? Convert(
object[] value,
Type targetType,
@@ -78,7 +77,10 @@ public class LadderToImageConverter : IMultiValueConverter
System.Globalization.CultureInfo culture
)
{
if (value.Length != 2)
if (
value.Length != 2
|| !value[0].GetType().IsAssignableTo(typeof(IEnumerable<LadderType>))
)
{
return null;
}
@@ -91,19 +93,14 @@ public class LadderToImageConverter : IMultiValueConverter
}
int n = ladder.Count();
if (!int.TryParse((string)value[1], out int itemHeight))
{
return null;
}
int itemHeight = (int)value[1];
DrawingGroup result = new();
// Rectangle
result.Children.Add(
new GeometryDrawing()
{
Geometry = new RectangleGeometry(new(0, 0, n * 100, 100)),
Geometry = new RectangleGeometry(new(0, 0, n * itemHeight, itemHeight)),
Pen = new(Brushes.Transparent, 0),
}
);
@@ -116,16 +113,13 @@ public class LadderToImageConverter : IMultiValueConverter
}
);
return result;
return new DrawingImage(result);
}
private GeometryGroup GetLadderGeometryGroup(IEnumerable<LadderType> ladder, int h)
{
float h2 = h * 0.5f;
GeometryGroup geometryGroup = new();
//geometryGroup.Children.Add(new RectangleGeometry(new(0, 0, ladder.Count() * 100, 100)));
float h2 = h * 0.5f;
int i = 0;
foreach (LadderType ladderType in ladder)
@@ -139,20 +133,23 @@ public class LadderToImageConverter : IMultiValueConverter
new LineGeometry(new(i * h + h2, 0), new(i * h + h2, h2))
);
geometryGroup.Children.Add(
new LineGeometry(new(i * h + h2, 50), new(i * h + h, h2))
new LineGeometry(new(i * h + h2, h2), new(i * h + h, h2))
);
break;
case LadderType.Through:
geometryGroup.Children.Add(
new LineGeometry(new(i * h + h2, 0), new(i * h + h2, h))
);
if (i == ladder.Count() - 1)
{
geometryGroup.Children.Add(
new LineGeometry(new(i * h + h2, h2), new(i * h + h2, h2))
new LineGeometry(new(i * h + h2, h2), new(i * h + h, h2))
);
}
break;
default:
throw new ArgumentOutOfRangeException(nameof(ladder));
}
@@ -172,6 +169,4 @@ public class LadderToImageConverter : IMultiValueConverter
{
throw new NotSupportedException();
}
#endregion
}
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using Pf2eDataScrapper.Forms.Controls.EntityTreeViewer;
using System.Collections.ObjectModel;
using Pf2eDataScrapper.Helpers;
using Pf2eDataScrapper.WPF.Stores;
using Pf2eDataScrapper.WPF.ViewModels.EntityViewStructure;