From 79137e7bc120e74fe4472aaa7fd9ed8bbb512695 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Fri, 17 May 2024 20:43:16 +0200 Subject: [PATCH] add api culture --- OwnChar.App.Desktop/Api/IMainWindowApi.cs | 10 ++++++++ OwnChar.App.Desktop/Api/IMainWindowTab.cs | 8 +++++++ OwnChar.App.Desktop/Api/IOwnCharApi.cs | 14 +++++++++++ OwnChar.App.Desktop/AppApi.cs | 7 +++--- OwnChar.App.Desktop/AppPlugin.cs | 5 ++-- OwnChar.App.Desktop/FeatureCodes.cs | 9 ++------ .../MainWindow/MainTabs/TabMyGroupsFeature.cs | 16 +++++++++++++ .../MainWindow/MainTabs/TabMyUserFeature.cs | 16 +++++++++++++ .../MainWindow/QuickAction/HomeFeature.cs | 17 ++++++++++++++ .../MainWindow/QuickAction/SettingsFeature.cs | 17 ++++++++++++++ OwnChar.App.Desktop/Program.cs | 9 ++++---- .../UI/MainTabs/TabCharListFeature.cs | 20 ---------------- .../UI/MainTabs/TabEditChar.cs | 9 -------- .../UI/MainTabs/TabEditCharFeature.cs | 20 ---------------- OwnChar.App.Desktop/UI/Windows/MainWindow.cs | 12 +++------- .../UI/Windows/MainWindowApi.cs | 23 +++++++++++++++++++ 16 files changed, 138 insertions(+), 74 deletions(-) create mode 100644 OwnChar.App.Desktop/Api/IMainWindowApi.cs create mode 100644 OwnChar.App.Desktop/Api/IMainWindowTab.cs create mode 100644 OwnChar.App.Desktop/Api/IOwnCharApi.cs create mode 100644 OwnChar.App.Desktop/Features/MainWindow/MainTabs/TabMyGroupsFeature.cs create mode 100644 OwnChar.App.Desktop/Features/MainWindow/MainTabs/TabMyUserFeature.cs create mode 100644 OwnChar.App.Desktop/Features/MainWindow/QuickAction/HomeFeature.cs create mode 100644 OwnChar.App.Desktop/Features/MainWindow/QuickAction/SettingsFeature.cs delete mode 100644 OwnChar.App.Desktop/UI/MainTabs/TabCharListFeature.cs delete mode 100644 OwnChar.App.Desktop/UI/MainTabs/TabEditCharFeature.cs create mode 100644 OwnChar.App.Desktop/UI/Windows/MainWindowApi.cs diff --git a/OwnChar.App.Desktop/Api/IMainWindowApi.cs b/OwnChar.App.Desktop/Api/IMainWindowApi.cs new file mode 100644 index 0000000..bad4d94 --- /dev/null +++ b/OwnChar.App.Desktop/Api/IMainWindowApi.cs @@ -0,0 +1,10 @@ +using System.Windows.Forms; + +namespace OwnChar.App.Desktop.Api +{ + public interface IMainWindowApi + { + void OpenTab(Control content); + void CloseTab(Control content); + } +} diff --git a/OwnChar.App.Desktop/Api/IMainWindowTab.cs b/OwnChar.App.Desktop/Api/IMainWindowTab.cs new file mode 100644 index 0000000..2cd2a5a --- /dev/null +++ b/OwnChar.App.Desktop/Api/IMainWindowTab.cs @@ -0,0 +1,8 @@ +namespace OwnChar.App.Desktop.Api +{ + public interface IMainWindowTab + { + string Name { get; } + IMainWindowApi MaindWindow { get; internal set; } + } +} diff --git a/OwnChar.App.Desktop/Api/IOwnCharApi.cs b/OwnChar.App.Desktop/Api/IOwnCharApi.cs new file mode 100644 index 0000000..1280b25 --- /dev/null +++ b/OwnChar.App.Desktop/Api/IOwnCharApi.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OwnChar.App.Desktop.Api +{ + public interface IOwnCharApi + { + public static IOwnCharApi Instance { get; } = new AppApi(); + public IMainWindowApi? MainWindow { get; internal set; } + } +} diff --git a/OwnChar.App.Desktop/AppApi.cs b/OwnChar.App.Desktop/AppApi.cs index 438fd09..883b795 100644 --- a/OwnChar.App.Desktop/AppApi.cs +++ b/OwnChar.App.Desktop/AppApi.cs @@ -1,4 +1,5 @@ -using System; +using OwnChar.App.Desktop.Api; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,8 +7,8 @@ using System.Threading.Tasks; namespace OwnChar.App.Desktop { - public sealed class AppApi + public sealed class AppApi : IOwnCharApi { - public AppApi Instance = new(); + public IMainWindowApi? MainWindow { get; internal set; } } } diff --git a/OwnChar.App.Desktop/AppPlugin.cs b/OwnChar.App.Desktop/AppPlugin.cs index 01df0d2..455f281 100644 --- a/OwnChar.App.Desktop/AppPlugin.cs +++ b/OwnChar.App.Desktop/AppPlugin.cs @@ -1,4 +1,5 @@ -using OwnChar.Plugins; +using OwnChar.App.Desktop.Api; +using OwnChar.Plugins; using Pilz.Plugins.Advanced; namespace OwnChar.App.Desktop @@ -18,7 +19,7 @@ namespace OwnChar.App.Desktop public object? GetApi() { - return null; + return IOwnCharApi.Instance; } } } diff --git a/OwnChar.App.Desktop/FeatureCodes.cs b/OwnChar.App.Desktop/FeatureCodes.cs index 88d7f89..2dea80d 100644 --- a/OwnChar.App.Desktop/FeatureCodes.cs +++ b/OwnChar.App.Desktop/FeatureCodes.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace OwnChar.App.Desktop +namespace OwnChar.App.Desktop { public static class FeatureCodes { public const string MainTab = "ownchar.app.desktop.main.tab"; + public const string QuickAction = "ownchar.app.desktop.main.quickaction"; } } diff --git a/OwnChar.App.Desktop/Features/MainWindow/MainTabs/TabMyGroupsFeature.cs b/OwnChar.App.Desktop/Features/MainWindow/MainTabs/TabMyGroupsFeature.cs new file mode 100644 index 0000000..463f7fc --- /dev/null +++ b/OwnChar.App.Desktop/Features/MainWindow/MainTabs/TabMyGroupsFeature.cs @@ -0,0 +1,16 @@ +using OwnChar.App.Desktop.UI.MainTabs; +using Pilz.Plugins.Advanced; +using Pilz.Plugins.Advanced.UI.Telerik; + +namespace OwnChar.App.Desktop.Features.MainWindow.MainTabs +{ + internal class TabMyGroupsFeature() : PluginModule(FeatureCodes.MainTab, "ownchar.mygroups", "My groups"), IPluginFeatureProvider + { + public static TabMyGroupsFeature Instance { get; } = new(); + + protected override PluginModuleUI CreateNewUI() + { + return new TabCharList(); + } + } +} diff --git a/OwnChar.App.Desktop/Features/MainWindow/MainTabs/TabMyUserFeature.cs b/OwnChar.App.Desktop/Features/MainWindow/MainTabs/TabMyUserFeature.cs new file mode 100644 index 0000000..c439804 --- /dev/null +++ b/OwnChar.App.Desktop/Features/MainWindow/MainTabs/TabMyUserFeature.cs @@ -0,0 +1,16 @@ +using OwnChar.App.Desktop.UI.MainTabs; +using Pilz.Plugins.Advanced; +using Pilz.Plugins.Advanced.UI.Telerik; + +namespace OwnChar.App.Desktop.Features.MainWindow.MainTabs +{ + internal class TabMyUserFeature() : PluginModule(FeatureCodes.MainTab, "ownchar.myuser", "My user"), IPluginFeatureProvider + { + public static TabMyUserFeature Instance { get; } = new(); + + protected override PluginModuleUI CreateNewUI() + { + return new TabEditChar(); + } + } +} diff --git a/OwnChar.App.Desktop/Features/MainWindow/QuickAction/HomeFeature.cs b/OwnChar.App.Desktop/Features/MainWindow/QuickAction/HomeFeature.cs new file mode 100644 index 0000000..4aa3c52 --- /dev/null +++ b/OwnChar.App.Desktop/Features/MainWindow/QuickAction/HomeFeature.cs @@ -0,0 +1,17 @@ +using OwnChar.App.Desktop.Features.MainWindow.MainTabs; +using Pilz.Plugins.Advanced; +using Pilz.Plugins.Advanced.UI.Telerik; + +namespace OwnChar.App.Desktop.Features.MainWindow.QuickAction +{ + internal class HomeFeature() : PluginModule(FeatureCodes.QuickAction, "ownchar.home", "Home"), IPluginFeatureProvider + { + public static TabMyUserFeature Instance { get; } = new(); + + protected override PluginModuleUI CreateNewUI() + { + return null; + //return new TabEditChar(); + } + } +} diff --git a/OwnChar.App.Desktop/Features/MainWindow/QuickAction/SettingsFeature.cs b/OwnChar.App.Desktop/Features/MainWindow/QuickAction/SettingsFeature.cs new file mode 100644 index 0000000..4f2f48f --- /dev/null +++ b/OwnChar.App.Desktop/Features/MainWindow/QuickAction/SettingsFeature.cs @@ -0,0 +1,17 @@ +using OwnChar.App.Desktop.Features.MainWindow.MainTabs; +using Pilz.Plugins.Advanced; +using Pilz.Plugins.Advanced.UI.Telerik; + +namespace OwnChar.App.Desktop.Features.MainWindow.QuickAction +{ + internal class SettingsFeature() : PluginModule(FeatureCodes.QuickAction, "ownchar.settings", "Settings"), IPluginFeatureProvider + { + public static TabMyUserFeature Instance { get; } = new(); + + protected override PluginModuleUI CreateNewUI() + { + return null; + //return new TabSettings(); + } + } +} diff --git a/OwnChar.App.Desktop/Program.cs b/OwnChar.App.Desktop/Program.cs index c8231ae..aea7e7d 100644 --- a/OwnChar.App.Desktop/Program.cs +++ b/OwnChar.App.Desktop/Program.cs @@ -1,10 +1,9 @@ -using OwnChar.App.Desktop.UI.Windows; +using OwnChar.App.Desktop.Api; +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; @@ -31,7 +30,9 @@ namespace OwnChar.App.Desktop OwnCharPlugins.Instance.LoadPlugins(plugins); } - Application.Run(new MainWindow()); + var mainWindow = new MainWindow(); + IOwnCharApi.Instance.MainWindow = mainWindow.Api; + Application.Run(mainWindow); } } } \ No newline at end of file diff --git a/OwnChar.App.Desktop/UI/MainTabs/TabCharListFeature.cs b/OwnChar.App.Desktop/UI/MainTabs/TabCharListFeature.cs deleted file mode 100644 index afea36f..0000000 --- a/OwnChar.App.Desktop/UI/MainTabs/TabCharListFeature.cs +++ /dev/null @@ -1,20 +0,0 @@ -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.cs b/OwnChar.App.Desktop/UI/MainTabs/TabEditChar.cs index 632ecfe..efdc203 100644 --- a/OwnChar.App.Desktop/UI/MainTabs/TabEditChar.cs +++ b/OwnChar.App.Desktop/UI/MainTabs/TabEditChar.cs @@ -1,13 +1,4 @@ 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 { diff --git a/OwnChar.App.Desktop/UI/MainTabs/TabEditCharFeature.cs b/OwnChar.App.Desktop/UI/MainTabs/TabEditCharFeature.cs deleted file mode 100644 index 1b80848..0000000 --- a/OwnChar.App.Desktop/UI/MainTabs/TabEditCharFeature.cs +++ /dev/null @@ -1,20 +0,0 @@ -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.cs b/OwnChar.App.Desktop/UI/Windows/MainWindow.cs index b30e7d2..bf0f54e 100644 --- a/OwnChar.App.Desktop/UI/Windows/MainWindow.cs +++ b/OwnChar.App.Desktop/UI/Windows/MainWindow.cs @@ -1,23 +1,17 @@ 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; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using Telerik.WinControls; using Telerik.WinControls.UI; namespace OwnChar.App.Desktop.UI.Windows { public partial class MainWindow : RadForm { + public MainWindowApi Api { get; } + public MainWindow() { + Api = new(this); InitializeComponent(); PluginFeatureController.Instance.Features.Get(FeatureCodes.MainTab).InsertItemsTo(radMenuItem2.Items, customClickHandler: MainTabItem_Clicked); } diff --git a/OwnChar.App.Desktop/UI/Windows/MainWindowApi.cs b/OwnChar.App.Desktop/UI/Windows/MainWindowApi.cs new file mode 100644 index 0000000..d5c32c4 --- /dev/null +++ b/OwnChar.App.Desktop/UI/Windows/MainWindowApi.cs @@ -0,0 +1,23 @@ +using OwnChar.App.Desktop.Api; +using System; +using System.Windows.Forms; + +namespace OwnChar.App.Desktop.UI.Windows; + +public partial class MainWindow +{ + public class MainWindowApi(MainWindow mainWindow) : IMainWindowApi + { + public MainWindow MainWindow { get; } = mainWindow; + + public void CloseTab(Control content) + { + throw new NotImplementedException(); + } + + public void OpenTab(Control content) + { + throw new NotImplementedException(); + } + } +}