2022-08-21 03:50:38 +03:00
|
|
|
using Eto.Forms;
|
2022-10-16 21:51:29 +03:00
|
|
|
using NAPS2.EtoForms.Layout;
|
2022-08-21 03:50:38 +03:00
|
|
|
|
|
|
|
namespace NAPS2.EtoForms;
|
|
|
|
|
|
|
|
public abstract class EtoFormBase : Form, IFormBase
|
|
|
|
{
|
|
|
|
private IFormFactory? _formFactory;
|
|
|
|
|
|
|
|
protected EtoFormBase(Naps2Config config)
|
|
|
|
{
|
2022-11-03 01:33:22 +03:00
|
|
|
EtoPlatform.Current.UpdateRtl(this);
|
2022-08-21 03:50:38 +03:00
|
|
|
Config = config;
|
|
|
|
FormStateController = new FormStateController(this, config);
|
2022-11-02 08:44:06 +03:00
|
|
|
Resizable = true;
|
2022-10-16 21:51:29 +03:00
|
|
|
LayoutController.Bind(this);
|
2022-12-10 08:39:46 +03:00
|
|
|
LayoutController.Invalidated += (_, _) => FormStateController.UpdateLayoutSize(LayoutController);
|
2022-08-21 03:50:38 +03:00
|
|
|
}
|
|
|
|
|
2022-12-10 22:36:54 +03:00
|
|
|
protected abstract void BuildLayout();
|
|
|
|
|
|
|
|
protected override void OnPreLoad(EventArgs e)
|
|
|
|
{
|
|
|
|
BuildLayout();
|
|
|
|
base.OnPreLoad(e);
|
|
|
|
}
|
|
|
|
|
2022-11-02 23:06:42 +03:00
|
|
|
public FormStateController FormStateController { get; }
|
2022-08-21 03:50:38 +03:00
|
|
|
|
2022-10-16 21:51:29 +03:00
|
|
|
public LayoutController LayoutController { get; } = new();
|
|
|
|
|
2022-08-21 03:50:38 +03:00
|
|
|
public IFormFactory FormFactory
|
|
|
|
{
|
|
|
|
get => _formFactory ?? throw new InvalidOperationException();
|
|
|
|
set => _formFactory = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Naps2Config Config { get; set; }
|
|
|
|
}
|