From af434bbb20c9d130c3eb8dd271e6a7d9a6e5d3de Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Thu, 16 May 2024 11:47:30 +0200 Subject: [PATCH] plugin shit --- OwnChar.App.Desktop.sln | 12 ++ OwnChar.App.Desktop/AppApi.cs | 3 +- OwnChar.App.Desktop/AppPlugin.cs | 19 +-- OwnChar.App.Desktop/FeatureCodes.cs | 13 ++ .../OwnChar.App.Desktop.csproj | 6 +- OwnChar.App.Desktop/Program.cs | 13 +- .../UI/MainTabs/TabCharList.Designer.cs | 37 ++++++ .../UI/MainTabs/TabCharList.cs | 22 ++++ .../UI/MainTabs/TabCharList.resx | 120 ++++++++++++++++++ .../UI/MainTabs/TabCharListFeature.cs | 20 +++ .../UI/MainTabs/TabEditChar.Designer.cs | 37 ++++++ .../UI/MainTabs/TabEditChar.cs | 22 ++++ .../UI/MainTabs/TabEditChar.resx | 120 ++++++++++++++++++ .../UI/MainTabs/TabEditCharFeature.cs | 20 +++ .../UI/Windows/MainWindow.Designer.cs | 52 ++++++-- OwnChar.App.Desktop/UI/Windows/MainWindow.cs | 12 +- .../UI/Windows/MainWindow.resx | 50 ++++---- 17 files changed, 526 insertions(+), 52 deletions(-) create mode 100644 OwnChar.App.Desktop/FeatureCodes.cs create mode 100644 OwnChar.App.Desktop/UI/MainTabs/TabCharList.Designer.cs create mode 100644 OwnChar.App.Desktop/UI/MainTabs/TabCharList.cs create mode 100644 OwnChar.App.Desktop/UI/MainTabs/TabCharList.resx create mode 100644 OwnChar.App.Desktop/UI/MainTabs/TabCharListFeature.cs create mode 100644 OwnChar.App.Desktop/UI/MainTabs/TabEditChar.Designer.cs create mode 100644 OwnChar.App.Desktop/UI/MainTabs/TabEditChar.cs create mode 100644 OwnChar.App.Desktop/UI/MainTabs/TabEditChar.resx create mode 100644 OwnChar.App.Desktop/UI/MainTabs/TabEditCharFeature.cs diff --git a/OwnChar.App.Desktop.sln b/OwnChar.App.Desktop.sln index d5c5dab..773ff66 100644 --- a/OwnChar.App.Desktop.sln +++ b/OwnChar.App.Desktop.sln @@ -5,6 +5,10 @@ VisualStudioVersion = 17.9.34714.143 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OwnChar.App.Desktop", "OwnChar.App.Desktop\OwnChar.App.Desktop.csproj", "{EEFEA78C-1351-4829-9380-9B13FE46F3CC}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OwnChar", "OwnChar\OwnChar\OwnChar.csproj", "{CEB99D50-9DE4-4E0B-BD18-A2F0D1BA7109}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OwnChar.Plugins", "OwnChar.Plugins\OwnChar.Plugins\OwnChar.Plugins.csproj", "{FC64EE8F-D2F8-4AAD-A967-D64A84C2CC90}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +19,14 @@ Global {EEFEA78C-1351-4829-9380-9B13FE46F3CC}.Debug|Any CPU.Build.0 = Debug|Any CPU {EEFEA78C-1351-4829-9380-9B13FE46F3CC}.Release|Any CPU.ActiveCfg = Release|Any CPU {EEFEA78C-1351-4829-9380-9B13FE46F3CC}.Release|Any CPU.Build.0 = Release|Any CPU + {CEB99D50-9DE4-4E0B-BD18-A2F0D1BA7109}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CEB99D50-9DE4-4E0B-BD18-A2F0D1BA7109}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CEB99D50-9DE4-4E0B-BD18-A2F0D1BA7109}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CEB99D50-9DE4-4E0B-BD18-A2F0D1BA7109}.Release|Any CPU.Build.0 = Release|Any CPU + {FC64EE8F-D2F8-4AAD-A967-D64A84C2CC90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC64EE8F-D2F8-4AAD-A967-D64A84C2CC90}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC64EE8F-D2F8-4AAD-A967-D64A84C2CC90}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC64EE8F-D2F8-4AAD-A967-D64A84C2CC90}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/OwnChar.App.Desktop/AppApi.cs b/OwnChar.App.Desktop/AppApi.cs index 8ec813c..438fd09 100644 --- a/OwnChar.App.Desktop/AppApi.cs +++ b/OwnChar.App.Desktop/AppApi.cs @@ -6,7 +6,8 @@ using System.Threading.Tasks; namespace OwnChar.App.Desktop { - public class AppApi + public sealed class AppApi { + public AppApi Instance = new(); } } diff --git a/OwnChar.App.Desktop/AppPlugin.cs b/OwnChar.App.Desktop/AppPlugin.cs index 1fe6a96..01df0d2 100644 --- a/OwnChar.App.Desktop/AppPlugin.cs +++ b/OwnChar.App.Desktop/AppPlugin.cs @@ -1,21 +1,24 @@ -using Pilz.Plugins; +using OwnChar.Plugins; using Pilz.Plugins.Advanced; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace OwnChar.App.Desktop { - public class AppPlugin : IPlugin + public class AppPlugin : IOwnCharPlugin { + public static AppPlugin? Instance { get; private set; } + + public string ID => "OwnChar.App.Desktop"; public string Name => "OwnChar Desktop App"; public AppPlugin() { + Instance = this; PluginFeatureController.Instance.RegisterAllOwn(); } + + public object? GetApi() + { + return null; + } } } diff --git a/OwnChar.App.Desktop/FeatureCodes.cs b/OwnChar.App.Desktop/FeatureCodes.cs new file mode 100644 index 0000000..88d7f89 --- /dev/null +++ b/OwnChar.App.Desktop/FeatureCodes.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OwnChar.App.Desktop +{ + public static class FeatureCodes + { + public const string MainTab = "ownchar.app.desktop.main.tab"; + } +} diff --git a/OwnChar.App.Desktop/OwnChar.App.Desktop.csproj b/OwnChar.App.Desktop/OwnChar.App.Desktop.csproj index 39d87bf..27da1ae 100644 --- a/OwnChar.App.Desktop/OwnChar.App.Desktop.csproj +++ b/OwnChar.App.Desktop/OwnChar.App.Desktop.csproj @@ -7,13 +7,14 @@ net8.0-windows true app.manifest + enable - + @@ -21,7 +22,8 @@ - + + diff --git a/OwnChar.App.Desktop/Program.cs b/OwnChar.App.Desktop/Program.cs index d4b6662..c8231ae 100644 --- a/OwnChar.App.Desktop/Program.cs +++ b/OwnChar.App.Desktop/Program.cs @@ -1,8 +1,10 @@ using OwnChar.App.Desktop.UI.Windows; +using OwnChar.Plugins; using Pilz.Plugins; using System; using System.IO; using System.Linq; +using System.Reflection; using System.Windows.Forms; using Telerik.WinControls; using Telerik.WinControls.Themes; @@ -21,10 +23,13 @@ namespace OwnChar.App.Desktop Application.SetCompatibleTextRenderingDefault(false); ThemeResolutionService.ApplicationThemeName = new Office2019LightTheme().ThemeName; - var pluginPath = Path.Combine(Path.GetDirectoryName(Pilz.IO.Extensions.GetExecutablePath()), "Plugins"); - var plugins = Directory.GetDirectories(pluginPath, "*", SearchOption.TopDirectoryOnly).Select(n => Path.Combine(n, n + ".dll")).ToArray(); - PluginManager.Instance.LoadOwnPlugins(AppPlugin.Instance); - PluginManager.Instance.LoadPlugins(plugins, AppPlugin.Instance); + OwnCharPlugins.Instance.LoadOwnPlugins(); + var pluginPath = Path.Combine(Path.GetDirectoryName(Pilz.IO.Extensions.GetExecutablePath())!, "Plugins"); + if (Directory.Exists(pluginPath)) + { + var plugins = Directory.GetDirectories(pluginPath, "*", SearchOption.TopDirectoryOnly).Select(n => Path.Combine(n, n + ".dll")).ToArray(); + OwnCharPlugins.Instance.LoadPlugins(plugins); + } Application.Run(new MainWindow()); } diff --git a/OwnChar.App.Desktop/UI/MainTabs/TabCharList.Designer.cs b/OwnChar.App.Desktop/UI/MainTabs/TabCharList.Designer.cs new file mode 100644 index 0000000..7633a25 --- /dev/null +++ b/OwnChar.App.Desktop/UI/MainTabs/TabCharList.Designer.cs @@ -0,0 +1,37 @@ +namespace OwnChar.App.Desktop.UI.MainTabs +{ + partial class TabCharList + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Komponenten-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/OwnChar.App.Desktop/UI/MainTabs/TabCharList.cs b/OwnChar.App.Desktop/UI/MainTabs/TabCharList.cs new file mode 100644 index 0000000..53c94c1 --- /dev/null +++ b/OwnChar.App.Desktop/UI/MainTabs/TabCharList.cs @@ -0,0 +1,22 @@ +using Pilz.Plugins.Advanced.UI.Telerik; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace OwnChar.App.Desktop.UI.MainTabs +{ + public partial class TabCharList : PluginModuleUI + { + public TabCharList() + { + ActionPanelVisible = false; + InitializeComponent(); + } + } +} diff --git a/OwnChar.App.Desktop/UI/MainTabs/TabCharList.resx b/OwnChar.App.Desktop/UI/MainTabs/TabCharList.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/OwnChar.App.Desktop/UI/MainTabs/TabCharList.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/OwnChar.App.Desktop/UI/MainTabs/TabCharListFeature.cs b/OwnChar.App.Desktop/UI/MainTabs/TabCharListFeature.cs new file mode 100644 index 0000000..afea36f --- /dev/null +++ b/OwnChar.App.Desktop/UI/MainTabs/TabCharListFeature.cs @@ -0,0 +1,20 @@ +using Pilz.Plugins.Advanced; +using Pilz.Plugins.Advanced.UI.Telerik; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OwnChar.App.Desktop.UI.MainTabs +{ + internal class TabCharListFeature() : PluginModule(FeatureCodes.MainTab, "ownchar.tabcharlist", "Character list"), IPluginFeatureProvider + { + public static TabCharListFeature Instance { get; } = new(); + + protected override PluginModuleUI CreateNewUI() + { + return new TabCharList(); + } + } +} diff --git a/OwnChar.App.Desktop/UI/MainTabs/TabEditChar.Designer.cs b/OwnChar.App.Desktop/UI/MainTabs/TabEditChar.Designer.cs new file mode 100644 index 0000000..c0a26c4 --- /dev/null +++ b/OwnChar.App.Desktop/UI/MainTabs/TabEditChar.Designer.cs @@ -0,0 +1,37 @@ +namespace OwnChar.App.Desktop.UI.MainTabs +{ + partial class TabEditChar + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Komponenten-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/OwnChar.App.Desktop/UI/MainTabs/TabEditChar.cs b/OwnChar.App.Desktop/UI/MainTabs/TabEditChar.cs new file mode 100644 index 0000000..632ecfe --- /dev/null +++ b/OwnChar.App.Desktop/UI/MainTabs/TabEditChar.cs @@ -0,0 +1,22 @@ +using Pilz.Plugins.Advanced.UI.Telerik; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace OwnChar.App.Desktop.UI.MainTabs +{ + public partial class TabEditChar : PluginModuleUI + { + public TabEditChar() + { + ActionPanelVisible = false; + InitializeComponent(); + } + } +} diff --git a/OwnChar.App.Desktop/UI/MainTabs/TabEditChar.resx b/OwnChar.App.Desktop/UI/MainTabs/TabEditChar.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/OwnChar.App.Desktop/UI/MainTabs/TabEditChar.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/OwnChar.App.Desktop/UI/MainTabs/TabEditCharFeature.cs b/OwnChar.App.Desktop/UI/MainTabs/TabEditCharFeature.cs new file mode 100644 index 0000000..1b80848 --- /dev/null +++ b/OwnChar.App.Desktop/UI/MainTabs/TabEditCharFeature.cs @@ -0,0 +1,20 @@ +using Pilz.Plugins.Advanced; +using Pilz.Plugins.Advanced.UI.Telerik; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OwnChar.App.Desktop.UI.MainTabs +{ + internal class TabEditCharFeature() : PluginModule(FeatureCodes.MainTab, "ownchar.tabcharedit", "Edit Character"), IPluginFeatureProvider + { + public static TabEditCharFeature Instance { get; } = new(); + + protected override PluginModuleUI CreateNewUI() + { + return new TabEditChar(); + } + } +} diff --git a/OwnChar.App.Desktop/UI/Windows/MainWindow.Designer.cs b/OwnChar.App.Desktop/UI/Windows/MainWindow.Designer.cs index 2e12e67..51d7ff4 100644 --- a/OwnChar.App.Desktop/UI/Windows/MainWindow.Designer.cs +++ b/OwnChar.App.Desktop/UI/Windows/MainWindow.Designer.cs @@ -28,20 +28,50 @@ /// private void InitializeComponent() { - ((System.ComponentModel.ISupportInitialize)(this)).BeginInit(); - this.SuspendLayout(); + radMenu1 = new Telerik.WinControls.UI.RadMenu(); + radMenuItem1 = new Telerik.WinControls.UI.RadMenuItem(); + radMenuItem2 = new Telerik.WinControls.UI.RadMenuItem(); + ((System.ComponentModel.ISupportInitialize)radMenu1).BeginInit(); + ((System.ComponentModel.ISupportInitialize)this).BeginInit(); + SuspendLayout(); // - // RadForm1 - // - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.Name = "RadForm1"; - this.Text = "RadForm1"; - ((System.ComponentModel.ISupportInitialize)(this)).EndInit(); - this.ResumeLayout(false); - + // radMenu1 + // + radMenu1.Items.AddRange(new Telerik.WinControls.RadItem[] { radMenuItem1, radMenuItem2 }); + radMenu1.Location = new System.Drawing.Point(0, 0); + radMenu1.Name = "radMenu1"; + radMenu1.Size = new System.Drawing.Size(292, 25); + radMenu1.TabIndex = 0; + // + // radMenuItem1 + // + radMenuItem1.Name = "radMenuItem1"; + radMenuItem1.Text = "Datei"; + // + // radMenuItem2 + // + radMenuItem2.Name = "radMenuItem2"; + radMenuItem2.Text = "Modules"; + // + // MainWindow + // + AutoScaleBaseSize = new System.Drawing.Size(7, 15); + AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + ClientSize = new System.Drawing.Size(292, 270); + Controls.Add(radMenu1); + Name = "MainWindow"; + Text = "RadForm1"; + ((System.ComponentModel.ISupportInitialize)radMenu1).EndInit(); + ((System.ComponentModel.ISupportInitialize)this).EndInit(); + ResumeLayout(false); + PerformLayout(); } #endregion + + private Telerik.WinControls.UI.RadMenu radMenu1; + private Telerik.WinControls.UI.RadMenuItem radMenuItem1; + private Telerik.WinControls.UI.RadMenuItem radMenuItem2; } } \ No newline at end of file diff --git a/OwnChar.App.Desktop/UI/Windows/MainWindow.cs b/OwnChar.App.Desktop/UI/Windows/MainWindow.cs index 85111a3..b30e7d2 100644 --- a/OwnChar.App.Desktop/UI/Windows/MainWindow.cs +++ b/OwnChar.App.Desktop/UI/Windows/MainWindow.cs @@ -1,4 +1,7 @@ -using System; +using Pilz.Plugins.Advanced; +using Pilz.Plugins.Advanced.UI.Telerik; +using Pilz.UI.Telerik.Dialogs; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -16,6 +19,13 @@ namespace OwnChar.App.Desktop.UI.Windows public MainWindow() { InitializeComponent(); + PluginFeatureController.Instance.Features.Get(FeatureCodes.MainTab).InsertItemsTo(radMenuItem2.Items, customClickHandler: MainTabItem_Clicked); + } + + private void MainTabItem_Clicked(object? sender, EventArgs e) + { + //if (sender is RadMenuItem item && item.Tag is PluginModule module) + //...Add() ... module.CreateUI(), "Titel", null); } } } diff --git a/OwnChar.App.Desktop/UI/Windows/MainWindow.resx b/OwnChar.App.Desktop/UI/Windows/MainWindow.resx index 7080a7d..57aad6d 100644 --- a/OwnChar.App.Desktop/UI/Windows/MainWindow.resx +++ b/OwnChar.App.Desktop/UI/Windows/MainWindow.resx @@ -1,17 +1,17 @@  -