mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-19 03:37:38 +03:00
7ca1cf7ef5
This helps organize logic a bit and better handles cases where forms have parameters.
39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using Eto.Forms;
|
|
using NAPS2.EtoForms.Layout;
|
|
|
|
namespace NAPS2.EtoForms;
|
|
|
|
public abstract class EtoFormBase : Form, IFormBase
|
|
{
|
|
private IFormFactory? _formFactory;
|
|
|
|
protected EtoFormBase(Naps2Config config)
|
|
{
|
|
EtoPlatform.Current.UpdateRtl(this);
|
|
Config = config;
|
|
FormStateController = new FormStateController(this, config);
|
|
Resizable = true;
|
|
LayoutController.Bind(this);
|
|
LayoutController.Invalidated += (_, _) => FormStateController.UpdateLayoutSize(LayoutController);
|
|
}
|
|
|
|
protected abstract void BuildLayout();
|
|
|
|
protected override void OnPreLoad(EventArgs e)
|
|
{
|
|
BuildLayout();
|
|
base.OnPreLoad(e);
|
|
}
|
|
|
|
public FormStateController FormStateController { get; }
|
|
|
|
public LayoutController LayoutController { get; } = new();
|
|
|
|
public IFormFactory FormFactory
|
|
{
|
|
get => _formFactory ?? throw new InvalidOperationException();
|
|
set => _formFactory = value;
|
|
}
|
|
|
|
public Naps2Config Config { get; set; }
|
|
} |