完成添加变量功能
This commit is contained in:
119
Views/Dialogs/VarDataDialog.xaml
Normal file
119
Views/Dialogs/VarDataDialog.xaml
Normal file
@@ -0,0 +1,119 @@
|
||||
<ui:ContentDialog x:Class="PMSWPF.Views.Dialogs.VarDataDialog"
|
||||
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:VarDataDialogViewModel}"
|
||||
mc:Ignorable="d">
|
||||
<ui:ContentDialog.Resources>
|
||||
<vc:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
|
||||
</ui:ContentDialog.Resources>
|
||||
|
||||
<Grid Margin="10" Width="480">
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<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 VariableData.Name, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Text="变量描述"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox AcceptsReturn="True"
|
||||
Text="{Binding VariableData.Description, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Text="节点ID"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox Text="{Binding VariableData.NodeId, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Text="协议类型"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<ComboBox SelectedValue="{Binding VariableData.ProtocolType, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedValuePath="Tag"
|
||||
ItemsSource="{ex:EnumBindingSource {x:Type en:ProtocolType}}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Text="数据类型"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox Text="{Binding VariableData.DataType, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Text="信号类型"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<ComboBox SelectedValue="{Binding VariableData.SignalType, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedValuePath="Tag"
|
||||
ItemsSource="{ex:EnumBindingSource {x:Type en:SignalType}}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={StaticResource EnumDescriptionConverter}}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</ikw:SimpleStackPanel>
|
||||
</GroupBox>
|
||||
|
||||
<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 VariableData.SaveRange, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<CheckBox Content="是否激活"
|
||||
FontSize="16"
|
||||
Margin="0 10 0 0 "
|
||||
IsChecked="{Binding VariableData.IsActive, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<CheckBox Content="是否保存"
|
||||
FontSize="16"
|
||||
Margin="0 10 0 0 "
|
||||
IsChecked="{Binding VariableData.IsSave, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
</ikw:SimpleStackPanel>
|
||||
</GroupBox>
|
||||
|
||||
<!-- 报警设置 -->
|
||||
<GroupBox Header="报警设置" Margin="10 15 0 10">
|
||||
<ikw:SimpleStackPanel Margin="10" Spacing="12">
|
||||
|
||||
<TextBlock Text="报警最小值"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox Text="{Binding VariableData.AlarmMin, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock Text="报警最大值"
|
||||
Style="{StaticResource TextBlockSubTitle}" />
|
||||
<TextBox Text="{Binding VariableData.AlarmMax, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<CheckBox Content="是否报警"
|
||||
FontSize="16"
|
||||
Margin="0 5"
|
||||
IsChecked="{Binding VariableData.IsAlarm, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</ikw:SimpleStackPanel>
|
||||
</GroupBox>
|
||||
</ikw:SimpleStackPanel>
|
||||
|
||||
</Grid>
|
||||
</ui:ContentDialog>
|
||||
17
Views/Dialogs/VarDataDialog.xaml.cs
Normal file
17
Views/Dialogs/VarDataDialog.xaml.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using PMSWPF.ViewModels.Dialogs;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace PMSWPF.Views.Dialogs;
|
||||
|
||||
public partial class VarDataDialog
|
||||
{
|
||||
public VarDataDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public VarDataDialog(VarDataDialogViewModel viewModel) : this()
|
||||
{
|
||||
DataContext = viewModel;
|
||||
}
|
||||
}
|
||||
@@ -45,9 +45,10 @@
|
||||
<controls:CommandBar x:Name="PrimaryCommandBar"
|
||||
DefaultLabelPosition="Right"
|
||||
IsOpen="False">
|
||||
<ui:AppBarButton x:Name="AddButton"
|
||||
Command="{Binding AddDeviceCommand}"
|
||||
Label="Add">
|
||||
<ui:AppBarButton
|
||||
Command="{Binding AddVarDataCommand}"
|
||||
CommandParameter="{Binding VariableTable}"
|
||||
Label="添加变量">
|
||||
<ui:AppBarButton.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" />
|
||||
</ui:AppBarButton.Icon>
|
||||
|
||||
Reference in New Issue
Block a user