diff --git a/Services/DataServices.cs b/Services/DataServices.cs index c915555..223e52f 100644 --- a/Services/DataServices.cs +++ b/Services/DataServices.cs @@ -28,21 +28,19 @@ public partial class DataServices : ObservableRecipient, IRecipient partial void OnDevicesChanged(List devices) { OnDeviceListChanged?.Invoke(devices); - if (menuBeans!=null && Devices!=null) + if (menuBeans != null && Devices != null) { - FillMenuData(MenuBeans,Devices); + FillMenuData(MenuBeans, Devices); } - } partial void OnMenuBeansChanged(List menuBeans) { OnMenuListChanged?.Invoke(menuBeans); - if (MenuBeans!=null && Devices!=null) + if (MenuBeans != null && Devices != null) { - FillMenuData(MenuBeans,Devices); + FillMenuData(MenuBeans, Devices); } - } @@ -59,7 +57,7 @@ public partial class DataServices : ObservableRecipient, IRecipient /// 给Menu菜单的Data填充数据 /// /// - private void FillMenuData(List menuBeans,List devices) + private void FillMenuData(List menuBeans, List devices) { if (menuBeans == null || menuBeans.Count == 0) return; @@ -87,7 +85,7 @@ public partial class DataServices : ObservableRecipient, IRecipient if (menuBean.Items != null && menuBean.Items.Count > 0) { - FillMenuData(menuBean.Items,devices); + FillMenuData(menuBean.Items, devices); } } } @@ -114,20 +112,29 @@ public partial class DataServices : ObservableRecipient, IRecipient return navgateVM; } + /// + /// 从设备列表中找到变量表VarTable对象 + /// + /// VarTable的ID + /// 如果找到择返回对象,否则返回null private VariableTable FindVarTableForDevice(int vtableId) { VariableTable varTable = null; foreach (var device in _devices) { varTable = device.VariableTables.FirstOrDefault(v => v.Id == vtableId); - if (varTable!=null) + if (varTable != null) return varTable; } return varTable; } - + /// + /// 接受加载消息,收到消息后从数据库加载对应的数据 + /// + /// 消息的类型,如加载菜单LoadMessage.Menu + /// public async void Receive(LoadMessage message) { if (!(message.Value is LoadTypes)) diff --git a/ViewModels/VariableTableViewModel.cs b/ViewModels/VariableTableViewModel.cs index 34bc1d2..6a7b02d 100644 --- a/ViewModels/VariableTableViewModel.cs +++ b/ViewModels/VariableTableViewModel.cs @@ -1,3 +1,4 @@ +using System.Collections.ObjectModel; using CommunityToolkit.Mvvm.ComponentModel; using PMSWPF.Models; @@ -7,7 +8,14 @@ partial class VariableTableViewModel : ViewModelBase { [ObservableProperty] private VariableTable variableTable; + [ObservableProperty] + private ObservableCollection _dataVariables; + public override void OnLoaded() { + if (VariableTable.DataVariables!=null ) + { + _dataVariables = new ObservableCollection(VariableTable.DataVariables); + } } } \ No newline at end of file diff --git a/Views/Dialogs/DeviceDialog.xaml b/Views/Dialogs/DeviceDialog.xaml index 47a2cd5..435bb87 100644 --- a/Views/Dialogs/DeviceDialog.xaml +++ b/Views/Dialogs/DeviceDialog.xaml @@ -13,72 +13,89 @@ Title="{Binding Title}" CloseButtonText="取消" DefaultButton="Primary" - PrimaryButtonText="添加" - + PrimaryButtonText="添加设备" + Background="#fff" d:DataContext="{d:DesignInstance vmd:DeviceDialogViewModel}" mc:Ignorable="d"> + + - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Views/MainView.xaml.cs b/Views/MainView.xaml.cs index a8997d6..cb93754 100644 --- a/Views/MainView.xaml.cs +++ b/Views/MainView.xaml.cs @@ -68,34 +68,4 @@ public partial class MainView : Window _viewModel.OnLoaded(); } - // private void NavigationView_OnItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args) - // { - // ViewModelBase navgateVM = App.Current.Services.GetRequiredService(); - // - // switch (args.InvokedItem) - // { - // case "主页": - // // mainViewModel.NavgateTo(); - // navgateVM = App.Current.Services.GetRequiredService(); - // _logger.LogInformation("导航到到主页面"); - // break; - // case "设备": - // navgateVM = App.Current.Services.GetRequiredService(); - // // mainViewModel.NavgateTo(); - // _logger.LogInformation("导航到到设备页面"); - // break; - // case "数据转换": - // navgateVM = App.Current.Services.GetRequiredService(); - // // mainViewModel.NavgateTo(); - // _logger.LogInformation("导航到到数据转换页面"); - // break; - // case "设置": - // // mainViewModel.NavgateTo(); - // navgateVM = App.Current.Services.GetRequiredService(); - // _logger.LogInformation("导航到到设备页面"); - // break; - // } - // - // MessageHelper.SendNavgatorMessage(navgateVM); - // } } \ No newline at end of file diff --git a/Views/VariableTableView.xaml b/Views/VariableTableView.xaml index 5af6b50..48bc326 100644 --- a/Views/VariableTableView.xaml +++ b/Views/VariableTableView.xaml @@ -4,25 +4,75 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf" + xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern" xmlns:vm="clr-namespace:PMSWPF.ViewModels" + xmlns:controls="http://schemas.inkore.net/lib/ui/wpf/modern" mc:Ignorable="d" d:DataContext="{d:DesignInstance vm:VariableTableViewModel}" - d:DesignHeight="300" d:DesignWidth="300"> - + d:DesignHeight="600" d:DesignWidth="800"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + - - + \ No newline at end of file