63 lines
1.4 KiB
C#
63 lines
1.4 KiB
C#
using System.ComponentModel;
|
|
using Pf2eModel;
|
|
using Pf2eModel.Model.Enum;
|
|
|
|
namespace Pf2eViewer;
|
|
|
|
public partial class MainViewForm : Form
|
|
{
|
|
public Pf2eDbContext Context = new();
|
|
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
|
public EntityView? CurrentView
|
|
{
|
|
get => EntityTreeViewerControl.EntityView;
|
|
set
|
|
{
|
|
EntityTreeViewerControl.EntityView = value;
|
|
Application.DoEvents();
|
|
}
|
|
}
|
|
|
|
public MainViewForm()
|
|
{
|
|
InitializeComponent();
|
|
|
|
DatabaseViewer.EntityChange += DatabaseViewer_EntityChange;
|
|
|
|
Reset();
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
Context.Dispose();
|
|
Context = new();
|
|
|
|
TypesListBox.DataSource = Context
|
|
.Entities.Select(e => e.Type)
|
|
.Distinct()
|
|
.OrderBy(t => t.ToString())
|
|
.ToList();
|
|
TypesListBox.SelectedIndex = 0;
|
|
}
|
|
|
|
private void TypesListBox_SelectedIndexChanged(object sender, EventArgs _)
|
|
{
|
|
if (TypesListBox.SelectedItem is null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CurrentView = null;
|
|
|
|
DatabaseViewer.Type = (EntityType)TypesListBox.SelectedItem;
|
|
}
|
|
|
|
private void DatabaseViewer_EntityChange(EntityView newEntity)
|
|
{
|
|
CurrentView = newEntity;
|
|
|
|
DescriptionTextBox.Text = newEntity.Entity!.Description;
|
|
}
|
|
}
|