diff --git a/App.xaml.cs b/App.xaml.cs
index a0bd539..f375578 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -1,5 +1,4 @@
using System.Windows;
-using System.Windows.Controls;
using iNKORE.UI.WPF.Modern.Common.IconKeys;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -7,7 +6,6 @@ using NLog;
using NLog.Extensions.Logging;
using PMSWPF.Data;
using PMSWPF.Data.Entities;
-using PMSWPF.Data.Repositories;
using PMSWPF.Enums;
using PMSWPF.Extensions;
using PMSWPF.Helper;
diff --git a/Data/Entities/DbVariableTable.cs b/Data/Entities/DbVariableTable.cs
index dfcdaea..d6d8a00 100644
--- a/Data/Entities/DbVariableTable.cs
+++ b/Data/Entities/DbVariableTable.cs
@@ -1,5 +1,4 @@
using PMSWPF.Enums;
-using PMSWPF.Models;
using SqlSugar;
using SqlSugar.DbConvert;
diff --git a/Data/Repositories/DeviceRepository.cs b/Data/Repositories/DeviceRepository.cs
index f6ff367..4444eef 100644
--- a/Data/Repositories/DeviceRepository.cs
+++ b/Data/Repositories/DeviceRepository.cs
@@ -1,7 +1,5 @@
using PMSWPF.Data.Entities;
-using PMSWPF.Excptions;
using PMSWPF.Extensions;
-using PMSWPF.Helper;
using PMSWPF.Models;
using SqlSugar;
@@ -9,49 +7,80 @@ namespace PMSWPF.Data.Repositories;
public class DeviceRepository
{
- private SqlSugarClient _db;
public DeviceRepository()
{
- _db = DbContext.GetInstance();
+
}
+ ///
+ /// 添加设备
+ ///
+ ///
+ ///
+ ///
public async Task Add(Device device)
{
- var exist = await _db.Queryable().Where(d => d.Name == device.Name).FirstAsync();
- if (exist != null)
- throw new InvalidOperationException("设备名称已经存在。");
- var dbDevice = new DbDevice();
- device.CopyTo(dbDevice);
- dbDevice.VariableTables = new List();
- // 添加默认变量表
- var dbVariableTable = new DbVariableTable();
- dbVariableTable.Name = "默认变量表";
- dbVariableTable.Description = "默认变量表";
- dbVariableTable.ProtocolType = dbDevice.ProtocolType;
- dbDevice.VariableTables.Add(dbVariableTable);
- var addDbDevice= await _db.InsertNav(dbDevice).Include(d => d.VariableTables).ExecuteReturnEntityAsync();
- return addDbDevice.CopyTo();
+ using (var db=DbContext.GetInstance())
+ {
+ var exist = await db.Queryable().Where(d => d.Name == device.Name).FirstAsync();
+ if (exist != null)
+ throw new InvalidOperationException("设备名称已经存在。");
+ var dbDevice = new DbDevice();
+ device.CopyTo(dbDevice);
+ dbDevice.VariableTables = new List();
+ // 添加默认变量表
+ var dbVariableTable = new DbVariableTable();
+ dbVariableTable.Name = "默认变量表";
+ dbVariableTable.Description = "默认变量表";
+ dbVariableTable.ProtocolType = dbDevice.ProtocolType;
+ dbDevice.VariableTables.Add(dbVariableTable);
+ var addDbDevice= await db.InsertNav(dbDevice).Include(d => d.VariableTables).ExecuteReturnEntityAsync();
+ return addDbDevice.CopyTo();
+ }
+
}
+ public async Task Edit(Device device)
+ {
+ using (var db=DbContext.GetInstance())
+ {
+ return await db.Updateable(device.CopyTo()).ExecuteCommandAsync();
+ }
+
+ }
+
+
public async Task> GetAll()
{
- var dlist = await _db.Queryable().Includes(d => d.VariableTables,dv=>dv.Device).ToListAsync();
- var devices = new List();
- foreach (var dbDevice in dlist)
+ using (var db = DbContext.GetInstance())
{
- var device = dbDevice.CopyTo();
- devices.Add(device);
- }
+ var dlist = await db.Queryable().Includes(d => d.VariableTables,dv=>dv.Device).ToListAsync();
+ var devices = new List();
+ foreach (var dbDevice in dlist)
+ {
+ var device = dbDevice.CopyTo();
+ devices.Add(device);
+ }
- return devices;
+ return devices;
+ }
+
}
public async Task GetById(int id)
{
- return await _db.Queryable().FirstAsync(p => p.Id == id);
+ using (var db=DbContext.GetInstance())
+ {
+ return await db.Queryable().FirstAsync(p => p.Id == id);
+ }
+
}
public async Task DeleteById(int id)
{
- return await _db.Deleteable(new DbDevice { Id = id }).ExecuteCommandAsync();
+ using (var db = DbContext.GetInstance())
+ {
+ return await db.Deleteable(new DbDevice { Id = id }).ExecuteCommandAsync();
+ }
+
}
}
\ No newline at end of file
diff --git a/Data/Repositories/MenuRepository.cs b/Data/Repositories/MenuRepository.cs
index 32081c3..5e28994 100644
--- a/Data/Repositories/MenuRepository.cs
+++ b/Data/Repositories/MenuRepository.cs
@@ -1,13 +1,8 @@
-using System.Windows.Controls;
-using CommunityToolkit.Mvvm.Messaging;
using iNKORE.UI.WPF.Modern.Common.IconKeys;
using PMSWPF.Data.Entities;
using PMSWPF.Enums;
using PMSWPF.Extensions;
-using PMSWPF.Helper;
-using PMSWPF.Message;
using PMSWPF.Models;
-using SqlSugar;
namespace PMSWPF.Data.Repositories;
@@ -17,7 +12,16 @@ public class MenuRepository
{
}
- public async Task> GetMenu()
+ public async Task DeleteMenu(MenuBean menu)
+ {
+ using (var db = DbContext.GetInstance())
+ {
+ var childList = await db.Queryable().ToChildListAsync(it => it.ParentId, menu.Id);
+ return await db.Deleteable(childList).ExecuteCommandAsync();
+ }
+ }
+
+ public async Task> GetMenuTrees()
{
// //无主键用法新:5.1.4.110
// db.Queryable().ToTree(it=>it.Child,it=>it.ParentId,0,it=>it.Id)//+4重载
@@ -27,10 +31,9 @@ public class MenuRepository
{
List menuTree = new();
var dbMenuTree = await db.Queryable().ToTreeAsync(dm => dm.Items, dm => dm.ParentId, 0);
+
foreach (var dbMenu in dbMenuTree)
- {
menuTree.Add(dbMenu.CopyTo());
- }
return menuTree;
}
@@ -102,4 +105,12 @@ public class MenuRepository
return true;
}
}
+
+ public async Task Edit(MenuBean menu)
+ {
+ using (var db = DbContext.GetInstance())
+ {
+ return await db.Updateable(menu.CopyTo()).ExecuteCommandAsync();
+ }
+ }
}
\ No newline at end of file
diff --git a/Helper/DataServicesHelper.cs b/Helper/DataServicesHelper.cs
new file mode 100644
index 0000000..6581b42
--- /dev/null
+++ b/Helper/DataServicesHelper.cs
@@ -0,0 +1,48 @@
+using Microsoft.Extensions.DependencyInjection;
+using PMSWPF.Enums;
+using PMSWPF.Models;
+using PMSWPF.ViewModels;
+
+namespace PMSWPF.Helper;
+
+public class DataServicesHelper
+{
+ public static MenuBean FindMenusForDevice(Device device,List menus)
+ {
+ foreach (var mainMenu in menus)
+ {
+ if (mainMenu.Items == null || mainMenu.Items.Count == 0)
+ continue;
+ foreach (var secondMenu in mainMenu.Items)
+ {
+ if (secondMenu.Type == MenuType.DeviceMenu && secondMenu.Data != null && secondMenu.Data == device)
+ {
+ return secondMenu;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static ViewModelBase GetMainViewModel(string name)
+ {
+ ViewModelBase navgateVM = App.Current.Services.GetRequiredService();
+ switch (name)
+ {
+ case "主页":
+ navgateVM = App.Current.Services.GetRequiredService();
+ break;
+ case "设备":
+ navgateVM = App.Current.Services.GetRequiredService();
+ break;
+ case "数据转换":
+ navgateVM = App.Current.Services.GetRequiredService();
+ break;
+ case "设置":
+ navgateVM = App.Current.Services.GetRequiredService();
+ break;
+ }
+
+ return navgateVM;
+ }
+}
\ No newline at end of file
diff --git a/Models/MenuBean.cs b/Models/MenuBean.cs
index ca14ae6..1c6b43a 100644
--- a/Models/MenuBean.cs
+++ b/Models/MenuBean.cs
@@ -1,3 +1,4 @@
+using CommunityToolkit.Mvvm.ComponentModel;
using PMSWPF.Enums;
using PMSWPF.ViewModels;
@@ -8,6 +9,7 @@ public class MenuBean
public int Id { get; set; }
public string Icon { get; set; }
+
public string Name { get; set; }
public int ParentId { get; set; }
public int DataId { get; set; }
diff --git a/Services/DataServices.cs b/Services/DataServices.cs
index 223e52f..bf9f4cd 100644
--- a/Services/DataServices.cs
+++ b/Services/DataServices.cs
@@ -4,11 +4,11 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using PMSWPF.Data.Repositories;
using PMSWPF.Enums;
-using PMSWPF.Extensions;
using PMSWPF.Helper;
using PMSWPF.Message;
using PMSWPF.Models;
using PMSWPF.ViewModels;
+using SqlSugar;
namespace PMSWPF.Services;
@@ -17,29 +17,29 @@ public partial class DataServices : ObservableRecipient, IRecipient
private readonly ILogger _logger;
[ObservableProperty] private List _devices;
[ObservableProperty] private List _variableTables;
- [ObservableProperty] private List menuBeans;
+ [ObservableProperty] private List menuTrees;
private readonly DeviceRepository _deviceRepository;
private readonly MenuRepository _menuRepository;
public event Action> OnDeviceListChanged;
- public event Action> OnMenuListChanged;
+ public event Action> OnMenuTreeListChanged;
partial void OnDevicesChanged(List devices)
{
OnDeviceListChanged?.Invoke(devices);
- if (menuBeans != null && Devices != null)
+ if (menuTrees != null && Devices != null)
{
- FillMenuData(MenuBeans, Devices);
+ FillMenuData(MenuTrees, Devices);
}
}
- partial void OnMenuBeansChanged(List menuBeans)
+ partial void OnMenuTreesChanged(List MenuTrees)
{
- OnMenuListChanged?.Invoke(menuBeans);
- if (MenuBeans != null && Devices != null)
+ OnMenuTreeListChanged?.Invoke(MenuTrees);
+ if (MenuTrees != null && Devices != null)
{
- FillMenuData(MenuBeans, Devices);
+ FillMenuData(MenuTrees, Devices);
}
}
@@ -56,18 +56,18 @@ public partial class DataServices : ObservableRecipient, IRecipient
///
/// 给Menu菜单的Data填充数据
///
- ///
- private void FillMenuData(List menuBeans, List devices)
+ ///
+ private void FillMenuData(List MenuTrees, List devices)
{
- if (menuBeans == null || menuBeans.Count == 0)
+ if (MenuTrees == null || MenuTrees.Count == 0)
return;
- foreach (MenuBean menuBean in menuBeans)
+ foreach (MenuBean menuBean in MenuTrees)
{
switch (menuBean.Type)
{
case MenuType.MainMenu:
- menuBean.ViewModel = GetMainViewModel(menuBean.Name);
+ menuBean.ViewModel =DataServicesHelper.GetMainViewModel(menuBean.Name);
break;
case MenuType.DeviceMenu:
menuBean.ViewModel = App.Current.Services.GetRequiredService();
@@ -90,26 +90,20 @@ public partial class DataServices : ObservableRecipient, IRecipient
}
}
- private ViewModelBase GetMainViewModel(string name)
- {
- ViewModelBase navgateVM = App.Current.Services.GetRequiredService();
- switch (name)
- {
- case "主页":
- navgateVM = App.Current.Services.GetRequiredService();
- break;
- case "设备":
- navgateVM = App.Current.Services.GetRequiredService();
- break;
- case "数据转换":
- navgateVM = App.Current.Services.GetRequiredService();
- break;
- case "设置":
- navgateVM = App.Current.Services.GetRequiredService();
- break;
- }
+
- return navgateVM;
+ ///
+ /// 查找设备所对应的菜单对象
+ ///
+ ///
+ ///
+ public async Task UpdateMenuForDevice(Device device)
+ {
+ var menu= DataServicesHelper.FindMenusForDevice(device, MenuTrees);
+ if (menu != null)
+ return await _menuRepository.Edit(menu);
+
+ return 0;
}
///
@@ -164,10 +158,22 @@ public partial class DataServices : ObservableRecipient, IRecipient
private async Task LoadMenus()
{
- MenuBeans = await _menuRepository.GetMenu();
- foreach (MenuBean menu in MenuBeans)
+ MenuTrees = await _menuRepository.GetMenuTrees();
+ foreach (MenuBean menu in MenuTrees)
{
MenuHelper.MenuAddParent(menu);
}
}
+
+ public async Task DeleteMenuForDevice(Device device)
+ {
+ var menu= DataServicesHelper.FindMenusForDevice(device, MenuTrees);
+ if (menu != null)
+ {
+ return await _menuRepository.DeleteMenu(menu);
+ }
+
+ return 0;
+
+ }
}
\ No newline at end of file
diff --git a/Services/DialogService.cs b/Services/DialogService.cs
index 48b11f4..5333139 100644
--- a/Services/DialogService.cs
+++ b/Services/DialogService.cs
@@ -1,8 +1,4 @@
-using CommunityToolkit.Mvvm.ComponentModel;
-using CommunityToolkit.Mvvm.Messaging;
-using HandyControl.Tools.Extension;
-using iNKORE.UI.WPF.Modern.Controls;
-using PMSWPF.Message;
+using iNKORE.UI.WPF.Modern.Controls;
using PMSWPF.Models;
using PMSWPF.ViewModels.Dialogs;
using PMSWPF.Views.Dialogs;
@@ -19,7 +15,15 @@ public class DialogService :IDialogService
public async Task ShowAddDeviceDialog()
{
var device = new Device();
- var dialog = new DeviceDialog(device);
+ DeviceDialogViewModel vm = new DeviceDialogViewModel(device);
+ vm.Title = "添加设备";
+ vm.PrimaryButContent = "添加设备";
+ return await ShowConentDialog(vm,device);
+ }
+
+ private static async Task ShowConentDialog(DeviceDialogViewModel viewModel,Device device)
+ {
+ var dialog = new DeviceDialog(viewModel);
var res = await dialog.ShowAsync();
if (res == ContentDialogResult.Primary)
{
@@ -28,6 +32,31 @@ public class DialogService :IDialogService
return null;
}
+ public async Task ShowEditDeviceDialog(Device device)
+ {
+ DeviceDialogViewModel vm = new DeviceDialogViewModel(device);
+ vm.Title = "编辑设备";
+ vm.PrimaryButContent = "编辑设备";
+ return await ShowConentDialog(vm,device);
+
+ }
+
+ public async Task ShowConfrimeDialog(string title, string message,string buttonText="确认")
+ {
+ ConfrimDialogViewModel vm = new ConfrimDialogViewModel();
+ vm.Title = title;
+ vm.Message = message;
+ vm.PrimaryButtonText = buttonText;
+ var dialog = new ConfirmDialog(vm);
+ var res = await dialog.ShowAsync();
+ if (res == ContentDialogResult.Primary)
+ {
+ return true;
+ }
+ return false;
+ }
+
+
public void ShowMessageDialog(string title, string message)
{
MessageBox.Show(message);
diff --git a/Services/IDialogService.cs b/Services/IDialogService.cs
index db8cec0..46e9cb0 100644
--- a/Services/IDialogService.cs
+++ b/Services/IDialogService.cs
@@ -5,6 +5,9 @@ namespace PMSWPF.Services;
public interface IDialogService
{
Task ShowAddDeviceDialog();
+ Task ShowEditDeviceDialog(Device device);
+
+ Task ShowConfrimeDialog(string title, string message,string buttonText="确认");
void ShowMessageDialog(string title, string message);
}
\ No newline at end of file
diff --git a/ViewModels/DevicesViewModel.cs b/ViewModels/DevicesViewModel.cs
index 3e45f9c..84c759c 100644
--- a/ViewModels/DevicesViewModel.cs
+++ b/ViewModels/DevicesViewModel.cs
@@ -1,14 +1,10 @@
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
-using CommunityToolkit.Mvvm.Messaging;
-using iNKORE.UI.WPF.Modern.Common.IconKeys;
using Microsoft.Extensions.Logging;
using PMSWPF.Data.Repositories;
using PMSWPF.Enums;
-using PMSWPF.Excptions;
using PMSWPF.Helper;
-using PMSWPF.Message;
using PMSWPF.Models;
using PMSWPF.Services;
@@ -21,7 +17,9 @@ public partial class DevicesViewModel : ViewModelBase
private readonly IDialogService _dialogService;
private readonly DataServices _dataServices;
+
[ObservableProperty] private ObservableCollection _devices;
+ [ObservableProperty] private Device _selectedDevice;
private readonly MenuRepository _menuRepository;
public DevicesViewModel(
@@ -33,15 +31,14 @@ public partial class DevicesViewModel : ViewModelBase
_logger = logger;
_dialogService = dialogService;
_dataServices = dataServices;
-
+
MessageHelper.SendLoadMessage(LoadTypes.Devices);
_dataServices.OnDeviceListChanged += (devices) => { Devices = new ObservableCollection(devices); };
}
- public async Task OnLoadedAsync()
- {
- }
-
+ ///
+ /// 添加设备
+ ///
[RelayCommand]
public async void AddDevice()
{
@@ -51,12 +48,12 @@ public partial class DevicesViewModel : ViewModelBase
device = await _dialogService.ShowAddDeviceDialog();
if (device != null)
{
- device= await _deviceRepository.Add(device);
- if (device!=null)
+ device = await _deviceRepository.Add(device);
+ if (device != null)
{
var msg = $"添加设备成功:{device.Name}";
_logger.LogInformation(msg);
-
+
bool addMenuRes = await _menuRepository.AddDeviceMenu(device);
if (addMenuRes)
{
@@ -88,6 +85,67 @@ public partial class DevicesViewModel : ViewModelBase
}
}
+
+ ///
+ /// 编辑设备
+ ///
+ [RelayCommand]
+ public async void EditDevice()
+ {
+ try
+ {
+ if (SelectedDevice == null)
+ {
+ NotificationHelper.ShowMessage("你没有选择任何设备,请选择设备后再点击编辑设备", NotificationType.Error);
+ return;
+ }
+
+ var editDievce = await _dialogService.ShowEditDeviceDialog(SelectedDevice);
+ if (editDievce != null)
+ {
+ var res = await _deviceRepository.Edit(editDievce);
+ await _dataServices.UpdateMenuForDevice(editDievce);
+
+ MessageHelper.SendLoadMessage(LoadTypes.Menu);
+ MessageHelper.SendLoadMessage(LoadTypes.Devices);
+ }
+ }
+ catch (Exception e)
+ {
+ NotificationHelper.ShowMessage($"编辑设备的过程中发生错误:{e.Message}", NotificationType.Error);
+ _logger.LogError($"编辑设备的过程中发生错误:{e}");
+ }
+ }
+
+ [RelayCommand]
+ public async void DeleteDevice()
+ {
+ try
+ {
+ if (SelectedDevice == null)
+ {
+ NotificationHelper.ShowMessage("你没有选择任何设备,请选择设备后再点击删除设备", NotificationType.Error);
+ return;
+ }
+
+ string msg = $"确认要删除设备名为:{SelectedDevice.Name}";
+ var isDel = await _dialogService.ShowConfrimeDialog("删除设备", msg, "删除设备");
+ if (isDel)
+ {
+ var defDeviceRes = await _deviceRepository.DeleteById(SelectedDevice.Id);
+ var defMenuRes = await _dataServices.DeleteMenuForDevice(SelectedDevice);
+ MessageHelper.SendLoadMessage(LoadTypes.Menu);
+ MessageHelper.SendLoadMessage(LoadTypes.Devices);
+ NotificationHelper.ShowMessage($"删除设备成功,设备名:{SelectedDevice.Name}", NotificationType.Success);
+ }
+ }
+ catch (Exception e)
+ {
+ NotificationHelper.ShowMessage($"编辑设备的过程中发生错误:{e.Message}", NotificationType.Error);
+ _logger.LogError($"编辑设备的过程中发生错误:{e}");
+ }
+ }
+
[RelayCommand]
public void NavigateVt()
{
@@ -96,6 +154,5 @@ public partial class DevicesViewModel : ViewModelBase
public override async void OnLoaded()
{
- await OnLoadedAsync();
}
}
\ No newline at end of file
diff --git a/ViewModels/Dialogs/ConfrimDialogViewModel.cs b/ViewModels/Dialogs/ConfrimDialogViewModel.cs
new file mode 100644
index 0000000..5f8d5b9
--- /dev/null
+++ b/ViewModels/Dialogs/ConfrimDialogViewModel.cs
@@ -0,0 +1,11 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+
+namespace PMSWPF.ViewModels.Dialogs;
+
+public partial class ConfrimDialogViewModel : ObservableObject
+{
+ [ObservableProperty] private string _title;
+ [ObservableProperty] private string primaryButtonText;
+
+ [ObservableProperty] private string message;
+}
\ No newline at end of file
diff --git a/ViewModels/Dialogs/DeviceDialogViewModel.cs b/ViewModels/Dialogs/DeviceDialogViewModel.cs
index 42fd308..278e143 100644
--- a/ViewModels/Dialogs/DeviceDialogViewModel.cs
+++ b/ViewModels/Dialogs/DeviceDialogViewModel.cs
@@ -1,6 +1,5 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
-using PMSWPF.Extensions;
using PMSWPF.Models;
namespace PMSWPF.ViewModels.Dialogs;
@@ -9,9 +8,9 @@ public partial class DeviceDialogViewModel : ObservableObject
{
[ObservableProperty]
private Device _device;
-
-
- [ObservableProperty] private string title = "添加设备";
+
+ [ObservableProperty] private string title ;
+ [ObservableProperty] private string primaryButContent ;
public DeviceDialogViewModel(Device device)
{
diff --git a/ViewModels/MainViewModel.cs b/ViewModels/MainViewModel.cs
index 0f6aaca..ddcf046 100644
--- a/ViewModels/MainViewModel.cs
+++ b/ViewModels/MainViewModel.cs
@@ -1,12 +1,8 @@
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
-using CommunityToolkit.Mvvm.Input;
-using CommunityToolkit.Mvvm.Messaging;
-using PMSWPF.Data.Entities;
using PMSWPF.Data.Repositories;
using PMSWPF.Enums;
using PMSWPF.Helper;
-using PMSWPF.Message;
using PMSWPF.Models;
using PMSWPF.Services;
@@ -35,7 +31,7 @@ public partial class MainViewModel : ViewModelBase
// 发送消息加载数据
MessageHelper.SendLoadMessage(LoadTypes.All);
// 当菜单加载成功后,在前台显示菜单
- dataServices.OnMenuListChanged += (menus) =>
+ dataServices.OnMenuTreeListChanged += (menus) =>
{
Menus = new ObservableCollection(menus);
};
diff --git a/Views/DeviceDetailView.xaml b/Views/DeviceDetailView.xaml
index 3958a0b..160a305 100644
--- a/Views/DeviceDetailView.xaml
+++ b/Views/DeviceDetailView.xaml
@@ -3,10 +3,13 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:PMSWPF.Views"
mc:Ignorable="d"
- d:DesignHeight="300" d:DesignWidth="300">
+ d:DesignHeight="300"
+ d:DesignWidth="300">
-
+
-
+
\ No newline at end of file
diff --git a/Views/DevicesView.xaml b/Views/DevicesView.xaml
index 40fe506..b7b937a 100644
--- a/Views/DevicesView.xaml
+++ b/Views/DevicesView.xaml
@@ -8,18 +8,26 @@
xmlns:vm="clr-namespace:PMSWPF.ViewModels"
d:DataContext="{d:DesignInstance vm:DevicesViewModel}"
mc:Ignorable="d"
- d:DesignHeight="300" d:DesignWidth="300">
+ d:DesignHeight="300"
+ d:DesignWidth="300">
-
-
+
+
-
-
+
+
@@ -38,22 +46,29 @@
-
-
-
+
+
+
+
-
+
+
-
+
+
+
+
+
+
@@ -63,8 +78,8 @@
+ Icon="Setting"
+ Label="Settings" />
@@ -72,7 +87,7 @@
diff --git a/Views/DevicesView.xaml.cs b/Views/DevicesView.xaml.cs
index 4479b1d..54d4fff 100644
--- a/Views/DevicesView.xaml.cs
+++ b/Views/DevicesView.xaml.cs
@@ -1,8 +1,6 @@
-using System.Windows;
-using System.Windows.Controls;
+using System.Windows.Controls;
using iNKORE.UI.WPF.Modern.Controls;
using Microsoft.Extensions.DependencyInjection;
-using PMSWPF.Services;
using PMSWPF.ViewModels;
namespace PMSWPF.Views;
@@ -14,9 +12,6 @@ public partial class DevicesView : UserControl
InitializeComponent();
DataContext=App.Current.Services.GetRequiredService();
}
-
- private void BasicGridView_ItemClick(object sender, ItemClickEventArgs e)
- {
- }
+
}
\ No newline at end of file
diff --git a/Views/Dialogs/ConfirmDialog.xaml b/Views/Dialogs/ConfirmDialog.xaml
new file mode 100644
index 0000000..47bb270
--- /dev/null
+++ b/Views/Dialogs/ConfirmDialog.xaml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Views/Dialogs/ConfirmDialog.xaml.cs b/Views/Dialogs/ConfirmDialog.xaml.cs
new file mode 100644
index 0000000..0200792
--- /dev/null
+++ b/Views/Dialogs/ConfirmDialog.xaml.cs
@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+using iNKORE.UI.WPF.Modern.Controls;
+using PMSWPF.ViewModels.Dialogs;
+
+namespace PMSWPF.Views.Dialogs;
+
+public partial class ConfirmDialog : ContentDialog
+{
+
+ public ConfirmDialog(ConfrimDialogViewModel viewModel)
+ {
+ InitializeComponent();
+ this.DataContext = viewModel;
+ }
+}
\ No newline at end of file
diff --git a/Views/Dialogs/DeviceDialog.xaml b/Views/Dialogs/DeviceDialog.xaml
index 435bb87..c14576d 100644
--- a/Views/Dialogs/DeviceDialog.xaml
+++ b/Views/Dialogs/DeviceDialog.xaml
@@ -1,49 +1,57 @@
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
@@ -54,7 +62,9 @@
-
+
@@ -63,26 +73,31 @@
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
@@ -93,9 +108,12 @@
-
-
+
+
-
+
\ No newline at end of file
diff --git a/Views/Dialogs/DeviceDialog.xaml.cs b/Views/Dialogs/DeviceDialog.xaml.cs
index ab5d178..45bd919 100644
--- a/Views/Dialogs/DeviceDialog.xaml.cs
+++ b/Views/Dialogs/DeviceDialog.xaml.cs
@@ -7,10 +7,10 @@ namespace PMSWPF.Views.Dialogs;
public partial class DeviceDialog
{
- public DeviceDialog(Device device)
+ public DeviceDialog(DeviceDialogViewModel viewModel)
{
InitializeComponent();
- DataContext = new DeviceDialogViewModel(device);
+ DataContext = viewModel;
}
private void OnPrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
diff --git a/Views/MainView.xaml b/Views/MainView.xaml
index ae8f9b3..c7202b7 100644
--- a/Views/MainView.xaml
+++ b/Views/MainView.xaml
@@ -1,25 +1,28 @@
-
+
-
-
+
+
@@ -27,21 +30,18 @@
-
+
@@ -83,8 +83,11 @@
-
-
+
+
diff --git a/Views/MainView.xaml.cs b/Views/MainView.xaml.cs
index cb93754..e878fcd 100644
--- a/Views/MainView.xaml.cs
+++ b/Views/MainView.xaml.cs
@@ -1,12 +1,8 @@
using System.Windows;
-using System.Windows.Controls;
-using CommunityToolkit.Mvvm.Messaging;
using iNKORE.UI.WPF.Modern.Controls;
-using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using PMSWPF.Enums;
using PMSWPF.Helper;
-using PMSWPF.Message;
using PMSWPF.Models;
using PMSWPF.ViewModels;
diff --git a/Views/VariableTableView.xaml b/Views/VariableTableView.xaml
index 48bc326..47cab11 100644
--- a/Views/VariableTableView.xaml
+++ b/Views/VariableTableView.xaml
@@ -70,9 +70,7 @@
-
-
-
+
\ No newline at end of file