给应用添加图标,完成给设备添加变量表的功能
This commit is contained in:
@@ -17,12 +17,6 @@
|
||||
d:DataContext="{d:DesignInstance vmd:ConfrimDialogViewModel}"
|
||||
mc:Ignorable="d">
|
||||
<ui:ContentDialog.Resources>
|
||||
<ex:EnumBindingSource x:Key="deviceType"
|
||||
EnumType="{x:Type en:DeviceType}" />
|
||||
<ex:EnumBindingSource x:Key="protocolType"
|
||||
EnumType="{x:Type en:ProtocolType}" />
|
||||
<vc:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
|
||||
|
||||
|
||||
</ui:ContentDialog.Resources>
|
||||
|
||||
|
||||
40
Views/Dialogs/VarTableDialog.xaml
Normal file
40
Views/Dialogs/VarTableDialog.xaml
Normal file
@@ -0,0 +1,40 @@
|
||||
<ui:ContentDialog x:Class="PMSWPF.Views.Dialogs.VarTableDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:vmd="clr-namespace:PMSWPF.ViewModels.Dialogs"
|
||||
xmlns:vc="clr-namespace:PMSWPF.ValueConverts"
|
||||
xmlns:ex="clr-namespace:PMSWPF.Extensions"
|
||||
xmlns:en="clr-namespace:PMSWPF.Enums"
|
||||
Title="{Binding Title}"
|
||||
CloseButtonText="取消"
|
||||
DefaultButton="Primary"
|
||||
PrimaryButtonText="{Binding PrimaryButtonText}"
|
||||
Background="#fff"
|
||||
d:DataContext="{d:DesignInstance vmd:VarTableDialogViewModel}"
|
||||
mc:Ignorable="d">
|
||||
<ui:ContentDialog.Resources>
|
||||
|
||||
</ui:ContentDialog.Resources>
|
||||
|
||||
<ikw:SimpleStackPanel Width="300" Grid.Column="0"
|
||||
Margin="10 10 20 10 "
|
||||
Spacing="12">
|
||||
<!-- 设备名称 -->
|
||||
<TextBlock Text="变量表名称"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox Text="{Binding VariableTable.Name, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<!-- 设备IP地址 -->
|
||||
<TextBlock Text="变量表描述"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox AcceptsReturn="True"
|
||||
Text="{Binding VariableTable.Description, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
</ikw:SimpleStackPanel>
|
||||
|
||||
</ui:ContentDialog>
|
||||
13
Views/Dialogs/VarTableDialog.xaml.cs
Normal file
13
Views/Dialogs/VarTableDialog.xaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using PMSWPF.ViewModels.Dialogs;
|
||||
|
||||
namespace PMSWPF.Views.Dialogs;
|
||||
|
||||
public partial class VarTableDialog : ContentDialog
|
||||
{
|
||||
public VarTableDialog(VarTableDialogViewModel viewModel)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = viewModel;
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,17 @@
|
||||
d:DataContext="{d:DesignInstance vm:MainViewModel}"
|
||||
mc:Ignorable="d">
|
||||
<Window.Resources>
|
||||
|
||||
<ContextMenu x:Key="MyMenuItemContextMenu">
|
||||
<MenuItem Header="添加" />
|
||||
<MenuItem Header="编辑" />
|
||||
<Separator />
|
||||
<MenuItem Header="删除" />
|
||||
</ContextMenu>
|
||||
<DataTemplate x:Key="NavigationViewMenuItem"
|
||||
DataType="{x:Type mo:MenuBean}">
|
||||
<ui:NavigationViewItem Content="{Binding Name}"
|
||||
<ui:NavigationViewItem
|
||||
Content="{Binding Name}"
|
||||
MenuItemsSource="{Binding Items }">
|
||||
<ui:NavigationViewItem.Icon>
|
||||
<ui:FontIcon Glyph="{Binding Icon}" />
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.Windows;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PMSWPF.Enums;
|
||||
using PMSWPF.Helper;
|
||||
using PMSWPF.Models;
|
||||
using PMSWPF.Services;
|
||||
using PMSWPF.ViewModels;
|
||||
|
||||
namespace PMSWPF.Views;
|
||||
@@ -13,15 +15,17 @@ namespace PMSWPF.Views;
|
||||
/// </summary>
|
||||
public partial class MainView : Window
|
||||
{
|
||||
private readonly DataServices _dataServices;
|
||||
private readonly ILogger<MainView> _logger;
|
||||
private MainViewModel _viewModel;
|
||||
|
||||
public MainView(MainViewModel viewModel, ILogger<MainView> logger)
|
||||
public MainView(DataServices dataServices, ILogger<MainView> logger)
|
||||
{
|
||||
InitializeComponent();
|
||||
_viewModel = viewModel;
|
||||
_viewModel = App.Current.Services.GetRequiredService<MainViewModel>();
|
||||
_dataServices = dataServices;
|
||||
_logger = logger;
|
||||
DataContext = viewModel;
|
||||
DataContext = _viewModel;
|
||||
_logger.LogInformation("主界面加载成功");
|
||||
}
|
||||
|
||||
@@ -30,32 +34,16 @@ public partial class MainView : Window
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
|
||||
private async void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
|
||||
{
|
||||
try
|
||||
var menu = args.SelectedItem as MenuBean;
|
||||
if (menu != null)
|
||||
{
|
||||
var menu = args.SelectedItem as MenuBean;
|
||||
if (menu == null)
|
||||
throw new ArgumentException("选择的菜单项为空!");
|
||||
|
||||
switch (menu.Type)
|
||||
{
|
||||
case MenuType.MainMenu:
|
||||
case MenuType.DeviceMenu:
|
||||
case MenuType.VariableTableMenu:
|
||||
if (menu.ViewModel == null)
|
||||
throw new ArgumentException($"菜单项:{menu.Name},没有绑定对象的ViewModel");
|
||||
MessageHelper.SendNavgatorMessage(menu.ViewModel);
|
||||
_logger.LogInformation($"导航到:{menu.Name}");
|
||||
break;
|
||||
case MenuType.AddVariableTableMenu:
|
||||
break;
|
||||
}
|
||||
await _viewModel.MenuSelectionChanged(menu);
|
||||
}
|
||||
catch (Exception e)
|
||||
else
|
||||
{
|
||||
NotificationHelper.ShowMessage(e.Message, NotificationType.Error);
|
||||
_logger.LogError(e.Message);
|
||||
NotificationHelper.ShowMessage("选择的菜单项为空!", NotificationType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,5 +51,4 @@ public partial class MainView : Window
|
||||
{
|
||||
_viewModel.OnLoaded();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user