finish login & polish up

This commit is contained in:
2024-06-11 07:37:13 +02:00
parent b1b0cf132a
commit ffc4658d8e
10 changed files with 298 additions and 46 deletions

View File

@@ -1,49 +1,69 @@
using OwnChar.App.Desktop.Api;
using OwnChar.App.Desktop.Api.Parameters;
using OwnChar.App.Desktop.LangRes;
using OwnChar.App.Desktop.Settings;
using OwnChar.App.Desktop.UI.MainTabs;
using OwnChar.Manager;
using Pilz.Plugins.Advanced;
using Pilz.Plugins.Advanced.UI.Telerik;
using Pilz.UI;
using System;
using System.Linq;
using System.Windows.Forms;
using Telerik.WinControls.UI;
using Telerik.Windows.Diagrams.Core;
namespace OwnChar.App.Desktop.UI.Windows;
public partial class MainWindow : RadTabbedForm, IMainWindowApi
{
private readonly MainWindowSettings settings = AppApi.Instance.Settings.Get<MainWindowSettings>();
Form IMainWindowApi.Window => this;
public OwnCharManager Manager { get; } = new();
public MainWindow()
{
InitializeComponent();
PluginFeatureController.Instance.Features.Get(FeatureCodes.QuickAction).InsertItemsTo(radTabbedFormControl1.RightItems, customClickHandler: RightItem_Clicked);
if (!settings.AllowAero)
AllowAero = false;
PluginFeatureController.Instance.Features.Get(FeatureCodes.QuickAction)
.InsertItemsTo(radTabbedFormControl2.RightItems, customClickHandler: RightItem_Clicked)
.ForEach(item => item.DisplayStyle = Telerik.WinControls.DisplayStyle.Image);
}
private MainWindowParams GetMainWindowParams()
protected virtual MainWindowParams GetMainWindowParams()
{
return new MainWindowParams(this);
}
public void OpenTab(Control content, string title)
{
var newTab = new RadTabbedFormControlTab();
content.BackColor = System.Drawing.Color.Transparent;
content.Dock = DockStyle.Fill;
newTab.Controls.Add(content);
newTab.Text = title;
newTab.Tag = content;
var newTab = new RadTabbedFormControlTab
{
Text = title,
Tag = content
};
content.Tag = newTab;
radTabbedFormControl1.Tabs.Add(newTab);
radTabbedFormControl1.SelectedTab = newTab;
newTab.Controls.Add(content);
radTabbedFormControl2.Tabs.Add(newTab);
radTabbedFormControl2.SelectedTab = newTab;
if (content is ILoadContent loadContent)
loadContent.LoadContent();
}
public void CloseTab(Control content)
{
if (FindTab(content) is RadTabbedFormControlTab tab)
radTabbedFormControl1.Tabs.Remove(tab);
radTabbedFormControl2.Tabs.Remove(tab);
}
public bool IsTabOpen(Control content)
@@ -58,12 +78,12 @@ public partial class MainWindow : RadTabbedForm, IMainWindowApi
private RadTabbedFormControlTab? FindTab(Control content)
{
return radTabbedFormControl1.Tabs.FirstOrDefault(n => n.Tag == content);
return radTabbedFormControl2.Tabs.FirstOrDefault(n => n.Tag == content);
}
private RadTabbedFormControlTab? FindTab<T>()
{
return radTabbedFormControl1.Tabs.FirstOrDefault(n => n.Tag is T);
return radTabbedFormControl2.Tabs.FirstOrDefault(n => n.Tag is T);
}
private void RightItem_Clicked(object? sender, EventArgs e)