2022-08-21 03:50:38 +03:00
|
|
|
using Eto.Drawing;
|
|
|
|
using Eto.Forms;
|
2022-11-02 07:22:09 +03:00
|
|
|
using NAPS2.EtoForms.Layout;
|
2022-12-27 07:59:08 +03:00
|
|
|
using NAPS2.EtoForms.Widgets;
|
2022-08-21 03:50:38 +03:00
|
|
|
|
|
|
|
namespace NAPS2.EtoForms;
|
|
|
|
|
|
|
|
public abstract class EtoPlatform
|
|
|
|
{
|
|
|
|
private static EtoPlatform? _current;
|
|
|
|
|
|
|
|
public static EtoPlatform Current
|
|
|
|
{
|
|
|
|
get => _current ?? throw new InvalidOperationException();
|
|
|
|
set => _current = value ?? throw new ArgumentNullException(nameof(value));
|
|
|
|
}
|
|
|
|
|
2022-10-16 08:12:10 +03:00
|
|
|
public virtual bool IsGtk => false;
|
|
|
|
public virtual bool IsMac => false;
|
|
|
|
public virtual bool IsWinForms => false;
|
|
|
|
|
2022-10-16 03:13:52 +03:00
|
|
|
public abstract Application CreateApplication();
|
2022-08-21 03:50:38 +03:00
|
|
|
public abstract IListView<T> CreateListView<T>(ListViewBehavior<T> behavior) where T : notnull;
|
2022-12-05 07:41:42 +03:00
|
|
|
public abstract void ConfigureImageButton(Button button, bool big);
|
2022-08-21 03:50:38 +03:00
|
|
|
public abstract Bitmap ToBitmap(IMemoryImage image);
|
2024-04-01 10:25:25 +03:00
|
|
|
public abstract IMemoryImage FromBitmap(Bitmap bitmap);
|
|
|
|
public abstract IMemoryImage DrawHourglass(IMemoryImage thumb);
|
2022-11-03 07:17:01 +03:00
|
|
|
public abstract void SetFrame(Control container, Control control, Point location, Size size, bool inOverlay);
|
2022-10-12 04:52:08 +03:00
|
|
|
public abstract Control CreateContainer();
|
2022-11-03 07:17:01 +03:00
|
|
|
public abstract void AddToContainer(Control container, Control control, bool inOverlay);
|
2023-04-02 22:55:32 +03:00
|
|
|
public abstract void RemoveFromContainer(Control container, Control control);
|
2022-10-13 04:21:27 +03:00
|
|
|
|
2022-11-02 09:41:39 +03:00
|
|
|
public abstract Control AccessibleImageButton(Image image, string text, Action onClick,
|
|
|
|
int xOffset = 0, int yOffset = 0);
|
|
|
|
|
2023-10-09 03:14:46 +03:00
|
|
|
public virtual void InitializePlatform()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-03-16 04:55:50 +03:00
|
|
|
public virtual void Invoke(Application application, Action action)
|
|
|
|
{
|
|
|
|
application.Invoke(action);
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void AsyncInvoke(Application application, Action action)
|
|
|
|
{
|
|
|
|
application.AsyncInvoke(action);
|
|
|
|
}
|
|
|
|
|
2022-11-02 23:19:50 +03:00
|
|
|
public virtual void SetContainerSize(Window window, Control container, Size size, int padding)
|
2022-11-02 03:45:30 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-10-14 02:17:05 +03:00
|
|
|
public virtual Size GetFormSize(Window window)
|
|
|
|
{
|
|
|
|
return window.Size;
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void SetFormSize(Window window, Size size)
|
|
|
|
{
|
|
|
|
window.Size = size;
|
|
|
|
}
|
2022-10-14 05:12:55 +03:00
|
|
|
|
2022-12-28 10:28:10 +03:00
|
|
|
public virtual Size GetClientSize(Window window, bool excludeToolbars = false)
|
2022-10-16 03:12:52 +03:00
|
|
|
{
|
|
|
|
return window.ClientSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void SetClientSize(Window window, Size clientSize)
|
|
|
|
{
|
|
|
|
window.ClientSize = clientSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void SetMinimumClientSize(Window window, Size minSize)
|
|
|
|
{
|
|
|
|
var windowDecorationSize = window.Size - window.ClientSize;
|
|
|
|
window.MinimumSize = minSize + windowDecorationSize;
|
|
|
|
}
|
|
|
|
|
2022-10-14 05:12:55 +03:00
|
|
|
public virtual SizeF GetPreferredSize(Control control, SizeF availableSpace)
|
|
|
|
{
|
|
|
|
return control.GetPreferredSize(availableSpace);
|
|
|
|
}
|
2022-11-02 07:22:09 +03:00
|
|
|
|
|
|
|
public virtual LayoutElement FormatProgressBar(ProgressBar progressBar)
|
|
|
|
{
|
|
|
|
return progressBar.Width(420).Padding(top: 10, bottom: 10);
|
|
|
|
}
|
2022-11-02 09:16:54 +03:00
|
|
|
|
|
|
|
public virtual void SetFormLocation(Window window, Point location)
|
|
|
|
{
|
|
|
|
window.Location = location;
|
|
|
|
}
|
2022-11-03 01:33:22 +03:00
|
|
|
|
|
|
|
public virtual void UpdateRtl(Window window)
|
|
|
|
{
|
|
|
|
}
|
2022-11-03 03:26:11 +03:00
|
|
|
|
2022-11-03 07:17:01 +03:00
|
|
|
public virtual void ConfigureZoomButton(Button button)
|
2022-11-03 03:26:11 +03:00
|
|
|
{
|
|
|
|
}
|
2022-11-29 05:26:44 +03:00
|
|
|
|
|
|
|
public virtual SizeF GetWrappedSize(Control control, int defaultWidth)
|
|
|
|
{
|
2022-12-29 01:36:43 +03:00
|
|
|
return GetPreferredSize(control, new SizeF(defaultWidth, LayoutController.MAX_SIZE));
|
2022-11-29 05:26:44 +03:00
|
|
|
}
|
2022-11-29 07:58:55 +03:00
|
|
|
|
2024-01-10 08:00:19 +03:00
|
|
|
public virtual void SetClipboardImage(Clipboard clipboard, ProcessedImage processedImage, IMemoryImage memoryImage)
|
2022-11-29 07:58:55 +03:00
|
|
|
{
|
2024-01-10 08:00:19 +03:00
|
|
|
using var etoBitmap = memoryImage.ToEtoImage();
|
|
|
|
clipboard.Image = etoBitmap;
|
2022-11-29 07:58:55 +03:00
|
|
|
}
|
2022-12-03 04:31:01 +03:00
|
|
|
|
|
|
|
public virtual void ConfigureDropDown(DropDown dropDown)
|
|
|
|
{
|
|
|
|
}
|
2022-12-03 04:48:33 +03:00
|
|
|
|
2022-12-05 00:12:22 +03:00
|
|
|
public virtual LayoutElement CreateGroupBox(string title, LayoutElement content)
|
|
|
|
{
|
|
|
|
var groupBox = new GroupBox { Text = title };
|
2022-12-29 01:25:32 +03:00
|
|
|
return L.Overlay(groupBox, L.Buffer(content, 6, IsGtk ? 21 : 18, 6, 6));
|
2022-12-05 00:12:22 +03:00
|
|
|
}
|
|
|
|
|
2022-12-03 04:48:33 +03:00
|
|
|
public virtual void ShowIcon(Dialog dialog)
|
|
|
|
{
|
|
|
|
}
|
2022-12-05 04:58:10 +03:00
|
|
|
|
|
|
|
public virtual void ConfigureEllipsis(Label label)
|
|
|
|
{
|
|
|
|
}
|
2022-12-05 07:41:42 +03:00
|
|
|
|
|
|
|
public virtual Bitmap? ExtractAssociatedIcon(string exePath) => throw new NotSupportedException();
|
2022-12-26 10:40:43 +03:00
|
|
|
|
2024-04-07 21:19:51 +03:00
|
|
|
public virtual void HandleKeyDown(Control control, Func<Keys, bool> handle)
|
|
|
|
{
|
|
|
|
control.KeyDown += (_, args) => args.Handled = handle(args.KeyData);
|
|
|
|
}
|
|
|
|
|
2022-12-27 05:43:55 +03:00
|
|
|
public virtual void AttachMouseWheelEvent(Control control, EventHandler<MouseEventArgs> eventHandler)
|
2022-12-26 10:40:43 +03:00
|
|
|
{
|
2022-12-27 05:43:55 +03:00
|
|
|
control.MouseWheel += eventHandler;
|
2022-12-26 10:40:43 +03:00
|
|
|
}
|
2024-04-14 06:09:24 +03:00
|
|
|
|
|
|
|
public virtual void AttachMouseMoveEvent(Control control, EventHandler<MouseEventArgs> eventHandler)
|
|
|
|
{
|
|
|
|
control.MouseMove += eventHandler;
|
|
|
|
}
|
2022-08-21 03:50:38 +03:00
|
|
|
}
|