code cleanup
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
using OwnChar.Manager;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OwnChar.App.Desktop.Api
|
||||
{
|
||||
namespace OwnChar.App.Desktop.Api;
|
||||
|
||||
public interface IMainWindowApi
|
||||
{
|
||||
Form Window { get; }
|
||||
@@ -12,4 +12,3 @@ namespace OwnChar.App.Desktop.Api
|
||||
bool IsTabOpen(Control content);
|
||||
bool IsTabOpen<T>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
namespace OwnChar.App.Desktop.Api
|
||||
{
|
||||
namespace OwnChar.App.Desktop.Api;
|
||||
|
||||
public interface IMainWindowTab
|
||||
{
|
||||
string Name { get; }
|
||||
IMainWindowApi MaindWindow { get; internal set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
using Pilz.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OwnChar.App.Desktop.Api
|
||||
{
|
||||
namespace OwnChar.App.Desktop.Api;
|
||||
|
||||
public interface IOwnCharApi
|
||||
{
|
||||
public abstract IMainWindowApi? MainWindow { get; }
|
||||
public abstract ISettings? Settings { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
using OwnChar.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OwnChar.App.Desktop.Api.Parameters
|
||||
{
|
||||
namespace OwnChar.App.Desktop.Api.Parameters;
|
||||
|
||||
public class AppInitParams(IOwnCharApi api) : OwnCharPluginInitParams
|
||||
{
|
||||
public IOwnCharApi Api { get; set; } = api;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
using Pilz.Plugins.Advanced;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OwnChar.App.Desktop.Api.Parameters
|
||||
{
|
||||
namespace OwnChar.App.Desktop.Api.Parameters;
|
||||
|
||||
public class MainWindowParams(IMainWindowApi api) : PluginFunctionParameter
|
||||
{
|
||||
public IMainWindowApi Api { get; } = api;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using OwnChar.Plugins;
|
||||
using Pilz.Configuration;
|
||||
using OwnChar.Plugins;
|
||||
using Pilz.Plugins.Advanced;
|
||||
|
||||
namespace OwnChar.App.Desktop
|
||||
{
|
||||
namespace OwnChar.App.Desktop;
|
||||
|
||||
public class AppPlugin : IOwnCharPlugin
|
||||
{
|
||||
public static AppPlugin? Instance { get; private set; }
|
||||
@@ -23,4 +21,3 @@ namespace OwnChar.App.Desktop
|
||||
return AppApi.Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
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";
|
||||
public const string LoginProvider = "ownchar.app.desktop.main.login.provider";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
using OwnChar.App.Desktop.UI.MainTabs;
|
||||
using Pilz.Plugins.Advanced;
|
||||
|
||||
namespace OwnChar.App.Desktop.Features.MainWindow.QuickAction
|
||||
{
|
||||
namespace OwnChar.App.Desktop.Features.MainWindow.QuickAction;
|
||||
|
||||
internal class HomeFeature() : PluginFunction(FeatureCodes.QuickAction, "ownchar.home", "Home"), IPluginFeatureProvider<HomeFeature>
|
||||
{
|
||||
public static HomeFeature Instance { get; } = new();
|
||||
@@ -15,4 +15,3 @@ namespace OwnChar.App.Desktop.Features.MainWindow.QuickAction
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ using OwnChar.App.Desktop.LangRes;
|
||||
using OwnChar.App.Desktop.UI.MainTabs;
|
||||
using Pilz.Plugins.Advanced;
|
||||
|
||||
namespace OwnChar.App.Desktop.Features.MainWindow.QuickAction
|
||||
{
|
||||
namespace OwnChar.App.Desktop.Features.MainWindow.QuickAction;
|
||||
|
||||
internal class SettingsFeature() : PluginFunction(FeatureCodes.QuickAction, "ownchar.settings", "Settings"), IPluginFeatureProvider<SettingsFeature>
|
||||
{
|
||||
public static SettingsFeature Instance { get; } = new();
|
||||
@@ -16,4 +16,3 @@ namespace OwnChar.App.Desktop.Features.MainWindow.QuickAction
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
<PackageReference Include="Pilz.IO" Version="2.0.0" />
|
||||
<PackageReference Include="Pilz.Plugins" Version="2.1.9" />
|
||||
<PackageReference Include="Pilz.Plugins.Advanced" Version="2.7.3" />
|
||||
<PackageReference Include="Pilz.Plugins.Advanced.UI" Version="1.5.0" />
|
||||
<PackageReference Include="Pilz.Plugins.Advanced.UI.Telerik" Version="1.4.0" />
|
||||
<PackageReference Include="Pilz.Plugins.Advanced.UI" Version="1.5.1" />
|
||||
<PackageReference Include="Pilz.Plugins.Advanced.UI.Telerik" Version="1.4.1" />
|
||||
<PackageReference Include="UI.for.WinForms.AllControls.Net70" Version="2024.1.312" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using OwnChar.App.Desktop.UI.Windows;
|
||||
using OwnChar.App.Desktop.UI.Windows;
|
||||
using OwnChar.Plugins;
|
||||
using Pilz.Configuration;
|
||||
using System;
|
||||
@@ -9,8 +8,8 @@ using System.Windows.Forms;
|
||||
using Telerik.WinControls;
|
||||
using Telerik.WinControls.Themes;
|
||||
|
||||
namespace OwnChar.App.Desktop
|
||||
{
|
||||
namespace OwnChar.App.Desktop;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
public static ISettingsManager? SettingsManager { get; private set; }
|
||||
@@ -43,8 +42,7 @@ namespace OwnChar.App.Desktop
|
||||
|
||||
// Start main window
|
||||
var mainWindow = new MainWindow();
|
||||
AppApi.Instance.MainWindow = mainWindow.Api;
|
||||
AppApi.Instance.MainWindow = mainWindow;
|
||||
Application.Run(mainWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,12 @@
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using OwnChar.App.Desktop.LangRes;
|
||||
using OwnChar.App.Desktop.UI.Windows;
|
||||
using OwnChar.Model;
|
||||
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;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs.Controls
|
||||
{
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs.Controls;
|
||||
|
||||
public partial class CharacterListControl : UserControl
|
||||
{
|
||||
|
||||
@@ -93,4 +85,3 @@ namespace OwnChar.App.Desktop.UI.MainTabs.Controls
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
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;
|
||||
using Telerik.WinControls.UI;
|
||||
using Telerik.WinControls.UI.Diagrams.Primitives;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs.Controls;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs.Controls
|
||||
{
|
||||
public partial class GroupListControl : UserControl
|
||||
{
|
||||
public GroupListControl()
|
||||
@@ -23,4 +13,3 @@ namespace OwnChar.App.Desktop.UI.MainTabs.Controls
|
||||
// Hinzufügen
|
||||
// Löschen + Umbenennen (Wenn Admin/Mod)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
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;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs.Controls;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs.Controls
|
||||
{
|
||||
public partial class MemberListControl : UserControl
|
||||
{
|
||||
public MemberListControl()
|
||||
@@ -20,4 +12,3 @@ namespace OwnChar.App.Desktop.UI.MainTabs.Controls
|
||||
// Auflisten von Nutzern
|
||||
// -> z.B. Freunden oder Mitgliedern einer Gruppe
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using OwnChar.App.Desktop.UI.MainTabs.Controls;
|
||||
using OwnChar.Model;
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
using Pilz.UI;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs
|
||||
{
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs;
|
||||
|
||||
public partial class TabCharView : UserControl, ILoadContent
|
||||
{
|
||||
private readonly IMainWindowApi mainApi;
|
||||
@@ -23,4 +22,3 @@ namespace OwnChar.App.Desktop.UI.MainTabs
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using OwnChar.Model;
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
using Pilz.UI;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs
|
||||
{
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs;
|
||||
|
||||
public partial class TabGroupView : UserControl, ILoadContent
|
||||
{
|
||||
private readonly IMainWindowApi mainApi;
|
||||
@@ -22,4 +22,3 @@ namespace OwnChar.App.Desktop.UI.MainTabs
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using OwnChar.App.Desktop.LangRes;
|
||||
using OwnChar.Data;
|
||||
using Pilz.Cryptography;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
using Pilz.UI;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
using Pilz.UI;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs
|
||||
{
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs;
|
||||
|
||||
public partial class TabSettingsView : UserControl, ILoadContent
|
||||
{
|
||||
public TabSettingsView()
|
||||
@@ -15,4 +15,3 @@ namespace OwnChar.App.Desktop.UI.MainTabs
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using OwnChar.Model;
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
using Pilz.UI;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs
|
||||
{
|
||||
namespace OwnChar.App.Desktop.UI.MainTabs;
|
||||
|
||||
public partial class TabUserView : UserControl, ILoadContent
|
||||
{
|
||||
private readonly IMainWindowApi mainApi;
|
||||
@@ -32,4 +32,3 @@ namespace OwnChar.App.Desktop.UI.MainTabs
|
||||
characterListControl1.LoadContent(mainApi, profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,33 +30,23 @@ namespace OwnChar.App.Desktop.UI.Windows
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
radTabbedFormControl1 = new RadTabbedFormControl();
|
||||
radTabbedFormControl2 = new RadTabbedFormControl();
|
||||
((System.ComponentModel.ISupportInitialize)radTabbedFormControl1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTabbedFormControl2).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)this).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// radTabbedFormControl1
|
||||
//
|
||||
radTabbedFormControl1.Location = new System.Drawing.Point(0, 0);
|
||||
radTabbedFormControl1.Name = "radTabbedFormControl1";
|
||||
radTabbedFormControl1.ShowNewTabButton = false;
|
||||
radTabbedFormControl1.Size = new System.Drawing.Size(768, 583);
|
||||
radTabbedFormControl1.TabIndex = 0;
|
||||
radTabbedFormControl1.TabWidth = 200;
|
||||
radTabbedFormControl1.Text = "MainForm";
|
||||
((RadTabbedFormControlElement)radTabbedFormControl1.GetChildAt(0)).Text = "MainForm";
|
||||
((RadQuickAccessOverflowButton)radTabbedFormControl1.GetChildAt(0).GetChildAt(3).GetChildAt(1)).Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
|
||||
((RadQuickAccessOverflowButton)radTabbedFormControl1.GetChildAt(0).GetChildAt(4).GetChildAt(1)).Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
|
||||
//
|
||||
// radTabbedFormControl2
|
||||
//
|
||||
radTabbedFormControl2.Location = new System.Drawing.Point(0, 0);
|
||||
radTabbedFormControl2.Name = "radTabbedFormControl2";
|
||||
radTabbedFormControl2.Size = new System.Drawing.Size(780, 589);
|
||||
radTabbedFormControl2.TabIndex = 1;
|
||||
radTabbedFormControl2.Text = "RadForm1";
|
||||
radTabbedFormControl2.Name = "radTabbedFormControl1";
|
||||
radTabbedFormControl2.ShowNewTabButton = false;
|
||||
radTabbedFormControl2.Size = new System.Drawing.Size(768, 583);
|
||||
radTabbedFormControl2.TabIndex = 0;
|
||||
radTabbedFormControl2.TabWidth = 200;
|
||||
radTabbedFormControl2.Text = "MainForm";
|
||||
((RadTabbedFormControlElement)radTabbedFormControl2.GetChildAt(0)).Text = "MainForm";
|
||||
((RadQuickAccessOverflowButton)radTabbedFormControl2.GetChildAt(0).GetChildAt(3).GetChildAt(1)).Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
|
||||
((RadQuickAccessOverflowButton)radTabbedFormControl2.GetChildAt(0).GetChildAt(4).GetChildAt(1)).Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
|
||||
//
|
||||
// MainWindow
|
||||
//
|
||||
@@ -68,7 +58,6 @@ namespace OwnChar.App.Desktop.UI.Windows
|
||||
ShowIcon = false;
|
||||
Text = "RadForm1";
|
||||
Load += MainWindow_Load;
|
||||
((System.ComponentModel.ISupportInitialize)radTabbedFormControl1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radTabbedFormControl2).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)this).EndInit();
|
||||
ResumeLayout(false);
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
using OwnChar.App.Desktop.Api.Parameters;
|
||||
using OwnChar.App.Desktop.LangRes;
|
||||
using OwnChar.App.Desktop.UI.MainTabs;
|
||||
using OwnChar.Data;
|
||||
using OwnChar.Data.Managers;
|
||||
using OwnChar.Data.Providers.JsonFile;
|
||||
using OwnChar.Manager;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Pilz.Plugins.Advanced.UI.Telerik;
|
||||
@@ -13,55 +10,25 @@ using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.Windows
|
||||
{
|
||||
public partial class MainWindow : RadTabbedForm
|
||||
{
|
||||
private readonly OwnCharManager manager = new();
|
||||
namespace OwnChar.App.Desktop.UI.Windows;
|
||||
|
||||
public MainWindowApi Api { get; }
|
||||
public partial class MainWindow : RadTabbedForm, IMainWindowApi
|
||||
{
|
||||
Form IMainWindowApi.Window => this;
|
||||
public OwnCharManager Manager { get; } = new();
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
Api = new(this);
|
||||
InitializeComponent();
|
||||
PluginFeatureController.Instance.Features.Get(FeatureCodes.QuickAction).InsertItemsTo(radTabbedFormControl1.RightItems, customClickHandler: RightItem_Clicked);
|
||||
}
|
||||
|
||||
public class MainWindowApi(MainWindow mainWindow) : IMainWindowApi
|
||||
{
|
||||
public MainWindow MainWindow { get; } = mainWindow;
|
||||
|
||||
public Form Window => MainWindow;
|
||||
public OwnCharManager Manager => MainWindow.manager;
|
||||
|
||||
public void OpenTab(Control content, string title)
|
||||
{
|
||||
MainWindow.OpenTab(content, title);
|
||||
}
|
||||
|
||||
public void CloseTab(Control content)
|
||||
{
|
||||
MainWindow.CloseTab(content);
|
||||
}
|
||||
|
||||
public bool IsTabOpen(Control content)
|
||||
{
|
||||
return MainWindow.FindTab(content) != null;
|
||||
}
|
||||
|
||||
public bool IsTabOpen<T>()
|
||||
{
|
||||
return MainWindow.FindTab<T>() != null;
|
||||
}
|
||||
}
|
||||
|
||||
private MainWindowParams GetMainWindowParams()
|
||||
{
|
||||
return new MainWindowParams(Api);
|
||||
return new MainWindowParams(this);
|
||||
}
|
||||
|
||||
private void OpenTab(Control content, string title)
|
||||
public void OpenTab(Control content, string title)
|
||||
{
|
||||
var newTab = new RadTabbedFormControlTab();
|
||||
content.Dock = DockStyle.Fill;
|
||||
@@ -73,12 +40,22 @@ namespace OwnChar.App.Desktop.UI.Windows
|
||||
radTabbedFormControl1.SelectedTab = newTab;
|
||||
}
|
||||
|
||||
private void CloseTab(Control content)
|
||||
public void CloseTab(Control content)
|
||||
{
|
||||
if (FindTab(content) is RadTabbedFormControlTab tab)
|
||||
radTabbedFormControl1.Tabs.Remove(tab);
|
||||
}
|
||||
|
||||
public bool IsTabOpen(Control content)
|
||||
{
|
||||
return FindTab(content) != null;
|
||||
}
|
||||
|
||||
public bool IsTabOpen<T>()
|
||||
{
|
||||
return FindTab<T>() != null;
|
||||
}
|
||||
|
||||
private RadTabbedFormControlTab? FindTab(Control content)
|
||||
{
|
||||
return radTabbedFormControl1.Tabs.FirstOrDefault(n => n.Tag == content);
|
||||
@@ -97,7 +74,6 @@ namespace OwnChar.App.Desktop.UI.Windows
|
||||
|
||||
private void MainWindow_Load(object sender, EventArgs e)
|
||||
{
|
||||
Api.OpenTab(new TabLoginView(Api), LoginPageLangRes.Title);
|
||||
}
|
||||
OpenTab(new TabLoginView(this), LoginPageLangRes.Title);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user