diff --git a/Pilz.Plugins.Advanced.UI.Gtk/Extensions.cs b/Pilz.Plugins.Advanced.UI.Gtk/Extensions.cs deleted file mode 100644 index 2777de3..0000000 --- a/Pilz.Plugins.Advanced.UI.Gtk/Extensions.cs +++ /dev/null @@ -1,128 +0,0 @@ -using Gtk; - -namespace Pilz.Plugins.Advanced.UI.Gtk; - -public static class Extensions -{ - private class PluginFunctionEventArgs(EventArgs original, PluginFunction function) : EventArgs - { - public EventArgs Original { get; } = original; - public PluginFunction Function { get; } = function; - } - - private class PluginModuleEventArgs(EventArgs original, PluginModuleBase function) : EventArgs - { - public EventArgs Original { get; } = original; - public PluginModuleBase Function { get; } = function; - } - - public static MenuItem GetAsItem(this PluginModuleBase module) - { - return module.GetAsItem(true); - } - - public static MenuItem GetAsItem(this PluginModuleBase module, bool addDefaultHandler) - { - return module.GetAsItem(addDefaultHandler ? (sender, e) => RadMenuItem_RMMethod_Click(sender, new PluginModuleEventArgs(e, module)) : null); - } - - public static MenuItem GetAsItem(this PluginFunction function) - { - return function.GetAsItem(true); - } - - public static MenuItem GetAsItem(this PluginFunction function, bool addDefaultHandler) - { - return function.GetAsItem(addDefaultHandler ? (sender, e) => RadMenuItem_RMFunction_Click(sender, new PluginFunctionEventArgs(e, function)) : null); - } - - public static MenuItem GetAsItem(this PluginFeature module, EventHandler? clickHandler) - { - var item = new MenuItem(module.Name) - { - Visible = module.Enabled, - TooltipText = module.Description ?? module.Name - }; - - if (clickHandler is not null) - item.Activated += clickHandler; - - return item; - } - - /// - /// Inserts all items to a menu item. - /// - /// - /// - /// Will add a default click handler that executes the feature.
- /// You usually don't set customClickHandler if you set this parameter to true. - /// Adds a custom click handler. If addDefaultHandler is true, it will only work on s.
- /// You usually don't set addDefaultHandler to true if you set this parameter to something not null. - /// Defines a custom default position (index). - /// Defines a custom top position (index). - /// Defines a custom bottom position (index). - /// Defines if splitters should be inserted to seperate the new items by priorization. - public static IEnumerable> InsertItemsTo(this IEnumerable features, - MenuItem parentMenuItem, - bool addDefaultHandler = false, - EventHandler? customClickHandler = null, - int? customDefault = null, - int? customTop = null, - int? customBottom = null, - bool insertPrioSplitters = false) - { - var insertedItems = new List>(); - FeaturePrioritization? prevPrio = null; - - // Oder by priorization - features = features.OrderByDescending(n => n.Prioritization); - - foreach (var feature in features) - { - MenuItem item; - - if (feature is PluginFunction function) - item = function.GetAsItem(addDefaultHandler); - else if (feature is PluginModuleBase module) - item = module.GetAsItem(addDefaultHandler); - else - item = feature.GetAsItem(null); - - if (!addDefaultHandler && customClickHandler != null) - item.Activated += customClickHandler; - - if (insertPrioSplitters && prevPrio > feature.Prioritization) - { - if (prevPrio != null) - insertItem(new SeparatorMenuItem()); - prevPrio = feature.Prioritization; - } - - insertItem(item); - - void insertItem(MenuItem item) - { - if (parentMenuItem.Submenu is Menu subMenu) - subMenu.Append(item); - } - - if (item.Parent != null) - insertedItems.Add(new(item, feature)); - } - - return insertedItems; - } - - private static void RadMenuItem_RMMethod_Click(object? sender, EventArgs e) - { - if (sender is MenuItem item && item.Sensitive && e is PluginFunctionEventArgs args && args.Function.Enabled) - throw new NotImplementedException(); - } - - private static void RadMenuItem_RMFunction_Click(object? sender, EventArgs e) - { - if (sender is MenuItem item && item.Sensitive && e is PluginFunctionEventArgs args && args.Function.Enabled) - args.Function.Execute(); - } -} \ No newline at end of file diff --git a/Pilz.Plugins.Advanced.UI.Gtk/Pilz.Plugins.Advanced.UI.Gtk.csproj b/Pilz.Plugins.Advanced.UI.Gtk/Pilz.Plugins.Advanced.UI.Gtk.csproj deleted file mode 100644 index e9f3589..0000000 --- a/Pilz.Plugins.Advanced.UI.Gtk/Pilz.Plugins.Advanced.UI.Gtk.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - net8.0 - enable - enable - - - - 1.0.0 - - - - - - - - - - - - diff --git a/Pilz.UI.Gtk/Dialogs/GtkContent.cs b/Pilz.UI.Gtk/Dialogs/GtkContent.cs deleted file mode 100644 index 2247091..0000000 --- a/Pilz.UI.Gtk/Dialogs/GtkContent.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Gtk; - -namespace Pilz.UI.Gtk.Dialogs; - -public class GtkContent : Box -{ - public GtkDialogBase Dialog { get; internal set; } = null!; - public ResponseType Result { get; set; } = ResponseType.Cancel; - - public bool RegisterDialogAccept { get; set; } = true; - public bool RegisterDialogCancel { get; set; } = true; - - protected GtkContent() - { - } - - protected GtkContent(nint raw) : base(raw) - { - } - - protected void Close(ResponseType result) - { - Result = result; - Dialog.Destroy(); - } - - protected virtual bool ValidateOK() - { - return true; - } - - protected virtual void Button_Confirm_Clicked(object? sender, EventArgs e) - { - if (ValidateOK()) - Close(ResponseType.Ok); - } - - protected virtual void Button_Cancel_Clicked(object? sender, EventArgs e) - { - Close(ResponseType.Cancel); - } -} diff --git a/Pilz.UI.Gtk/Dialogs/GtkDialogBase.Statics.cs b/Pilz.UI.Gtk/Dialogs/GtkDialogBase.Statics.cs deleted file mode 100644 index cea742b..0000000 --- a/Pilz.UI.Gtk/Dialogs/GtkDialogBase.Statics.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Gtk; - -namespace Pilz.UI.Gtk.Dialogs; - -public partial class GtkDialogBase -{ - private static GtkDialogBase CreateDialog(TContent content, string title) where TContent : Widget - { - var dialog = new GtkDialogBase - { - Title = title, - }; - dialog.ContentArea.Add(content); - content.Show(); - return dialog; - } - - public static TContent Show(TContent content, string title) where TContent : Widget - { - var dialog = CreateDialog(content, title); - dialog.Show(); - dialog.Destroy(); - return content; - } - - public static TContent ShowDialog(TContent content, string title) where TContent : Widget - { - var dialog = CreateDialog(content, title); - dialog.Run(); - dialog.Destroy(); - return content; - } -} diff --git a/Pilz.UI.Gtk/Dialogs/GtkDialogBase.cs b/Pilz.UI.Gtk/Dialogs/GtkDialogBase.cs deleted file mode 100644 index 4b9f739..0000000 --- a/Pilz.UI.Gtk/Dialogs/GtkDialogBase.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Gtk; - -namespace Pilz.UI.Gtk.Dialogs; - -public partial class GtkDialogBase : Dialog -{ - public GtkDialogBase() : this(new Builder("GtkDialogBase.glade")) { } - - protected GtkDialogBase(Builder builder) : base(builder.GetRawOwnedObject("GtkDialogBase")) - { - builder.Autoconnect(this); - DefaultResponse = ResponseType.Cancel; - Response += Dialog_Response; - } - - protected virtual void Dialog_Response(object o, ResponseArgs args) - { - Hide(); - } -} diff --git a/Pilz.UI.Gtk/Dialogs/GtkDialogBase.glade b/Pilz.UI.Gtk/Dialogs/GtkDialogBase.glade deleted file mode 100644 index 1ca2644..0000000 --- a/Pilz.UI.Gtk/Dialogs/GtkDialogBase.glade +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - False - center-on-parent - dialog - - - False - vertical - 2 - - - False - end - - - gtk-apply - True - True - True - True - True - - - True - True - 0 - - - - - gtk-cancel - True - True - True - True - True - - - True - True - 1 - - - - - False - False - 0 - - - - - - - - - buttonOkay - buttonCancel - - - diff --git a/Pilz.UI.Gtk/Dialogs/MessageBox.cs b/Pilz.UI.Gtk/Dialogs/MessageBox.cs deleted file mode 100644 index 6294101..0000000 --- a/Pilz.UI.Gtk/Dialogs/MessageBox.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Gtk; - -namespace Pilz.UI.Gtk.Dialogs; - -public static class MessageBox -{ - [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Nicht verwendete Parameter entfernen", Justification = "Can be used for easier migration from WinForms. However, the title get ignored as Gtk has no title parameter.")] - public static ResponseType Show(Window window, string message, string title, ButtonsType buttons, MessageType type) - { - var msgBox = new MessageDialog(window, DialogFlags.DestroyWithParent, type, buttons, message); - var result = msgBox.Run(); - msgBox.Destroy(); - return (ResponseType)result; - } - - public static ResponseType Show(Window window, ButtonsType buttons, MessageType type, string format, params object[] args) - { - var msgBox = new MessageDialog(window, DialogFlags.DestroyWithParent, type, buttons, format, args); - var result = msgBox.Run(); - msgBox.Destroy(); - return (ResponseType)result; - } -} diff --git a/Pilz.UI.Gtk/Pilz.UI.Gtk.csproj b/Pilz.UI.Gtk/Pilz.UI.Gtk.csproj deleted file mode 100644 index 2f23f27..0000000 --- a/Pilz.UI.Gtk/Pilz.UI.Gtk.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - net8.0 - enable - enable - true - - - - 1.0.2 - - - - - - - - - - - - - - - - - - - diff --git a/Pilz.UI.Gtk/Symbols/GtkSymbolFactory.cs b/Pilz.UI.Gtk/Symbols/GtkSymbolFactory.cs deleted file mode 100644 index 22c1b6d..0000000 --- a/Pilz.UI.Gtk/Symbols/GtkSymbolFactory.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Gdk; -using Gtk; -using Pilz.UI.Symbols; -using Size = System.Drawing.Size; - -namespace Pilz.UI.Gtk.Symbols; - -public abstract class GtkSymbolFactory : BaseSymbolFactory, IGtkSymbolFactory -{ - - public virtual Pixbuf? GetPixbuf(TSymbols svgImage, SymbolSize size) - { - return GetPixbuf(svgImage, ResolveCommonSize(size)); - } - - public virtual Pixbuf? GetPixbuf(TSymbols svgImage, Size size) - { - using var stream = GetImageRessourceStream(svgImage); - - if (stream is null) - return null; - - Pixbuf pixbuf; - if (size.IsEmpty) - pixbuf = new(stream); - else - pixbuf = new(stream, size.Width, size.Height); - - return pixbuf; - } - - public virtual Image? GetImage(TSymbols svgImage, SymbolSize size) - { - return GetImage(svgImage, ResolveCommonSize(size)); - } - - public virtual Image? GetImage(TSymbols svgImage, Size size) - { - if (GetPixbuf(svgImage, size) is Pixbuf pixbuf) - return GetImageFromPixbuf(pixbuf); - return null; - } - - public virtual Image GetImageFromPixbuf(Pixbuf pixbuf) - { - return new Image(pixbuf); - } -} \ No newline at end of file diff --git a/Pilz.UI.Gtk/Symbols/IGtkSymbolFactory.cs b/Pilz.UI.Gtk/Symbols/IGtkSymbolFactory.cs deleted file mode 100644 index 275b3f0..0000000 --- a/Pilz.UI.Gtk/Symbols/IGtkSymbolFactory.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Gtk; -using Pilz.UI.Symbols; -using System.Drawing; - -namespace Pilz.UI.Gtk.Symbols; - -public interface IGtkSymbolFactory : IBaseSymbolFactory -{ - Image? GetImage(TSymbols svgImage, Size size); - Image? GetImage(TSymbols svgImage, SymbolSize size); - Gdk.Pixbuf? GetPixbuf(TSymbols svgImage, Size size); - Gdk.Pixbuf? GetPixbuf(TSymbols svgImage, SymbolSize size); - Image GetImageFromPixbuf(Gdk.Pixbuf pixbuf); -} \ No newline at end of file diff --git a/Pilz.sln b/Pilz.sln index 7d64e6a..a5b3664 100644 --- a/Pilz.sln +++ b/Pilz.sln @@ -47,12 +47,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pilz.Extensions", "Pilz.Ext EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pilz.UI.WinForms.Telerik.Symbols", "Pilz.UI.WinForms.Telerik.Symbols\Pilz.UI.WinForms.Telerik.Symbols.csproj", "{9F10C26F-1D9F-4B0B-8A7A-73A6082C5BF7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pilz.UI.Gtk", "Pilz.UI.Gtk\Pilz.UI.Gtk.csproj", "{AA8CCE40-6BEE-4DC3-B973-D4F719940793}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pilz.UI", "Pilz.UI\Pilz.UI.csproj", "{E75FBCEF-B971-4036-85D3-27D4ACA77156}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pilz.Plugins.Advanced.UI.Gtk", "Pilz.Plugins.Advanced.UI.Gtk\Pilz.Plugins.Advanced.UI.Gtk.csproj", "{F9CA6B5C-F14F-418D-9617-6007ED75E82F}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pilz.UI.AvaloniaUI.Symbols", "Pilz.UI.AvaloniaUI.Symbols\Pilz.UI.AvaloniaUI.Symbols.csproj", "{C425EA21-F478-4FDB-B05D-5AE2A2FE1865}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pilz.UI.AvaloniaUI", "Pilz.UI.AvaloniaUI\Pilz.UI.AvaloniaUI.csproj", "{919DC195-50C2-48AE-9885-94897B3DC5B4}" @@ -241,14 +237,6 @@ Global {9F10C26F-1D9F-4B0B-8A7A-73A6082C5BF7}.Release|Any CPU.Build.0 = Release|Any CPU {9F10C26F-1D9F-4B0B-8A7A-73A6082C5BF7}.Release|x86.ActiveCfg = Release|Any CPU {9F10C26F-1D9F-4B0B-8A7A-73A6082C5BF7}.Release|x86.Build.0 = Release|Any CPU - {AA8CCE40-6BEE-4DC3-B973-D4F719940793}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AA8CCE40-6BEE-4DC3-B973-D4F719940793}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AA8CCE40-6BEE-4DC3-B973-D4F719940793}.Debug|x86.ActiveCfg = Debug|Any CPU - {AA8CCE40-6BEE-4DC3-B973-D4F719940793}.Debug|x86.Build.0 = Debug|Any CPU - {AA8CCE40-6BEE-4DC3-B973-D4F719940793}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AA8CCE40-6BEE-4DC3-B973-D4F719940793}.Release|Any CPU.Build.0 = Release|Any CPU - {AA8CCE40-6BEE-4DC3-B973-D4F719940793}.Release|x86.ActiveCfg = Release|Any CPU - {AA8CCE40-6BEE-4DC3-B973-D4F719940793}.Release|x86.Build.0 = Release|Any CPU {E75FBCEF-B971-4036-85D3-27D4ACA77156}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E75FBCEF-B971-4036-85D3-27D4ACA77156}.Debug|Any CPU.Build.0 = Debug|Any CPU {E75FBCEF-B971-4036-85D3-27D4ACA77156}.Debug|x86.ActiveCfg = Debug|Any CPU @@ -257,14 +245,6 @@ Global {E75FBCEF-B971-4036-85D3-27D4ACA77156}.Release|Any CPU.Build.0 = Release|Any CPU {E75FBCEF-B971-4036-85D3-27D4ACA77156}.Release|x86.ActiveCfg = Release|Any CPU {E75FBCEF-B971-4036-85D3-27D4ACA77156}.Release|x86.Build.0 = Release|Any CPU - {F9CA6B5C-F14F-418D-9617-6007ED75E82F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F9CA6B5C-F14F-418D-9617-6007ED75E82F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F9CA6B5C-F14F-418D-9617-6007ED75E82F}.Debug|x86.ActiveCfg = Debug|Any CPU - {F9CA6B5C-F14F-418D-9617-6007ED75E82F}.Debug|x86.Build.0 = Debug|Any CPU - {F9CA6B5C-F14F-418D-9617-6007ED75E82F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F9CA6B5C-F14F-418D-9617-6007ED75E82F}.Release|Any CPU.Build.0 = Release|Any CPU - {F9CA6B5C-F14F-418D-9617-6007ED75E82F}.Release|x86.ActiveCfg = Release|Any CPU - {F9CA6B5C-F14F-418D-9617-6007ED75E82F}.Release|x86.Build.0 = Release|Any CPU {C425EA21-F478-4FDB-B05D-5AE2A2FE1865}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C425EA21-F478-4FDB-B05D-5AE2A2FE1865}.Debug|Any CPU.Build.0 = Debug|Any CPU {C425EA21-F478-4FDB-B05D-5AE2A2FE1865}.Debug|x86.ActiveCfg = Debug|Any CPU