|
|
@@ -1,4 +1,5 @@
|
|
|
using System.Collections.Concurrent;
|
|
|
+using System.Collections.ObjectModel;
|
|
|
using System.Windows.Controls;
|
|
|
using System.Windows.Input;
|
|
|
using YSAI.Langs;
|
|
|
@@ -19,29 +20,198 @@ using YSAI.Tool.Core.svg;
|
|
|
|
|
|
namespace YSAI.Tool
|
|
|
{
|
|
|
- public class MainWindowController : NotifyObject
|
|
|
+ /// <summary>
|
|
|
+ /// 数据源
|
|
|
+ /// </summary>
|
|
|
+ public class Source : NotifyObject
|
|
|
{
|
|
|
/// <summary>
|
|
|
- /// 关于页面
|
|
|
+ /// 图标
|
|
|
+ /// </summary>
|
|
|
+ //public ImageSource Icon
|
|
|
+ //{
|
|
|
+ // get => GetProperty(() => Icon);
|
|
|
+ // set => SetProperty(() => Icon, value);
|
|
|
+ //}
|
|
|
+ /// <summary>
|
|
|
+ /// 标题
|
|
|
/// </summary>
|
|
|
- public ICommand AboutUsTool { get => new CommandX(() => { UserControl = UserControls["AboutUsTool"]; }); }
|
|
|
+ public string Title
|
|
|
+ {
|
|
|
+ get => GetProperty(() => Title);
|
|
|
+ set => SetProperty(() => Title, value);
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Can操作
|
|
|
+ /// 展示的地方
|
|
|
/// </summary>
|
|
|
- public ICommand CanTool { get => new CommandX(() => { UserControl = UserControls["CanTool"]; }); }
|
|
|
+ public object UserControl
|
|
|
+ {
|
|
|
+ get => GetProperty(() => UserControl);
|
|
|
+ set => SetProperty(() => UserControl, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- public ICommand MqttClientTool { get => new CommandX(() => { UserControl = UserControls["MqttClientTool"]; }); }
|
|
|
- public ICommand MqttServiceTool { get => new CommandX(() => { UserControl = UserControls["MqttServiceTool"]; }); }
|
|
|
- public ICommand MqttWebSocketServiceTool { get => new CommandX(() => { UserControl = UserControls["MqttWebSocketServiceTool"]; }); }
|
|
|
- public ICommand OpcDaHttpClientTool { get => new CommandX(() => { UserControl = UserControls["OpcDaHttpClientTool"]; }); }
|
|
|
- public ICommand OpcUaClientTool { get => new CommandX(() => { UserControl = UserControls["OpcUaClientTool"]; }); }
|
|
|
- public ICommand OpcUaServiceTool { get => new CommandX(() => { UserControl = UserControls["OpcUaServiceTool"]; }); }
|
|
|
- public ICommand SerialPortTool { get => new CommandX(() => { UserControl = UserControls["SerialPortTool"]; }); }
|
|
|
- public ICommand SocketTcpClientTool { get => new CommandX(() => { UserControl = UserControls["SocketTcpClientTool"]; }); }
|
|
|
- public ICommand SocketTcpServerTool { get => new CommandX(() => { UserControl = UserControls["SocketTcpServerTool"]; }); }
|
|
|
- public ICommand SocketUdpTool { get => new CommandX(() => { UserControl = UserControls["SocketUdpTool"]; }); }
|
|
|
- public ICommand SvgTool { get => new CommandX(() => { UserControl = UserControls["SvgTool"]; }); }
|
|
|
+ public class MainWindowController : NotifyObject
|
|
|
+ {
|
|
|
+ #region 控件
|
|
|
+ public ICommand AboutUsTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "AboutUsTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public ICommand CanTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "CanTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public ICommand MqttClientTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "MqttClientTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public ICommand MqttServiceTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "MqttServiceTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public ICommand MqttWebSocketServiceTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "MqttWebSocketServiceTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public ICommand OpcDaHttpClientTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "OpcDaHttpClientTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public ICommand OpcUaClientTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "OpcUaClientTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public ICommand OpcUaServiceTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "OpcUaServiceTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public ICommand SerialPortTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "SerialPortTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public ICommand SocketTcpClientTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "SocketTcpClientTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public ICommand SocketTcpServerTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "SocketTcpServerTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public ICommand SocketUdpTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "SocketUdpTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public ICommand SvgTool
|
|
|
+ {
|
|
|
+ get => new CommandX(() =>
|
|
|
+ {
|
|
|
+ string name = "SvgTool";
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = name,
|
|
|
+ UserControl = UserControls[name]
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ #endregion 控件
|
|
|
|
|
|
public MainWindowController()
|
|
|
{
|
|
|
@@ -62,28 +232,34 @@ namespace YSAI.Tool
|
|
|
UserControls.AddOrUpdate("SvgTool", new SvgTool(), (k, v) => new SvgTool());
|
|
|
UserControls.AddOrUpdate("AboutUsTool", new AboutUsTool(), (k, v) => new AboutUsTool());
|
|
|
|
|
|
- //显示用户控件
|
|
|
- UserControl = UserControls["AboutUsTool"];
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 展示的地方
|
|
|
- /// </summary>
|
|
|
- public object UserControl
|
|
|
- {
|
|
|
- get => GetProperty(() => UserControl);
|
|
|
- set
|
|
|
+ if (TabControlItemsSource == null)
|
|
|
{
|
|
|
- if (value != UserControl)
|
|
|
- {
|
|
|
- SetProperty(() => UserControl, value);
|
|
|
- }
|
|
|
+ TabControlItemsSource = new ObservableCollection<Source>();
|
|
|
}
|
|
|
+
|
|
|
+ TabControlItemsSource.Add(new Source
|
|
|
+ {
|
|
|
+ Title = "AboutUsTool",
|
|
|
+ UserControl = UserControls["AboutUsTool"]
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 控件集合
|
|
|
/// </summary>
|
|
|
private ConcurrentDictionary<string, UserControl> UserControls = new ConcurrentDictionary<string, UserControl>();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 选项卡控件项源
|
|
|
+ /// </summary>
|
|
|
+ public ObservableCollection<Source> TabControlItemsSource
|
|
|
+ {
|
|
|
+ get => GetProperty(() => TabControlItemsSource);
|
|
|
+ set => SetProperty(() => TabControlItemsSource, value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|