2
3 -
在AppSettings中添加VariableImportTemplate配置项,用于设置变量导入的默认参数(IsActive、PollingIn
terval、IsHistoryEnabled、HistoryDeadband)
4 - 修改AppSettings.Load()方法,优化配置加载逻辑
5 -
实现IVariableItemViewModelFactory和VariableItemViewModelFactory,使用工厂模式创建VariableItemVie
wModel实例
6 - 在ImportOpcUaDialogViewModel中使用工厂创建VariableItemViewModel实例,以应用默认配置
7 -
在SettingViewModel和SettingView中添加变量导入设置界面和相关属性(VariablePollingInterval、Variab
leIsActive、VariableIsHistoryEnabled、VariableHistoryDeadband)
8 - 移除VariableItemViewModel构造函数中的轮询间隔默认值设置,改由工厂模式设置
9 - 优化SplashViewModel中配置加载逻辑
10 - 移除MainView.xaml.cs中已注释的代码
11 - 调整VariableTableView.xaml的UI布局和菜单结构
12 - 注册IVariableItemViewModelFactory服务
这些修改主要实现了几个关键功能:
1. 引入了工厂模式来创建VariableItemViewModel实例,确保所有新创建的变量项都应用默认配置
2. 添加了变量导入模板设置,用户可以在设置界面自定义导入变量的默认属性
3. 对相关UI进行了调整和优化
80 lines
2.3 KiB
C#
80 lines
2.3 KiB
C#
using System.Windows;
|
|
using DMS.WPF.Services;
|
|
using DMS.WPF.ViewModels;
|
|
using iNKORE.UI.WPF.Modern.Controls;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using DMS.Core.Enums;
|
|
using DMS.Core.Models;
|
|
using DMS.WPF.Interfaces;
|
|
using DMS.WPF.ViewModels.Items;
|
|
|
|
namespace DMS.WPF.Views;
|
|
|
|
/// <summary>
|
|
/// MainView.xaml 的交互逻辑
|
|
/// </summary>
|
|
// using Hardcodet.NotifyIcon.Wpf;
|
|
|
|
public partial class MainView : Window
|
|
{
|
|
private MainViewModel _viewModel;
|
|
|
|
public MainView()
|
|
{
|
|
InitializeComponent();
|
|
_viewModel = App.Current.Services.GetRequiredService<MainViewModel>();
|
|
DataContext = _viewModel;
|
|
|
|
// Set the NotifyIcon's DataContext to the ViewModel
|
|
MyNotifyIcon.DataContext = _viewModel;
|
|
}
|
|
|
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
}
|
|
|
|
public void ShowApplication()
|
|
{
|
|
Show();
|
|
WindowState = WindowState.Normal;
|
|
Activate();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 左边菜单项被点击的事件,切换右边的视图
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="args"></param>
|
|
private async void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
|
|
{
|
|
var menu = args.SelectedItem as MenuItemViewModel;
|
|
if (menu != null)
|
|
{
|
|
|
|
NavigationType navigationType = NavigationType.None;
|
|
switch (menu.MenuType)
|
|
{
|
|
case MenuType.DeviceMenu:
|
|
navigationType=NavigationType.Device;
|
|
break;
|
|
case MenuType.VariableTableMenu:
|
|
navigationType=NavigationType.VariableTable;
|
|
break;
|
|
case MenuType.MqttMenu:
|
|
navigationType=NavigationType.Mqtt;
|
|
break;
|
|
|
|
}
|
|
|
|
var navigationService= App.Current.Services.GetRequiredService<INavigationService>();
|
|
navigationService.NavigateToAsync(this,new NavigationParameter(menu.TargetViewKey,menu.TargetId,navigationType));
|
|
}
|
|
|
|
}
|
|
|
|
private async void MainView_OnLoaded(object sender, RoutedEventArgs e)
|
|
{
|
|
_viewModel.OnLoaded();
|
|
}
|
|
} |