临时提交

This commit is contained in:
2025-08-23 16:01:30 +08:00
parent 1e0c154884
commit eb81cecec1
20 changed files with 406 additions and 146 deletions

View File

@@ -12,7 +12,7 @@
Title="{Binding Title}"
CloseButtonText="取消"
DefaultButton="Primary"
PrimaryButtonText="{Binding PrimaryButContent}"
PrimaryButtonText="{Binding PrimaryButText}"
Background="#fff"
d:DataContext="{d:DesignInstance vmd:ConfrimDialogViewModel}"
mc:Ignorable="d">

View File

@@ -13,7 +13,7 @@
Title="{Binding Title}"
CloseButtonText="取消"
DefaultButton="Primary"
PrimaryButtonText="{Binding PrimaryButContent}"
PrimaryButtonText="{Binding PrimaryButText}"
d:DataContext="{d:DesignInstance vmd:DeviceDialogViewModel}"
mc:Ignorable="d">

View File

@@ -13,7 +13,7 @@
Title="{Binding Title}"
CloseButtonText="取消"
DefaultButton="Primary"
PrimaryButtonText="{Binding PrimaryButContent}"
PrimaryButtonText="{Binding PrimaryButText}"
Background="#fff"
d:DataContext="{d:DesignInstance vmd:MqttDialogViewModel}"
mc:Ignorable="d">

View File

@@ -1,16 +0,0 @@
using DMS.WPF.ViewModels.Dialogs;
namespace DMS.WPF.Views.Dialogs;
public partial class VarDataDialog
{
public VarDataDialog()
{
InitializeComponent();
}
public VarDataDialog(VarDataDialogViewModel viewModel) : this()
{
DataContext = viewModel;
}
}

View File

@@ -1,4 +1,4 @@
<ui:ContentDialog x:Class="DMS.WPF.Views.Dialogs.VarDataDialog"
<ui:ContentDialog x:Class="DMS.WPF.Views.Dialogs.VariableDialog"
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"
@@ -11,34 +11,42 @@
xmlns:sockets="clr-namespace:System.Net.Sockets;assembly=System.Net.Sockets"
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
xmlns:valueConverts="clr-namespace:DMS.WPF.ValueConverts"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
Title="{Binding Title}"
CloseButtonText="取消"
DefaultButton="Primary"
PrimaryButtonText="{Binding PrimaryButtonText}"
PrimaryButtonText="{Binding PrimaryButText}"
Background="#fff"
d:DataContext="{d:DesignInstance vmd:VarDataDialogViewModel}"
d:DataContext="{d:DesignInstance vmd:VariableDialogViewModel}"
mc:Ignorable="d">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PrimaryButtonClick">
<i:InvokeCommandAction Command="{Binding PrimaryButtonCommand}" />
</i:EventTrigger>
<i:EventTrigger EventName="CloseButtonClick">
<i:InvokeCommandAction Command="{Binding CancleButtonCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ui:ContentDialog.Resources>
<valueConverts:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
</ui:ContentDialog.Resources>
<Grid Margin="10" Width="480">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- <Grid.RowDefinitions> -->
<!-- <RowDefinition Height="Auto" /> -->
<!-- <RowDefinition Height="Auto" /> -->
<!-- </Grid.RowDefinitions> -->
<!-- 基本信息 -->
<GroupBox Header="基本信息" Grid.Row="0" Grid.Column="0" Margin="0 0 10 10">
<ikw:SimpleStackPanel Margin="10" Spacing="12">
<TextBlock Text="变量名称"
Style="{StaticResource TextBlockSubTitle}" />
<TextBox Text="{Binding Variable.Name, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Width="200" Text="{Binding Variable.Name, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="变量描述"
Style="{StaticResource TextBlockSubTitle}" />
@@ -47,11 +55,11 @@
<TextBlock Text="节点ID"
Style="{StaticResource TextBlockSubTitle}" />
<TextBox Text="{Binding Variable.NodeId, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Text="{Binding Variable.OpcUaNodeId, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="协议类型"
Style="{StaticResource TextBlockSubTitle}" />
<ComboBox SelectedValue="{Binding Variable.ProtocolType, UpdateSourceTrigger=PropertyChanged}"
<ComboBox SelectedValue="{Binding Variable.Protocol, UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="Tag"
ItemsSource="{ex:EnumBindingSource {x:Type sockets:ProtocolType}}">
<ComboBox.ItemTemplate>
@@ -63,7 +71,7 @@
<TextBlock Text="数据类型"
Style="{StaticResource TextBlockSubTitle}" />
<TextBox Text="{Binding Variable.DataType, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Text="{Binding Variable.CSharpDataType, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="信号类型"
Style="{StaticResource TextBlockSubTitle}" />
@@ -79,7 +87,7 @@
<TextBlock Text="轮询级别"
Style="{StaticResource TextBlockSubTitle}" />
<ComboBox SelectedValue="{Binding Variable.PollLevelType, UpdateSourceTrigger=PropertyChanged}"
<ComboBox SelectedValue="{Binding Variable.PollLevel, UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="Tag"
ItemsSource="{ex:EnumBindingSource {x:Type enums:PollLevelType}}">
<ComboBox.ItemTemplate>
@@ -91,13 +99,13 @@
</ikw:SimpleStackPanel>
</GroupBox>
<ikw:SimpleStackPanel Grid.Row="0" Grid.Column="1">
<ikw:SimpleStackPanel Grid.Row="0" Grid.Column="1" >
<!-- 保存设置 -->
<GroupBox Header="保存设置" Margin="10 0 0 10">
<ikw:SimpleStackPanel Spacing="12" Margin="10">
<TextBlock Text="保存范围"
Style="{StaticResource TextBlockSubTitle}" />
<TextBox Text="{Binding Variable.SaveRange, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Width="200" Text="{Binding Variable.HistoryDeadband, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Content="是否激活"
FontSize="16"
Margin="0 10 0 0 "
@@ -105,7 +113,7 @@
<CheckBox Content="是否保存"
FontSize="16"
Margin="0 10 0 0 "
IsChecked="{Binding Variable.IsSave, UpdateSourceTrigger=PropertyChanged}" />
IsChecked="{Binding Variable.IsHistoryEnabled, UpdateSourceTrigger=PropertyChanged}" />
</ikw:SimpleStackPanel>
</GroupBox>
@@ -116,18 +124,22 @@
<TextBlock Text="报警最小值"
Style="{StaticResource TextBlockSubTitle}" />
<TextBox Text="{Binding Variable.AlarmMin, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Text="{Binding Variable.AlarmMinValue, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="报警最大值"
Style="{StaticResource TextBlockSubTitle}" />
<TextBox Text="{Binding Variable.AlarmMax, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Text="{Binding Variable.AlarmMaxValue, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Content="是否报警"
FontSize="16"
Margin="0 5"
IsChecked="{Binding Variable.IsAlarm, UpdateSourceTrigger=PropertyChanged}" />
IsChecked="{Binding Variable.IsAlarmEnabled, UpdateSourceTrigger=PropertyChanged}" />
</ikw:SimpleStackPanel>
</GroupBox>
</ikw:SimpleStackPanel>
<ikw:SimpleStackPanel Grid.Row="0" Grid.Column="2" Width="100">
</ikw:SimpleStackPanel>
</Grid>
</ui:ContentDialog>

View File

@@ -0,0 +1,14 @@
using DMS.WPF.ViewModels.Dialogs;
namespace DMS.WPF.Views.Dialogs;
public partial class VariableDialog
{
public VariableDialog()
{
InitializeComponent();
}
}

View File

@@ -10,7 +10,7 @@
Title="{Binding Title}"
CloseButtonText="取消"
DefaultButton="Primary"
PrimaryButtonText="{Binding PrimaryButContent}"
PrimaryButtonText="{Binding PrimaryButText}"
Background="#fff"
d:DataContext="{d:DesignInstance vmd:VariableTableDialogViewModel}"
mc:Ignorable="d">

View File

@@ -0,0 +1,87 @@
<UserControl x:Class="DMS.WPF.Views.HandyDialogs.VariableEditorDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:DMS.WPF.Views"
xmlns:vmd="clr-namespace:DMS.WPF.ViewModels.Dialogs"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=vmd:VariableDialogViewModel}"
Background="#fff"
Width="1000">
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding Title}" Style="{StaticResource TextBlockTitle}" Margin="0,0,0,16"/>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="名称:" VerticalAlignment="Center" Margin="0,0,10,0"/>
<hc:TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Variable.Name, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxExtend}" Margin="0,5"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="地址:" VerticalAlignment="Center" Margin="0,0,10,0"/>
<hc:TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Variable.S7Address, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxExtend}" Margin="0,5"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="描述:" VerticalAlignment="Center" Margin="0,0,10,0"/>
<hc:TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Variable.Description, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" AcceptsReturn="True" MinHeight="60" Style="{StaticResource TextBoxExtend}" Margin="0,5"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="数据类型:" VerticalAlignment="Center" Margin="0,0,10,0"/>
<hc:ComboBox Grid.Row="3" Grid.Column="1" ItemsSource="{Binding CSharpDataTypes}" SelectedItem="{Binding Variable.CSharpDataType}" Style="{StaticResource ComboBoxExtend}" Margin="0,5"/>
<TextBlock Grid.Row="4" Grid.Column="0" Text="协议:" VerticalAlignment="Center" Margin="0,0,10,0"/>
<hc:ComboBox Grid.Row="4" Grid.Column="1" ItemsSource="{Binding ProtocolTypes}" SelectedItem="{Binding Variable.Protocol}" Style="{StaticResource ComboBoxExtend}" Margin="0,5"/>
<TextBlock Grid.Row="5" Grid.Column="0" Text="轮询频率:" VerticalAlignment="Center" Margin="0,0,10,0"/>
<hc:ComboBox Grid.Row="5" Grid.Column="1" ItemsSource="{Binding PollLevelTypes}" SelectedItem="{Binding Variable.PollLevel}" Style="{StaticResource ComboBoxExtend}" Margin="0,5"/>
<hc:Divider Grid.Row="6" Grid.ColumnSpan="2" Margin="0,10"/>
<StackPanel Grid.Row="7" Grid.ColumnSpan="2" Orientation="Horizontal">
<CheckBox IsChecked="{Binding Variable.IsActive}" Content="启用变量" Margin="0,5,20,5"/>
<CheckBox IsChecked="{Binding Variable.IsHistoryEnabled}" Content="启用历史记录" Margin="0,5,20,5"/>
<CheckBox IsChecked="{Binding Variable.IsAlarmEnabled}" Content="启用报警" Margin="0,5,20,5"/>
</StackPanel>
<Grid Grid.Row="8" Grid.ColumnSpan="2" IsEnabled="{Binding Variable.IsAlarmEnabled}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<hc:NumericUpDown Grid.Column="0" Minimum="-999999" Maximum="999999" Value="{Binding Variable.AlarmMinValue}" hc:InfoElement.Title="报警下限" Margin="0,5,5,5"/>
<hc:NumericUpDown Grid.Column="1" Minimum="-999999" Maximum="999999" Value="{Binding Variable.AlarmMaxValue}" hc:InfoElement.Title="报警上限" Margin="5,5"/>
<hc:NumericUpDown Grid.Column="2" Minimum="0" Maximum="999999" Value="{Binding Variable.AlarmDeadband}" hc:InfoElement.Title="报警死区" Margin="5,5,0,5"/>
</Grid>
</Grid>
</ScrollViewer>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,16,0,0">
<Button Command="{Binding SaveCommand}" Content="保存" Style="{StaticResource ButtonPrimary}" IsDefault="True"/>
<Button Command="{Binding CancelCommand}" Content="取消" Margin="10,0,0,0" IsCancel="True"/>
</StackPanel>
</Grid>
</UserControl>

View File

@@ -0,0 +1,16 @@
using System.Windows.Controls;
namespace DMS.WPF.Views.HandyDialogs
{
/// <summary>
/// Interaction logic for VariableEditorDialog.xaml
/// </summary>
public partial class VariableEditorDialog : UserControl
{
public VariableEditorDialog()
{
InitializeComponent();
}
}
}

View File

@@ -58,8 +58,7 @@
<controls:CommandBar x:Name="PrimaryCommandBar"
DefaultLabelPosition="Right"
IsOpen="False">
<ui:AppBarButton Command="{Binding AddVarDataCommand}"
CommandParameter="{Binding VariableTable}"
<ui:AppBarButton Command="{Binding AddVariableCommand}"
Label="添加变量">
<ui:AppBarButton.Icon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" />
@@ -312,18 +311,17 @@
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="轮询频率"
SortMemberPath="PollLevelType">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Text="{Binding PollLevelType, Converter={StaticResource EnumDescriptionConverter}}" />
Text="{Binding PollLevel, Converter={StaticResource EnumDescriptionConverter}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Source={StaticResource pollLevelType}}"
SelectedItem="{Binding PollLevelType}">
SelectedItem="{Binding PollLevel}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
@@ -343,24 +341,24 @@
<DataGridTextColumn IsReadOnly="True"
Header="创建时间"
Binding="{Binding CreateTime, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}" />
Binding="{Binding CreatedAt, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}" />
<DataGridTextColumn IsReadOnly="True"
Header="更新时间"
Binding="{Binding UpdateTime, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}" />
Binding="{Binding UpdatedAt, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}" />
<DataGridTextColumn Header="转换规则"
Binding="{Binding Converstion}" />
Binding="{Binding ConversionFormula}" />
<DataGridCheckBoxColumn Header="启用"
Binding="{Binding IsActive}" />
<DataGridCheckBoxColumn Header="保存"
Binding="{Binding IsSave}" />
Binding="{Binding IsHistoryEnabled}" />
<DataGridTextColumn Header="保存范围"
Binding="{Binding SaveRange}" />
Binding="{Binding HistoryDeadband}" />
<DataGridCheckBoxColumn Header="报警"
Binding="{Binding IsAlarm}" />
Binding="{Binding IsAlarmEnabled}" />
<DataGridTextColumn Header="报警最小值"
Binding="{Binding AlarmMin}" />
Binding="{Binding AlarmMinValue}" />
<DataGridTextColumn Header="报警最大值"
Binding="{Binding AlarmMax}" />
Binding="{Binding AlarmMaxValue}" />
</DataGrid.Columns>
</DataGrid>
</DockPanel>