Завершение обновления формы отображения
This commit is contained in:
+16
-56
@@ -1,13 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System.ComponentModel;
|
||||
using Pf2eModel;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Common.I18n;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eViewer.Converters;
|
||||
|
||||
namespace Pf2eViewer;
|
||||
|
||||
@@ -15,18 +8,21 @@ public partial class MainViewForm : Form
|
||||
{
|
||||
public Pf2eDbContext Context = new();
|
||||
|
||||
public readonly string JsonViewerHtml;
|
||||
|
||||
[AllowNull]
|
||||
public readonly EntityView Viewer = null;
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public EntityView? CurrentView
|
||||
{
|
||||
get => EntityTreeViewerControl.EntityView;
|
||||
set
|
||||
{
|
||||
EntityTreeViewerControl.EntityView = value;
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
|
||||
public MainViewForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
using StreamReader reader = new("Resources/json-viewer.html");
|
||||
JsonViewerHtml = reader.ReadToEnd();
|
||||
|
||||
DatabaseViewer.EntityChange += DatabaseViewer_EntityChange;
|
||||
|
||||
Reset();
|
||||
@@ -45,36 +41,6 @@ public partial class MainViewForm : Form
|
||||
TypesListBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void ToggleFreeze(bool state)
|
||||
{
|
||||
// EntityGridView.Visible = state;
|
||||
// JsonWebView.Visible = state;
|
||||
}
|
||||
|
||||
private void DatabaseViewer_EntityChange(EntityView newEntity)
|
||||
{
|
||||
JsonSerializerSettings settings = new()
|
||||
{
|
||||
Converters =
|
||||
[
|
||||
new StringEnumConverter { NamingStrategy = new CamelCaseNamingStrategy() },
|
||||
new EntityConverter(),
|
||||
new LocaleStringConverter(),
|
||||
],
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
};
|
||||
|
||||
string result = JsonConvert.SerializeObject(newEntity.Entity, settings);
|
||||
string subResult = JsonConvert.SerializeObject(newEntity.SubEntity, settings);
|
||||
|
||||
string json = result[..^1] + $",\"SubEntity\":{subResult}}}";
|
||||
|
||||
EntityTreeViewerControl.EntityView = newEntity;
|
||||
// RenderJson(json);
|
||||
|
||||
DescriptionTextBox.Text = newEntity.Entity!.Description;
|
||||
}
|
||||
|
||||
private void TypesListBox_SelectedIndexChanged(object sender, EventArgs _)
|
||||
{
|
||||
if (TypesListBox.SelectedItem is null)
|
||||
@@ -82,21 +48,15 @@ public partial class MainViewForm : Form
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentView = null;
|
||||
|
||||
DatabaseViewer.Type = (EntityType)TypesListBox.SelectedItem;
|
||||
// Viewer.Page = 1;
|
||||
}
|
||||
|
||||
public void RenderJson(string json)
|
||||
private void DatabaseViewer_EntityChange(EntityView newEntity)
|
||||
{
|
||||
/*
|
||||
if (JsonWebView.CoreWebView2 == null)
|
||||
{
|
||||
JsonWebView.EnsureCoreWebView2Async();
|
||||
return;
|
||||
}
|
||||
CurrentView = newEntity;
|
||||
|
||||
string html = JsonViewerHtml.Replace("{JSON}", json);
|
||||
JsonWebView.CoreWebView2.NavigateToString(html);
|
||||
*/
|
||||
DescriptionTextBox.Text = newEntity.Entity!.Description;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user