finally more structure
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
namespace OwnChar.App.Desktop.UI.Windows
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace OwnChar.App.Desktop.UI.Windows
|
||||
{
|
||||
partial class MainWindow
|
||||
{
|
||||
@@ -28,13 +30,28 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
radTabbedFormControl1 = new Telerik.WinControls.UI.RadTabbedFormControl();
|
||||
radMenu1 = new Telerik.WinControls.UI.RadMenu();
|
||||
radMenuItem1 = new Telerik.WinControls.UI.RadMenuItem();
|
||||
radMenuItem2 = new Telerik.WinControls.UI.RadMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.radTabbedFormControl1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radMenu1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)this).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// radTabbedFormControl1
|
||||
//
|
||||
this.radTabbedFormControl1.Location = new System.Drawing.Point(0, 0);
|
||||
this.radTabbedFormControl1.Name = "radTabbedFormControl1";
|
||||
this.radTabbedFormControl1.ShowNewTabButton = false;
|
||||
this.radTabbedFormControl1.Size = new System.Drawing.Size(768, 583);
|
||||
this.radTabbedFormControl1.TabIndex = 0;
|
||||
this.radTabbedFormControl1.TabWidth = 200;
|
||||
this.radTabbedFormControl1.Text = "MainForm";
|
||||
((Telerik.WinControls.UI.RadTabbedFormControlElement)(radTabbedFormControl1.GetChildAt(0))).Text = "MainForm";
|
||||
((Telerik.WinControls.UI.RadQuickAccessOverflowButton)(radTabbedFormControl1.GetChildAt(0).GetChildAt(3).GetChildAt(1))).Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
|
||||
((Telerik.WinControls.UI.RadQuickAccessOverflowButton)(radTabbedFormControl1.GetChildAt(0).GetChildAt(4).GetChildAt(1))).Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
|
||||
//
|
||||
// radMenu1
|
||||
//
|
||||
radMenu1.Items.AddRange(new Telerik.WinControls.RadItem[] { radMenuItem1, radMenuItem2 });
|
||||
@@ -63,6 +80,7 @@
|
||||
Name = "MainWindow";
|
||||
Text = "RadForm1";
|
||||
((System.ComponentModel.ISupportInitialize)radMenu1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.radTabbedFormControl1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)this).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
@@ -70,6 +88,7 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private Telerik.WinControls.UI.RadTabbedFormControl radTabbedFormControl1;
|
||||
private Telerik.WinControls.UI.RadMenu radMenu1;
|
||||
private Telerik.WinControls.UI.RadMenuItem radMenuItem1;
|
||||
private Telerik.WinControls.UI.RadMenuItem radMenuItem2;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using OwnChar.App.Desktop.Api;
|
||||
using OwnChar.App.Desktop.Api.Parameters;
|
||||
using OwnChar.Manager;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Pilz.Plugins.Advanced.UI.Telerik;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
@@ -9,34 +12,81 @@ namespace OwnChar.App.Desktop.UI.Windows
|
||||
{
|
||||
public partial class MainWindow : RadTabbedForm
|
||||
{
|
||||
private readonly OwnCharManager? manager = new();
|
||||
|
||||
public MainWindowApi Api { get; }
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
Api = new(this);
|
||||
InitializeComponent();
|
||||
PluginFeatureController.Instance.Features.Get(FeatureCodes.MainTab).InsertItemsTo(radMenuItem2.Items, customClickHandler: MainTabItem_Clicked);
|
||||
PluginFeatureController.Instance.Features.Get(FeatureCodes.QuickAction).InsertItemsTo(radTabbedFormControl1.RightItems, customClickHandler: RightItem_Clicked);
|
||||
}
|
||||
|
||||
public class MainWindowApi(MainWindow mainWindow) : IMainWindowApi
|
||||
{
|
||||
public MainWindow MainWindow { get; } = mainWindow;
|
||||
|
||||
public void CloseTab(Control content)
|
||||
public OwnCharManager? Manager => MainWindow.manager;
|
||||
|
||||
public void OpenTab(Control content, string title)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
MainWindow.OpenTab(content, title);
|
||||
}
|
||||
|
||||
public void OpenTab(Control content)
|
||||
public void CloseTab(Control content)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
MainWindow.CloseTab(content);
|
||||
}
|
||||
|
||||
public bool IsTabOpen(Control content)
|
||||
{
|
||||
return MainWindow.FindTab(content) != null;
|
||||
}
|
||||
|
||||
public bool IsTabOpen<T>()
|
||||
{
|
||||
return MainWindow.FindTab<T>() != null;
|
||||
}
|
||||
}
|
||||
|
||||
private void MainTabItem_Clicked(object? sender, EventArgs e)
|
||||
private MainWindowParams GetMainWindowParams()
|
||||
{
|
||||
//if (sender is RadMenuItem item && item.Tag is PluginModule module)
|
||||
//...Add() ... module.CreateUI(), "Titel", null);
|
||||
return new MainWindowParams(Api);
|
||||
}
|
||||
|
||||
private void OpenTab(Control content, string title)
|
||||
{
|
||||
var newTab = new RadTabbedFormControlTab();
|
||||
content.Dock = DockStyle.Fill;
|
||||
newTab.Controls.Add(content);
|
||||
newTab.Text = title;
|
||||
newTab.Tag = content;
|
||||
content.Tag = newTab;
|
||||
radTabbedFormControl1.Tabs.Add(newTab);
|
||||
radTabbedFormControl1.SelectedTab = newTab;
|
||||
}
|
||||
|
||||
private void CloseTab(Control content)
|
||||
{
|
||||
if (FindTab(content) is RadTabbedFormControlTab tab)
|
||||
radTabbedFormControl1.Tabs.Remove(tab);
|
||||
}
|
||||
|
||||
private RadTabbedFormControlTab? FindTab(Control content)
|
||||
{
|
||||
return radTabbedFormControl1.Tabs.FirstOrDefault(n => n.Tag == content);
|
||||
}
|
||||
|
||||
private RadTabbedFormControlTab? FindTab<T>()
|
||||
{
|
||||
return radTabbedFormControl1.Tabs.FirstOrDefault(n => n.Tag is T);
|
||||
}
|
||||
|
||||
private void RightItem_Clicked(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is RadMenuItem item && item.Tag is PluginFunction function)
|
||||
function.Execute(GetMainWindowParams());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user