Compare commits

..
2 Commits
47 changed files with 1716 additions and 193 deletions
@@ -184,6 +184,14 @@ internal class ProcessorCollection
Items = AllItems.Where(item => nameFlags.ContainsKey(item.Name)).ToList(); Items = AllItems.Where(item => nameFlags.ContainsKey(item.Name)).ToList();
} }
/// <summary>
/// Получить список типов, которые обрабатываются в компендиуме.
/// </summary>
/// <param name="compendium">Тип компендиума.</param>
/// <returns>Набор типов.</returns>
public ICollection<string> GetTypesOfCompendium(ProcessorCompendiumEnum compendium) =>
Items.Select(item => item.InnerType).OfType<string>().ToList();
} }
/// <summary> /// <summary>
+1
View File
@@ -1,4 +1,5 @@
using System.ComponentModel; using System.ComponentModel;
using System.IO;
using dotenv.net; using dotenv.net;
using dotenv.net.Utilities; using dotenv.net.Utilities;
+2 -1
View File
@@ -1,4 +1,5 @@
using dotenv.net; using System.IO;
using dotenv.net;
using dotenv.net.Utilities; using dotenv.net.Utilities;
namespace Pf2eDataScrapper; namespace Pf2eDataScrapper;
@@ -167,6 +167,7 @@ public sealed partial class EntityTreeViewerControl : UserControl
public EntityTreeViewerControl() public EntityTreeViewerControl()
{ {
InitializeComponent(); InitializeComponent();
ContentImage = new(ContentWidth, Height); ContentImage = new(ContentWidth, Height);
DoubleBuffered = true; DoubleBuffered = true;
VerticalScroll.Visible = true; VerticalScroll.Visible = true;
@@ -213,6 +214,11 @@ public sealed partial class EntityTreeViewerControl : UserControl
/// </summary> /// </summary>
public void UpdateRenders() public void UpdateRenders()
{ {
if (EntityView?.Entity is null)
{
return;
}
int maxNameWidth = -1; int maxNameWidth = -1;
foreach (EntityTreeViewerControlRow row in _viewerRows) foreach (EntityTreeViewerControlRow row in _viewerRows)
@@ -239,6 +245,11 @@ public sealed partial class EntityTreeViewerControl : UserControl
/// </summary> /// </summary>
public void UpdateView() public void UpdateView()
{ {
if (EntityView?.Entity is null)
{
return;
}
_viewerRows.ForEach(row => row.UpdateButton()); _viewerRows.ForEach(row => row.UpdateButton());
List<EntityTreeViewerControlRow> rows = _viewerRows.Where(r => r.Item.Visible).ToList(); List<EntityTreeViewerControlRow> rows = _viewerRows.Where(r => r.Item.Visible).ToList();
@@ -0,0 +1,36 @@
namespace Pf2eDataScrapper.Forms.Controls.EntityTreeViewer;
partial class EntityViewerControl
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Pf2eDataScrapper.Forms.Controls.EntityTreeViewer;
public partial class EntityViewerControl : UserControl
{
public EntityViewerControl()
{
InitializeComponent();
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+15 -15
View File
@@ -37,7 +37,7 @@ partial class EntityViewForm
ResultSplitContainer = new SplitContainer(); ResultSplitContainer = new SplitContainer();
DescriptionTextBox = new TextBox(); DescriptionTextBox = new TextBox();
DatabaseViewer = new DatabaseViewerControl(); DatabaseViewer = new DatabaseViewerControl();
EntityTreeViewerControl = new EntityTreeViewerControl(); _entityTreeViewerCntrl = new EntityTreeViewerControl();
MenuStrip = new MenuStrip(); MenuStrip = new MenuStrip();
FileToolStripMenuItem = new ToolStripMenuItem(); FileToolStripMenuItem = new ToolStripMenuItem();
ExitToolStripMenuItem = new ToolStripMenuItem(); ExitToolStripMenuItem = new ToolStripMenuItem();
@@ -137,20 +137,20 @@ partial class EntityViewForm
DatabaseViewer.Size = new Size(322, 731); DatabaseViewer.Size = new Size(322, 731);
DatabaseViewer.TabIndex = 1; DatabaseViewer.TabIndex = 1;
// //
// EntityTreeViewerControl // _entityTreeViewerCntrl
// //
EntityTreeViewerControl.AutoScroll = true; _entityTreeViewerCntrl.AutoScroll = true;
EntityTreeViewerControl.ButtonSize = 15; _entityTreeViewerCntrl.ButtonSize = 15;
EntityTreeViewerControl.DepthSize = 15; _entityTreeViewerCntrl.DepthSize = 15;
EntityTreeViewerControl.Dock = DockStyle.Fill; _entityTreeViewerCntrl.Dock = DockStyle.Fill;
EntityTreeViewerControl.Font = new Font("Consolas", 9F); _entityTreeViewerCntrl.Font = new Font("Consolas", 9F);
EntityTreeViewerControl.HoverColor = SystemColors.ControlDark; _entityTreeViewerCntrl.HoverColor = SystemColors.ControlDark;
EntityTreeViewerControl.ItemHeight = 20; _entityTreeViewerCntrl.ItemHeight = 20;
EntityTreeViewerControl.Location = new Point(0, 0); _entityTreeViewerCntrl.Location = new Point(0, 0);
EntityTreeViewerControl.Name = "EntityTreeViewerControl"; _entityTreeViewerCntrl.Name = "_entityTreeViewerCntrl";
EntityTreeViewerControl.Size = new Size(582, 861); _entityTreeViewerCntrl.Size = new Size(582, 861);
EntityTreeViewerControl.TabIndex = 0; _entityTreeViewerCntrl.TabIndex = 0;
EntityTreeViewerControl.TypeFontSize = 7F; _entityTreeViewerCntrl.TypeFontSize = 7F;
// //
// MenuStrip // MenuStrip
// //
@@ -229,7 +229,7 @@ partial class EntityViewForm
private ListBox TypesListBox; private ListBox TypesListBox;
private SplitContainer ResultSplitContainer; private SplitContainer ResultSplitContainer;
private TextBox DescriptionTextBox; private TextBox DescriptionTextBox;
private EntityTreeViewerControl EntityTreeViewerControl; private EntityTreeViewerControl _entityTreeViewerCntrl;
private DatabaseViewerControl DatabaseViewer; private DatabaseViewerControl DatabaseViewer;
private MenuStrip MenuStrip; private MenuStrip MenuStrip;
private ToolStripMenuItem FileToolStripMenuItem; private ToolStripMenuItem FileToolStripMenuItem;
+2 -2
View File
@@ -18,10 +18,10 @@ internal partial class EntityViewForm : Form
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public EntityView? CurrentView public EntityView? CurrentView
{ {
get => EntityTreeViewerControl.EntityView; get => _entityTreeViewerCntrl.EntityView;
set set
{ {
EntityTreeViewerControl.EntityView = value; _entityTreeViewerCntrl.EntityView = value;
Application.DoEvents(); Application.DoEvents();
} }
} }
+59 -54
View File
@@ -1,10 +1,14 @@
using Microsoft.Extensions.DependencyInjection; using System.ComponentModel;
using System.Windows;
using Microsoft.Extensions.DependencyInjection;
using Pf2eDataScrapper.App; using Pf2eDataScrapper.App;
using Pf2eDataScrapper.Forms;
using Pf2eDataScrapper.Helpers; using Pf2eDataScrapper.Helpers;
using Pf2eDataScrapper.Processors; using Pf2eDataScrapper.Processors;
using Pf2eDataScrapper.WPF;
using Pf2eDataScrapper.WPF.Views;
using Pf2eModel; using Pf2eModel;
using Slugify; using Slugify;
using StartForm = Pf2eDataScrapper.WPF.Views.StartForm;
namespace Pf2eDataScrapper; namespace Pf2eDataScrapper;
@@ -20,7 +24,8 @@ internal sealed class ImportApplication : ApplicationContext
Settings = settings; Settings = settings;
Processors = processors; Processors = processors;
CurrentStage = ApplicationStage.InitialSettings; //CurrentStage = ApplicationStage.InitialSettings;
CurrentStage = ApplicationStage.Viewer;
} }
#region "Поля" #region "Поля"
@@ -46,30 +51,20 @@ internal sealed class ImportApplication : ApplicationContext
#region "Формы" #region "Формы"
private StartForm? _startForm; private StartForm? _startFormWpf;
private ProgressForm? _progressForm; private ProgressFormWpf? _progressFormWpf;
private EntityViewForm? _entityViewForm; private EntityForm? _entityForm;
#endregion #endregion
#region "Жизненный цикл" #region "Жизненный цикл"
private Form? CurrentForm { get; set; } private Window? CurrentWpfForm { get; set; }
public delegate void ApplicationStateChangeDelegate(object sender, ApplicationStage nextStage); public delegate void ApplicationStateChangeDelegate(object sender, ApplicationStage nextStage);
public void ApplicationStateChange(object sender, ApplicationStage nextStage)
{
if (sender != CurrentForm)
{
return;
}
CurrentStage = nextStage;
}
private void StartStage(ApplicationStage stage) private void StartStage(ApplicationStage stage)
{ {
switch (stage) switch (stage)
@@ -80,13 +75,13 @@ internal sealed class ImportApplication : ApplicationContext
); );
case ApplicationStage.InitialSettings: case ApplicationStage.InitialSettings:
_startForm = ActivatorUtilities.CreateInstance<StartForm>(ServiceProvider); _startFormWpf = ActivatorUtilities.CreateInstance<StartForm>(ServiceProvider);
_startForm.StartPosition = FormStartPosition.CenterParent; _startFormWpf.WindowStartupLocation = WindowStartupLocation.CenterOwner;
_startForm.ApplicationStateChange += ApplicationStateChange; _startFormWpf.Closing += Wpf_HandleFormClosing;
_startForm.FormClosing += HandleFormClosing; _startFormWpf.ApplicationStateChange += ApplicationStateChange;
_startForm.Show(); _startFormWpf.Show();
CurrentForm = _startForm; CurrentWpfForm = _startFormWpf;
break; break;
case ApplicationStage.ImportProcess: case ApplicationStage.ImportProcess:
@@ -94,38 +89,37 @@ internal sealed class ImportApplication : ApplicationContext
ServiceProvider ServiceProvider
); );
_progressForm = ActivatorUtilities.CreateInstance<ProgressForm>(ServiceProvider); _progressFormWpf = ActivatorUtilities.CreateInstance<ProgressFormWpf>(
_progressForm.StartPosition = FormStartPosition.CenterParent; ServiceProvider
_progressForm.FormClosing += HandleFormClosing; );
_progressFormWpf.WindowStartupLocation = WindowStartupLocation.CenterOwner;
_progressFormWpf.Closing += Wpf_HandleFormClosing;
_progressFormWpf.ApplicationStateChange += ApplicationStateChange;
_progressForm.Show(); CurrentWpfForm = _progressFormWpf;
_progressFormWpf.Show();
CurrentForm = _progressForm;
executor.Start(); executor.Start();
break; break;
case ApplicationStage.Viewer: case ApplicationStage.Viewer:
_entityViewForm = ActivatorUtilities.CreateInstance<EntityViewForm>( _entityForm = ActivatorUtilities.CreateInstance<EntityForm>(ServiceProvider);
ServiceProvider _entityForm.WindowStartupLocation = WindowStartupLocation.CenterOwner;
); _entityForm.Closing += Wpf_HandleFormClosing;
_entityViewForm.StartPosition = FormStartPosition.CenterParent; //_entityForm.ApplicationStateChange += ApplicationStateChange;
_entityViewForm.ApplicationStateChange += ApplicationStateChange; _entityForm.Show();
_entityViewForm.FormClosing += HandleFormClosing;
_entityViewForm.Show(); CurrentWpfForm = _entityForm;
CurrentForm = _entityViewForm;
break; break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
Application.DoEvents();
} }
private void CloseStage(ApplicationStage stage) private void CloseStage(ApplicationStage stage)
{ {
CurrentForm = null; CurrentWpfForm = null;
switch (stage) switch (stage)
{ {
case ApplicationStage.BootUp: case ApplicationStage.BootUp:
@@ -133,38 +127,48 @@ internal sealed class ImportApplication : ApplicationContext
break; break;
case ApplicationStage.InitialSettings: case ApplicationStage.InitialSettings:
_startForm!.Hide(); _startFormWpf!.Hide();
_startForm!.Close(); _startFormWpf!.Close();
_startForm = null; _startFormWpf = null;
break; break;
case ApplicationStage.ImportProcess: case ApplicationStage.ImportProcess:
break; break;
case ApplicationStage.Viewer: case ApplicationStage.Viewer:
_entityViewForm!.Hide(); _entityForm!.Hide();
_entityViewForm!.Close(); _entityForm!.Close();
_entityViewForm = null; _entityForm = null;
break; break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
Application.DoEvents();
} }
private void HandleFormClosing(object? sender, FormClosingEventArgs e) #endregion
#region "События"
public void ApplicationStateChange(object sender, ApplicationStage nextStage)
{ {
if (sender != CurrentForm) if (sender?.Equals(CurrentWpfForm) ?? false)
{
CurrentStage = nextStage;
}
}
private void Wpf_HandleFormClosing(object? sender, CancelEventArgs e)
{
if (sender?.Equals(CurrentWpfForm) ?? false)
{
ExitThread();
}
else
{ {
e.Cancel = true; e.Cancel = true;
return;
} }
ExitThread();
} }
#endregion #endregion
#region "Внедрение зависимостей" #region "Внедрение зависимостей"
@@ -177,6 +181,7 @@ internal sealed class ImportApplication : ApplicationContext
{ {
// Контекст базы данных // Контекст базы данных
services.AddEntityFrameworkNpgsql(); services.AddEntityFrameworkNpgsql();
services.AddDbContext<Pf2eDbContext>(); services.AddDbContext<Pf2eDbContext>();
//services.AddDbContextPool<Pf2eDbContext>(options => //services.AddDbContextPool<Pf2eDbContext>(options =>
//{ //{
@@ -18,25 +18,19 @@ internal abstract class AbstractCompendium
/// </summary> /// </summary>
public string Dir => Repository.RepositoryDirPath; public string Dir => Repository.RepositoryDirPath;
/// <summary>
/// Возвращает количество элементов в компендиуме.
/// </summary>
/// <returns>Количество элементов.</returns>
public abstract int Count();
/// <summary> /// <summary>
/// Возвращает количество элементов для указанного типа данных. /// Возвращает количество элементов для указанного типа данных.
/// </summary> /// </summary>
/// <param name="type">Тип данных.</param> /// <param name="type">Типы данных.</param>
/// <returns>Количество элементов.</returns> /// <returns>Количество элементов.</returns>
public abstract int Count(string type); public abstract int Count(params ICollection<string> type);
/// <summary> /// <summary>
/// Получение итератора сущностей. Если указан тип <paramref name="type"/> - то только указанного типа. /// Получение итератора сущностей. Если указан тип <paramref name="type"/> - то только указанного типа.
/// </summary> /// </summary>
/// <param name="type">Тип сущностей, которые нужно получить.</param> /// <param name="type">Типы сущностей, которые нужно получить.</param>
/// <returns>Итератор сущностей.</returns> /// <returns>Итератор сущностей.</returns>
public abstract IEnumerable<Tuple<AbstractCompendiumItem, JObject>> Iterate( public abstract IEnumerable<Tuple<AbstractCompendiumItem, JObject>> Iterate(
string? type = null params ICollection<string> type
); );
} }
@@ -1,4 +1,6 @@
namespace Pf2eDataScrapper.Importers; using System.IO;
namespace Pf2eDataScrapper.Importers;
/// <summary> /// <summary>
/// Абстрактный класс импортёра. /// Абстрактный класс импортёра.
@@ -1,4 +1,6 @@
using Newtonsoft.Json.Linq; using System.IO;
using System.Net.Http;
using Newtonsoft.Json.Linq;
using Pf2eDataScrapper.Helpers; using Pf2eDataScrapper.Helpers;
using Pf2eDataScrapper.Importers.Repositories; using Pf2eDataScrapper.Importers.Repositories;
@@ -1,4 +1,5 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.IO;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.Compendium; namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.Compendium;
@@ -8,6 +9,7 @@ namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.Compendium;
/// </summary> /// </summary>
internal sealed class AonprdCompendium(AonprdRepository repository) : AbstractCompendium internal sealed class AonprdCompendium(AonprdRepository repository) : AbstractCompendium
{ {
/// <inheritdoc/>
public override AonprdRepository Repository { get; } = repository; public override AonprdRepository Repository { get; } = repository;
/// <summary> /// <summary>
@@ -15,29 +17,22 @@ internal sealed class AonprdCompendium(AonprdRepository repository) : AbstractCo
/// </summary> /// </summary>
public ConcurrentBag<AonprdCompendiumItem> Items { get; } = []; public ConcurrentBag<AonprdCompendiumItem> Items { get; } = [];
/// <summary> /// <inheritdoc/>
/// Возвращает количество элементов в компендиуме. public override int Count(params ICollection<string> types) =>
/// </summary> types.Count == 0 ? Items.Count : Items.Count(i => types.Contains(i.Type));
/// <returns>Количество элементов.</returns>
public override int Count() => Items.Count;
/// <summary> /// <inheritdoc/>
/// Возвращает количество элементов для указанного типа данных. public override IEnumerable<Tuple<AbstractCompendiumItem, JObject>> Iterate(
/// </summary> params ICollection<string> types
/// <param name="type">Тип данных.</param> )
/// <returns>Количество элементов.</returns>
public override int Count(string type) => Items.Count(i => i.Type == type);
/// <summary>
/// Получение итератора сущностей. Если указан тип <paramref name="type"/> - то только указанного типа.
/// </summary>
/// <param name="type">Тип сущностей, которые нужно получить.</param>
/// <returns>Итератор сущностей.</returns>
public override IEnumerable<Tuple<AbstractCompendiumItem, JObject>> Iterate(string? type = null)
{ {
IEnumerable<string> files = type is null IEnumerable<string> files =
? Items.Select(t => t.File).Distinct() types.Count == 0
: Items.Where(t => t.Type == type).Select(t => t.File).Distinct(); ? Items.Select(item => item.File).Distinct()
: Items
.Where(item => types.Contains(item.Type))
.Select(item => item.File)
.Distinct();
foreach (string file in files) foreach (string file in files)
{ {
@@ -57,16 +52,12 @@ internal sealed class AonprdCompendium(AonprdRepository repository) : AbstractCo
if ( if (
id is null id is null
|| !fileReferences.TryGetValue(id, out AonprdCompendiumItem? reference) || !fileReferences.TryGetValue(id, out AonprdCompendiumItem? reference)
|| !types.Contains(reference.Type)
) )
{ {
continue; continue;
} }
if (type is not null && reference.Type != type)
{
continue;
}
yield return new(reference, (JObject)item); yield return new(reference, (JObject)item);
} }
} }
@@ -1,4 +1,5 @@
using Pf2eModel.Model.Base.Source; using System.IO;
using Pf2eModel.Model.Base.Source;
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.Helpers; namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.Helpers;
@@ -46,7 +46,7 @@ internal class LegacyRemasterProcessors(ProcessorInput input) : AbstractInputPro
return Context return Context
.EntityExternals.AsNoTracking() .EntityExternals.AsNoTracking()
.Where(x => aonprdIds.Contains(x.ExternalId)) .Where(x => aonprdIds.Contains(x.ExternalId!))
.Select(x => x.EntityId) .Select(x => x.EntityId)
.ToList(); .ToList();
} }
@@ -1,4 +1,5 @@
using Newtonsoft.Json.Linq; using System.IO;
using Newtonsoft.Json.Linq;
using Pf2eDataScrapper.App; using Pf2eDataScrapper.App;
using Pf2eDataScrapper.Helpers; using Pf2eDataScrapper.Helpers;
using Pf2eDataScrapper.Importers.Implementations.Aonprd.Compendium; using Pf2eDataScrapper.Importers.Implementations.Aonprd.Compendium;
@@ -1,4 +1,5 @@
using Pf2eDataScrapper.App; using System.IO;
using Pf2eDataScrapper.App;
using Pf2eDataScrapper.Helpers; using Pf2eDataScrapper.Helpers;
using Pf2eDataScrapper.Importers.Implementations.Aonprd.Compendium; using Pf2eDataScrapper.Importers.Implementations.Aonprd.Compendium;
using Pf2eDataScrapper.SchemaBuilder; using Pf2eDataScrapper.SchemaBuilder;
@@ -0,0 +1,51 @@
using System.Collections.Concurrent;
using System.IO;
using Newtonsoft.Json.Linq;
namespace Pf2eDataScrapper.Importers.Implementations.FoundryEn.Compendium;
/// <summary>
/// Загрузчик данных компендиума.
/// </summary>
/// <param name="repository">Репозиторий данных.</param>
internal sealed class FoundryEnCompendium(
FoundryEnRepository repository,
CompendiumFolderCollection folders
) : AbstractCompendium
{
/// <inheritdoc/>
public override FoundryEnRepository Repository { get; } = repository;
/// <summary>
/// Набор папок компендиума
/// </summary>
public CompendiumFolderCollection Folders { get; } = folders;
/// <summary>
/// Коллекция всех записей компендиума.
/// </summary>
public ConcurrentBag<FoundryEnCompendiumItem> Items { get; } = [];
/// <inheritdoc/>
public override int Count(params ICollection<string> types) =>
types.Count == 0 ? Items.Count : Items.Count(i => types.Contains(i.Type));
/// <inheritdoc/>
public override IEnumerable<Tuple<AbstractCompendiumItem, JObject>> Iterate(
params ICollection<string> types
)
{
foreach (
FoundryEnCompendiumItem item in types.Count == 0
? Items
: Items.Where(i => types.Contains(i.Type))
)
{
using StreamReader fileReader = new(
Path.Combine(Repository.RepositoryDirPath, item.File)
);
yield return new(item, JObject.Parse(fileReader.ReadToEnd()));
}
}
}
@@ -1,64 +0,0 @@
using System.Collections.Concurrent;
using Newtonsoft.Json.Linq;
using Pf2eDataScrapper.Importers.Implementations.FoundryEn.Compendium;
namespace Pf2eDataScrapper.Importers.Implementations.FoundryEn;
/// <summary>
/// Загрузчик данных компендиума.
/// </summary>
/// <param name="repository">Репозиторий данных.</param>
internal sealed class FoundryEnCompendium(
FoundryEnRepository repository,
CompendiumFolderCollection folders
) : AbstractCompendium
{
/// <summary>
/// Репозиторий данных.
/// </summary>
public override FoundryEnRepository Repository { get; } = repository;
/// <summary>
/// Набор папок компендиума
/// </summary>
public CompendiumFolderCollection Folders { get; } = folders;
/// <summary>
/// Коллекция всех записей компендиума.
/// </summary>
public ConcurrentBag<FoundryEnCompendiumItem> Items { get; } = [];
/// <summary>
/// Возвращает количество элементов в компендиуме.
/// </summary>
/// <returns>Количество элементов.</returns>
public override int Count() => Items.Count;
/// <summary>
/// Возвращает количество элементов для указанного типа данных.
/// </summary>
/// <param name="type">Тип данных.</param>
/// <returns>Количество элементов.</returns>
public override int Count(string type) => Items.Count(i => i.Type == type);
/// <summary>
/// Получение итератора сущностей. Если указан тип <paramref name="type"/> - то только указанного типа.
/// </summary>
/// <param name="type">Тип сущностей, которые нужно получить.</param>
/// <returns>Итератор сущностей.</returns>
public override IEnumerable<Tuple<AbstractCompendiumItem, JObject>> Iterate(string? type = null)
{
IEnumerable<FoundryEnCompendiumItem> items = type is null
? Items
: Items.Where(i => i.Type == type);
foreach (FoundryEnCompendiumItem item in items)
{
using StreamReader fileReader = new(
Path.Combine(Repository.RepositoryDirPath, item.File)
);
yield return new(item, JObject.Parse(fileReader.ReadToEnd()));
}
}
}
@@ -1,4 +1,5 @@
using Newtonsoft.Json.Linq; using System.IO;
using Newtonsoft.Json.Linq;
using Pf2eDataScrapper.App; using Pf2eDataScrapper.App;
using Pf2eDataScrapper.Importers.Implementations.FoundryEn.Compendium; using Pf2eDataScrapper.Importers.Implementations.FoundryEn.Compendium;
using Pf2eDataScrapper.Processors; using Pf2eDataScrapper.Processors;
@@ -1,4 +1,5 @@
using Newtonsoft.Json.Linq; using System.IO;
using Newtonsoft.Json.Linq;
using Pf2eDataScrapper.App; using Pf2eDataScrapper.App;
using Pf2eDataScrapper.Helpers; using Pf2eDataScrapper.Helpers;
using Pf2eDataScrapper.Importers.Implementations.FoundryEn.Compendium; using Pf2eDataScrapper.Importers.Implementations.FoundryEn.Compendium;
@@ -1,5 +1,7 @@
using Pf2eDataScrapper.App; using System.IO;
using Pf2eDataScrapper.App;
using Pf2eDataScrapper.Helpers; using Pf2eDataScrapper.Helpers;
using Pf2eDataScrapper.Importers.Implementations.FoundryEn.Compendium;
using Pf2eDataScrapper.SchemaBuilder; using Pf2eDataScrapper.SchemaBuilder;
namespace Pf2eDataScrapper.Importers.Implementations.FoundryEn.Processors.Preparation; namespace Pf2eDataScrapper.Importers.Implementations.FoundryEn.Processors.Preparation;
@@ -1,4 +1,5 @@
using Pf2eDataScrapper.Helpers; using System.IO;
using Pf2eDataScrapper.Helpers;
namespace Pf2eDataScrapper.Importers.Repositories; namespace Pf2eDataScrapper.Importers.Repositories;
@@ -1,4 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using Pf2eDataScrapper.Helpers; using Pf2eDataScrapper.Helpers;
namespace Pf2eDataScrapper.Importers.Repositories; namespace Pf2eDataScrapper.Importers.Repositories;
+1
View File
@@ -5,6 +5,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<UseWPF>True</UseWPF>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Importers\Implementations\FoundryEn\DataBuilder\**" /> <Compile Remove="Importers\Implementations\FoundryEn\DataBuilder\**" />
@@ -5,7 +5,7 @@ using Pf2eDataScrapper.App;
using Pf2eDataScrapper.Helpers; using Pf2eDataScrapper.Helpers;
using Pf2eDataScrapper.Importers; using Pf2eDataScrapper.Importers;
using Pf2eDataScrapper.Importers.Implementations.Aonprd.Compendium; using Pf2eDataScrapper.Importers.Implementations.Aonprd.Compendium;
using Pf2eDataScrapper.Importers.Implementations.FoundryEn; using Pf2eDataScrapper.Importers.Implementations.FoundryEn.Compendium;
namespace Pf2eDataScrapper.Processors; namespace Pf2eDataScrapper.Processors;
@@ -116,15 +116,13 @@ internal sealed class ProcessorExecutor(
_ => throw new($"Не могу выбрать импортёр для группы {item.Group}"), _ => throw new($"Не могу выбрать импортёр для группы {item.Group}"),
}; };
Progress.Local.Reset( ICollection<string> types = item.InnerType is null
item.InnerType is null ? compendium.Count() : compendium.Count(item.InnerType) ? Collection.GetTypesOfCompendium(item.Compendium ?? throw new("impossible"))
); : [item.InnerType];
foreach ( Progress.Local.Reset(compendium.Count(types));
(AbstractCompendiumItem compendiumItem, JObject json) in compendium.Iterate(
item.InnerType foreach ((AbstractCompendiumItem compendiumItem, JObject json) in compendium.Iterate(types))
)
)
{ {
Progress.Local.Start(compendiumItem.Id); Progress.Local.Start(compendiumItem.Id);
+3
View File
@@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Pf2eDataScrapper.Importers.Implementations.Aonprd; using Pf2eDataScrapper.Importers.Implementations.Aonprd;
using Pf2eDataScrapper.Importers.Implementations.FoundryEn; using Pf2eDataScrapper.Importers.Implementations.FoundryEn;
using Pf2eDataScrapper.WPF;
namespace Pf2eDataScrapper; namespace Pf2eDataScrapper;
@@ -37,6 +38,8 @@ internal static class Program
{ {
IServiceCollection services = new ServiceCollection(); IServiceCollection services = new ServiceCollection();
services.RegisterWpfServices();
ImportApplication.RegisterServices(services); ImportApplication.RegisterServices(services);
AonprdImporter.RegisterServices(services); AonprdImporter.RegisterServices(services);
@@ -1,4 +1,5 @@
using Newtonsoft.Json.Linq; using System.IO;
using Newtonsoft.Json.Linq;
using Pf2eDataScrapper.Helpers; using Pf2eDataScrapper.Helpers;
using Pf2eDataScrapper.Importers; using Pf2eDataScrapper.Importers;
using Pf2eDataScrapper.Processors; using Pf2eDataScrapper.Processors;
@@ -0,0 +1,88 @@
<UserControl
x:Class="Pf2eDataScrapper.WPF.Components.DbEntityListControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Pf2eDataScrapper.WPF.Components"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:Pf2eDataScrapper.WPF.ViewModels"
d:DataContext="{d:DesignInstance Type=viewModels:DbEntityListViewModel}"
d:DesignHeight="450"
d:DesignWidth="400"
x:ClassModifier="internal"
mc:Ignorable="d">
<UserControl.Background>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}" />
</UserControl.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25" />
<RowDefinition Height="30" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<DockPanel Grid.Row="0" Grid.Column="0">
<Button
Width="25"
Margin="0,0,3,0"
Content="&lt;&lt;"
DockPanel.Dock="Left" />
<Button
Width="25"
Margin="0,0,3,0"
Content="&lt;"
DockPanel.Dock="Left" />
<Button
Width="25"
Margin="3,0,0,0"
Content="&gt;&gt;"
DockPanel.Dock="Right" />
<Button
Width="25"
Margin="3,0,0,0"
Content="&gt;"
DockPanel.Dock="Right" />
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<Label VerticalContentAlignment="Center" Content="Страница" />
<TextBox
Width="30"
VerticalContentAlignment="Center"
Text="{Binding Page, StringFormat=\{0:D\}}" />
<Label VerticalContentAlignment="Center" Content="из" />
<Label VerticalContentAlignment="Center" Content="{Binding PageCount, Mode=OneWay}" />
</StackPanel>
</DockPanel>
<TextBox
Grid.Row="1"
VerticalAlignment="Center"
Text="TextBox"
TextWrapping="Wrap" />
<ListView
Grid.Row="2"
d:ItemsSource="{d:SampleData ItemCount=50}"
ItemsSource="{Binding Entities}">
<ListView.View>
<GridView>
<GridViewColumn
Width="Auto"
DisplayMemberBinding="{Binding Id}"
Header="ID" />
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="Название" />
<GridViewColumn
Width="Auto"
DisplayMemberBinding="{Binding Rarity}"
Header="Редк." />
</GridView>
</ListView.View>
</ListView>
</Grid>
</UserControl>
@@ -0,0 +1,28 @@
using Pf2eDataScrapper.WPF.ViewModels;
namespace Pf2eDataScrapper.WPF.Components;
/// <summary>
/// Логика взаимодействия для DbEntityListControl.xaml
/// </summary>
internal partial class DbEntityListControl : System.Windows.Controls.UserControl
{
public DbEntityListViewModel? ViewModel
{
get => _viewModel;
set
{
_viewModel = value;
DataContext = ViewModel;
}
}
private DbEntityListViewModel? _viewModel;
public DbEntityListControl()
{
InitializeComponent();
}
//https://www.youtube.com/watch?v=54ZmhbpjBmg
}
@@ -0,0 +1,414 @@
<UserControl
x:Class="Pf2eDataScrapper.WPF.Components.ProcessorCollectionControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="400"
d:DesignWidth="300"
x:ClassModifier="internal"
BorderThickness="2,2,2,2"
mc:Ignorable="d">
<UserControl.Resources>
<Style x:Key="HeaderCheckbox" TargetType="{x:Type CheckBox}">
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
<Style x:Key="ElementBorder" TargetType="{x:Type Border}">
<Setter Property="Margin" Value="10,5,10,20" />
<Setter Property="BorderThickness" Value="1,1,1,1" />
<Setter Property="BorderBrush" Value="Black" />
</Style>
<Style x:Key="ElementPanelStyle" TargetType="{x:Type WrapPanel}">
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled" />
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlLightLightColorKey}}" />
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ElementCheckBox" TargetType="CheckBox">
<Setter Property="Margin" Value="4,2,4,2" />
</Style>
</UserControl.Resources>
<UserControl.Background>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}" />
</UserControl.Background>
<ScrollViewer>
<StackPanel
x:Name="RootPanel"
Margin="3,3,3,3"
ScrollViewer.CanContentScroll="True">
<CheckBox
x:Name="Test"
Content="Test Header 1"
IsChecked="False"
Style="{DynamicResource HeaderCheckbox}" />
<Border Style="{DynamicResource ElementBorder}">
<WrapPanel Style="{StaticResource ElementPanelStyle}">
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
</WrapPanel>
</Border>
<CheckBox
Content="Test Header 2"
IsChecked="False"
Style="{DynamicResource HeaderCheckbox}" />
<Border Style="{DynamicResource ElementBorder}">
<WrapPanel Style="{StaticResource ElementPanelStyle}">
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2 Test 2 Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
</WrapPanel>
</Border>
<CheckBox
Content="Test Header 2"
IsChecked="False"
Style="{DynamicResource HeaderCheckbox}" />
<Border Style="{DynamicResource ElementBorder}">
<WrapPanel Style="{StaticResource ElementPanelStyle}">
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2 Test 2 Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
</WrapPanel>
</Border>
<CheckBox
Content="Test Header 2"
IsChecked="False"
Style="{DynamicResource HeaderCheckbox}" />
<Border Style="{DynamicResource ElementBorder}">
<WrapPanel Style="{StaticResource ElementPanelStyle}">
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2 Test 2 Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
</WrapPanel>
</Border>
<CheckBox
Content="Test Header 2"
IsChecked="False"
Style="{DynamicResource HeaderCheckbox}" />
<Border Style="{DynamicResource ElementBorder}">
<WrapPanel Style="{StaticResource ElementPanelStyle}">
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2 Test 2 Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
</WrapPanel>
</Border>
<CheckBox
Content="Test Header 2"
IsChecked="False"
Style="{DynamicResource HeaderCheckbox}" />
<Border Style="{DynamicResource ElementBorder}">
<WrapPanel Style="{StaticResource ElementPanelStyle}">
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2 Test 2 Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
</WrapPanel>
</Border>
<CheckBox
Content="Test Header 2"
IsChecked="False"
Style="{DynamicResource HeaderCheckbox}" />
<Border Style="{DynamicResource ElementBorder}">
<WrapPanel Style="{StaticResource ElementPanelStyle}">
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2 Test 2 Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 1"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 2"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 3"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
<CheckBox
Content="Test 4"
IsChecked="False"
Style="{DynamicResource ElementCheckBox}" />
</WrapPanel>
</Border>
</StackPanel>
</ScrollViewer>
</UserControl>
@@ -0,0 +1,160 @@
using System.ComponentModel;
using System.Windows;
using Pf2eDataScrapper.App;
using CheckBox = System.Windows.Controls.CheckBox;
namespace Pf2eDataScrapper.WPF.Components;
/// <summary>
/// Логика взаимодействия для ProcessorCollectionControl.xaml
/// </summary>
internal partial class ProcessorCollectionControl : System.Windows.Controls.UserControl
{
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ProcessorCollection Collection
{
get => _collection;
set
{
_collection = value;
SetContent();
}
}
private ProcessorCollection _collection = null!;
public ProcessorCollectionControl()
{
InitializeComponent();
}
private Dictionary<ProcessorGroupEnum, CheckBox> GroupCheckBoxes { get; } = [];
private Dictionary<ProcessorGroupEnum, bool?> GroupLastStats { get; } = [];
private Dictionary<string, CheckBox> ItemCheckBoxes { get; } = [];
private void SetContent()
{
RootPanel.Children.Clear();
foreach (ProcessorGroupEnum group in Enum.GetValues<ProcessorGroupEnum>())
{
GroupCheckBoxes[group] = new()
{
Content = group.ToString(),
IsThreeState = true,
Style = (Style)Resources["HeaderCheckbox"]!,
};
GroupCheckBoxes[group].Click += GroupCheckBox_Click;
System.Windows.Controls.Border border = new()
{
Style = (Style)Resources["ElementBorder"]!,
};
System.Windows.Controls.WrapPanel wrapPanel = new()
{
Style = (Style)Resources["ElementPanelStyle"]!,
};
foreach (
ProcessorCollectionItem item in Collection.AllItems.Where(item =>
item.Group == group
)
)
{
ItemCheckBoxes[item.Name] = new()
{
Content = item.Description,
ToolTip = item.Name,
IsChecked = item.Active,
Style = (Style)Resources["ElementCheckBox"]!,
};
ItemCheckBoxes[item.Name].Click += ItemCheckBox_Click;
wrapPanel.Children.Add(ItemCheckBoxes[item.Name]);
}
border.Child = wrapPanel;
RootPanel.Children.Add(GroupCheckBoxes[group]);
RootPanel.Children.Add(border);
}
UpdateContent();
}
private void UpdateContent()
{
GroupLastStats.Clear();
List<string> checkedItems = [];
foreach ((string key, CheckBox? checkBox) in ItemCheckBoxes)
{
ProcessorCollectionItem item = Collection[key];
bool isChecked = checkBox.IsChecked ?? false;
if (GroupLastStats.TryGetValue(item.Group, out bool? state))
{
/*
* | true | false | null
* | Checked | Unchecked | Indeterminate
* -------+---------+-----------+---------------
* true | true | null | null
* false | null | false | null
*/
GroupLastStats[item.Group] =
isChecked && state == true ? true
: !isChecked && state == false ? false
: null;
}
else
{
GroupLastStats[item.Group] = isChecked;
}
if (isChecked)
{
checkedItems.Add(key);
}
}
foreach ((ProcessorGroupEnum groupEnum, CheckBox? checkBox) in GroupCheckBoxes)
{
checkBox.IsChecked = GroupLastStats.GetValueOrDefault(groupEnum, null);
}
Collection.FilterProcessors(checkedItems);
}
private void GroupCheckBox_Click(object sender, RoutedEventArgs e)
{
CheckBox groupCheckBox = (CheckBox)sender;
ProcessorGroupEnum groupEnum = GroupCheckBoxes
.First(pair => pair.Value == groupCheckBox)
.Key;
groupCheckBox.IsChecked =
GroupLastStats[groupEnum] is null || groupCheckBox.IsChecked is not null;
foreach (
(string _, CheckBox checkBox) in ItemCheckBoxes.Where(pair =>
Collection[pair.Key].Group == groupEnum
)
)
{
checkBox.IsChecked = groupCheckBox.IsChecked;
}
UpdateContent();
}
private void ItemCheckBox_Click(object sender, RoutedEventArgs e)
{
UpdateContent();
}
}
@@ -0,0 +1,20 @@
using Pf2eModel.Model.Base;
namespace Pf2eDataScrapper.WPF.Stores;
public class SelectedEntityStore
{
private Entity? _selectedEntityType;
public Entity? SelectedEntityType
{
get => _selectedEntityType;
set
{
_selectedEntityType = value;
SelectedEntityTypeChanged?.Invoke(SelectedEntityType);
}
}
public event Action<Entity?>? SelectedEntityTypeChanged;
}
@@ -0,0 +1,20 @@
using Pf2eModel.Model.Enum;
namespace Pf2eDataScrapper.WPF.Stores;
internal class SelectedEntityTypeStore
{
private EntityType? _selectedEntityType;
public EntityType? SelectedEntityType
{
get => _selectedEntityType;
set
{
_selectedEntityType = value;
SelectedEntityTypeChanged?.Invoke(SelectedEntityType);
}
}
public event Action<EntityType?>? SelectedEntityTypeChanged;
}
+23
View File
@@ -0,0 +1,23 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Pf2eDataScrapper.WPF;
internal abstract class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new(propertyName));
}
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value))
return false;
field = value;
OnPropertyChanged(propertyName);
return true;
}
}
@@ -0,0 +1,155 @@
using System.Collections.Concurrent;
using System.Collections.ObjectModel;
using Pf2eDataScrapper.WPF.Stores;
using Pf2eModel;
using Pf2eModel.Model.Base;
using Pf2eModel.Model.Enum;
namespace Pf2eDataScrapper.WPF.ViewModels;
internal class DbEntityListViewModel : ViewModelBase
{
public Pf2eDbContext Context { get; }
public SelectedEntityTypeStore SelectedEntityTypeStore { get; }
private EntityType? SelectedEntityType => SelectedEntityTypeStore.SelectedEntityType;
public int Page
{
get => _page;
set
{
_page = Math.Clamp(value, 1, PageCount);
OnPropertyChanged();
}
}
private int _page = 1;
public int EntitiesCount
{
get => _entitiesCount;
set
{
_entitiesCount = value;
OnPropertyChanged();
OnPropertyChanged(nameof(PageCount));
}
}
private int _entitiesCount = 1;
public int PerPage
{
get => _perPage;
set
{
_perPage = value;
OnPropertyChanged();
OnPropertyChanged(nameof(PageCount));
}
}
private int _perPage = 30;
public string Search
{
get => _search;
set
{
_search = value;
OnPropertyChanged();
}
}
private string _search = "";
public int PageCount => Convert.ToInt32(Math.Ceiling(1.0 * EntitiesCount / PerPage));
public IEnumerable<Entity> Entities
{
get => _entities;
set
{
_entities = [.. value];
OnPropertyChanged();
}
}
private ObservableCollection<Entity> _entities = [];
public DbEntityListViewModel(
Pf2eDbContext context,
SelectedEntityTypeStore selectedEntityTypeStore
)
{
Context = context;
SelectedEntityTypeStore = selectedEntityTypeStore;
SelectedEntityTypeStore.SelectedEntityTypeChanged +=
SelectedEntityTypeStore_SelectedEntityTypeChanged;
}
~DbEntityListViewModel()
{
SelectedEntityTypeStore.SelectedEntityTypeChanged -=
SelectedEntityTypeStore_SelectedEntityTypeChanged;
}
private void SelectedEntityTypeStore_SelectedEntityTypeChanged(EntityType? entityType)
{
if (entityType is null)
{
Page = 1;
EntitiesCount = 1;
Entities = [];
return;
}
Query();
}
/// <summary>
/// Поток, в котором будет выполняться запрос к базе данных.
/// </summary>
private Thread? _queryThread;
private void Query()
{
Abort();
_queryThread = new(PerformQuery);
_queryThread.Start();
}
/// <summary>
/// Прерывает выполнение потока, если он ещё не завершён.
/// </summary>
public void Abort()
{
_queryThread?.Interrupt();
_queryThread = null;
}
/// <summary>
/// Выполняет запрос к базе данных и обрабатывает результаты.
/// </summary>
private void PerformQuery()
{
try
{
Pf2eDbContext dbContext = new();
IQueryable<Entity> query =
Search == ""
? dbContext.Entities.Where(e => e.Type == SelectedEntityType)
:
// ReSharper disable once EntityFramework.UnsupportedServerSideFunctionCall
dbContext.Entities.Where(e =>
e.Type == SelectedEntityType && Pf2eDbContext.LocaleSearch(e.Name, Search)
);
Page = 1;
EntitiesCount = query.Count();
Entities = query.OrderBy(e => e.Id).Skip((Page - 1) * PerPage).Take(PerPage).ToList();
}
catch (ThreadInterruptedException)
{
// Ignore
}
}
}
@@ -0,0 +1,49 @@
using Pf2eDataScrapper.WPF.Stores;
using Pf2eModel;
using Pf2eModel.Model.Enum;
namespace Pf2eDataScrapper.WPF.ViewModels;
internal class EntityFormViewModel : ViewModelBase
{
public IServiceProvider ServiceProvider { get; }
public Pf2eDbContext Context { get; }
public SelectedEntityTypeStore SelectedEntityTypeStore { get; }
public IEnumerable<EntityType> EntityTypes { get; set; } = [];
public EntityType? SelectedEntityType
{
get => SelectedEntityTypeStore.SelectedEntityType;
set
{
SelectedEntityTypeStore.SelectedEntityType = value;
OnPropertyChanged();
}
}
public string TestText => SelectedEntityType?.ToString() ?? "null";
public EntityFormViewModel(
IServiceProvider serviceProvider,
Pf2eDbContext context,
SelectedEntityTypeStore selectedEntityTypeStore
)
{
ServiceProvider = serviceProvider;
Context = context;
SelectedEntityTypeStore = selectedEntityTypeStore;
Update();
}
public void Update()
{
LoadEntityTypes();
}
private void LoadEntityTypes()
{
EntityTypes = Context.Entities.Select(e => e.Type).Distinct().ToList();
OnPropertyChanged(nameof(EntityTypes));
}
}
@@ -0,0 +1,69 @@
<Window
x:Class="Pf2eDataScrapper.WPF.Views.EntityForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:components="clr-namespace:Pf2eDataScrapper.WPF.Components"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Pf2eDataScrapper.WPF"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:Pf2eDataScrapper.WPF.ViewModels"
Title="EntityForm"
Width="1000"
Height="600"
d:DataContext="{d:DesignInstance Type=viewModels:EntityFormViewModel}"
x:ClassModifier="internal"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition Height="150" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<GridSplitter
Grid.Row="0"
Grid.RowSpan="4"
Grid.Column="1"
Width="5"
HorizontalAlignment="Stretch" />
<GridSplitter
Grid.Row="0"
Grid.RowSpan="4"
Grid.Column="3"
Width="5"
HorizontalAlignment="Stretch" />
<GridSplitter
Grid.Row="2"
Grid.Column="0"
Height="5"
HorizontalAlignment="Stretch"
Cursor="SizeNS"
ResizeDirection="Rows" />
<ListBox
x:Name="EntityTypeListBox"
Grid.Row="1"
Grid.Column="0"
d:ItemsSource="{d:SampleData ItemCount=10}"
ItemsSource="{Binding EntityTypes}"
SelectedItem="{Binding SelectedEntityType}" />
<components:DbEntityListControl x:Name="DbEntityListControl" Grid.Row="2" Grid.Column="0" />
<TextBox
Grid.Row="0"
Grid.RowSpan="4"
Grid.Column="4"
IsReadOnly="True"
Text="{Binding TestText, Mode=OneWay}"
TextWrapping="Wrap" />
</Grid>
</Window>
@@ -0,0 +1,29 @@
using System.Collections.ObjectModel;
using System.Windows;
using Pf2eDataScrapper.WPF.ViewModels;
using Pf2eModel;
using Pf2eModel.Model.Enum;
namespace Pf2eDataScrapper.WPF.Views;
/// <summary>
/// Логика взаимодействия для EntityForm.xaml
/// </summary>
internal partial class EntityForm : Window
{
public Pf2eDbContext Context { get; }
public EntityFormViewModel ViewModel { get; }
public EntityForm(
Pf2eDbContext context,
EntityFormViewModel viewModel,
DbEntityListViewModel dbEntityListViewModel
)
{
Context = context;
ViewModel = viewModel;
DataContext = ViewModel;
InitializeComponent();
DbEntityListControl.ViewModel = dbEntityListViewModel;
}
}
@@ -0,0 +1,85 @@
<Window
x:Class="Pf2eDataScrapper.WPF.ProgressFormWpf"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Pf2eDataScrapper.WPF"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="ProgressWindow"
Title="Выполняется обработка..."
Width="400"
Height="500"
x:ClassModifier="internal"
mc:Ignorable="d">
<Grid Margin="3,3,3,3">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="25" />
<RowDefinition Height="Auto" />
<RowDefinition Height="25" />
<RowDefinition Height="25" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<Label
x:Name="ProcessorsLabel"
Grid.Row="0"
VerticalContentAlignment="Center"
Content="Label" />
<ProgressBar
x:Name="ProcessorsProgressBar"
Grid.Row="1"
Margin="0,0,0,5" />
<Label
x:Name="LocalLabel"
Grid.Row="2"
VerticalContentAlignment="Center"
Content="Label" />
<ProgressBar
x:Name="LocalProgressBar"
Grid.Row="3"
Margin="0,0,0,5" />
<WrapPanel Grid.Row="4" />
<ListView
x:Name="MessageListView"
Grid.Row="5"
ItemsSource="{Binding ViewRows}"
ScrollViewer.CanContentScroll="True">
<ListView.View>
<GridView>
<GridViewColumn Width="Auto" Header="Время" />
<GridViewColumn Width="Auto" Header="Тип" />
<GridViewColumn Width="Auto" Header="Сообщение" />
</GridView>
</ListView.View>
<ListView.ItemTemplate>
<DataTemplate DataType="{x:Type local:ListViewRow}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
HorizontalAlignment="Left"
Background="{Binding Path=Color}"
Text="{Binding Path=Time}" />
<TextBlock
Grid.Column="1"
HorizontalAlignment="Left"
Background="{Binding Path=Color}"
Text="{Binding Path=Level}" />
<TextBlock
Grid.Column="2"
HorizontalAlignment="Left"
Background="{Binding Path=Color}"
Text="{Binding Path=Message}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Window>
@@ -0,0 +1,78 @@
using System.Collections.ObjectModel;
using System.Windows;
using Pf2eDataScrapper.Helpers;
namespace Pf2eDataScrapper.WPF;
/// <summary>
/// Логика взаимодействия для ProgressFormWpf.xaml
/// </summary>
internal partial class ProgressFormWpf : Window
{
public ProcessProgress Progress { get; }
public ObservableCollection<ListViewRow> ViewRows { get; set; } = [];
public ProgressFormWpf(ProcessProgress progress)
{
Progress = progress;
InitializeComponent();
Progress.ProgressUpdate += Progress_ProgressUpdate;
Progress.ProgressMessage += Progress_ProgressMessage;
}
private void Progress_ProgressUpdate(ProcessProgress sender)
{
if (!Dispatcher.CheckAccess())
{
Dispatcher.Invoke(() => Progress_ProgressUpdate(sender));
return;
}
ProcessorsLabel.Content = sender.Processors.ToString();
ProcessorsProgressBar.Maximum = sender.Processors.Count;
ProcessorsProgressBar.Value = sender.Processors.Current;
LocalLabel.Content = sender.Local.ToString();
LocalProgressBar.Maximum = sender.Local.Count;
LocalProgressBar.Value = sender.Local.Current;
}
private void Progress_ProgressMessage(ProcessProgress sender, LogLevel level, string message)
{
if (!Dispatcher.CheckAccess())
{
Dispatcher.Invoke(() => Progress_ProgressMessage(sender, level, message));
return;
}
ListViewRow item = new(level, message) { IsVisible = true };
ViewRows.Add(item);
}
public event ImportApplication.ApplicationStateChangeDelegate? ApplicationStateChange;
}
internal class ListViewRow(LogLevel level, string message)
{
public string Time { get; } = DateTime.Now.ToString("HH:mm:ss.fff");
public LogLevel Level { get; } = level;
public string Message { get; } = message;
public Color Color { get; } =
level switch
{
LogLevel.Important => Color.Salmon,
LogLevel.Warning => Color.Khaki,
LogLevel.Information => Color.White,
LogLevel.Progress => Color.LightGray,
_ => Color.White,
};
public bool IsVisible { get; set; } = true;
}
+61
View File
@@ -0,0 +1,61 @@
<Window
x:Class="Pf2eDataScrapper.WPF.Views.StartForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:components="clr-namespace:Pf2eDataScrapper.WPF.Components"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Pf2eDataScrapper.WPF"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="StartForm"
Width="800"
Height="600"
x:ClassModifier="internal"
Loaded="Window_Loaded"
mc:Ignorable="d">
<Window.Background>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}" />
</Window.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" MinWidth="100" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="5*" MinWidth="200" />
</Grid.ColumnDefinitions>
<StackPanel
Grid.Row="0"
Grid.Column="0"
Margin="3,3,3,3">
<Button
Margin="0,0,0,3"
Click="ViewerButton_Click"
Content="Просмотр сущностей" />
<Button Content="Просмотр правил" />
</StackPanel>
<Button
Grid.Row="1"
Grid.Column="0"
Margin="3,3,3,3"
Click="StartButton_Click"
Content="Старт" />
<GridSplitter
Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Width="5"
HorizontalAlignment="Stretch" />
<components:ProcessorCollectionControl
x:Name="ProcessorCollectionControl"
Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="2" />
</Grid>
</Window>
@@ -0,0 +1,35 @@
using System.Windows;
using Pf2eDataScrapper.App;
namespace Pf2eDataScrapper.WPF.Views;
/// <summary>
/// Логика взаимодействия для StartForm.xaml
/// </summary>
internal partial class StartForm : Window
{
public ProcessorCollection Collection { get; }
public StartForm(ProcessorCollection collection)
{
Collection = collection;
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
ProcessorCollectionControl.Collection = Collection;
}
private void ViewerButton_Click(object sender, RoutedEventArgs e)
{
ApplicationStateChange?.Invoke(this, ApplicationStage.Viewer);
}
private void StartButton_Click(object sender, RoutedEventArgs e)
{
ApplicationStateChange?.Invoke(this, ApplicationStage.ImportProcess);
}
public event ImportApplication.ApplicationStateChangeDelegate? ApplicationStateChange;
}
@@ -0,0 +1,21 @@
using Microsoft.Extensions.DependencyInjection;
using Pf2eDataScrapper.WPF.Stores;
using Pf2eDataScrapper.WPF.ViewModels;
namespace Pf2eDataScrapper.WPF;
public static class WpfServiceProviderExtension
{
public static IServiceCollection RegisterWpfServices(this IServiceCollection collection)
{
return collection
// ViewModels
.AddTransient<EntityFormViewModel>()
.AddTransient<DbEntityListViewModel>()
// Stores
.AddSingleton<SelectedEntityTypeStore>()
.AddSingleton<SelectedEntityStore>()
//
;
}
}
@@ -13,7 +13,7 @@ using Pf2eModel.Model.Enum;
namespace Pf2eModel.Migrations namespace Pf2eModel.Migrations
{ {
[DbContext(typeof(Pf2eDbContext))] [DbContext(typeof(Pf2eDbContext))]
[Migration("20250515054227_1")] [Migration("20250515080518_1")]
partial class _1 partial class _1
{ {
/// <inheritdoc /> /// <inheritdoc />