初步完成变量选择Mqtt服务器

This commit is contained in:
2025-09-06 19:10:25 +08:00
parent 31c4e77232
commit 5db88f5709
11 changed files with 455 additions and 220 deletions

View File

@@ -1,38 +1,86 @@
<ui:ContentDialog
x:Class="DMS.WPF.Views.Dialogs.MqttAliasBatchEditDialog"
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:hc="https://handyorg.github.io/handycontrol"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:vm="clr-namespace:DMS.WPF.ViewModels.Dialogs"
xmlns:models="clr-namespace:DMS.Core.Models"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance vm:MqttAliasBatchEditDialogViewModel}"
Title="{Binding Title}"
PrimaryButtonText="确定"
CloseButtonText="取消"
>
<StackPanel Margin="10">
<TextBlock TextWrapping="WrapWithOverflow" Margin="5 10" FontSize="13" Foreground="#666">设置的别名当变量向MQTT服务器发送数据时就会按照设置设置好的别名发送请在MQTT服务端按照设置的名称接受。</TextBlock>
<DataGrid ItemsSource="{Binding VariablesToEdit}"
<ui:ContentDialog x:Class="DMS.WPF.Views.Dialogs.MqttAliasBatchEditDialog"
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:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:vm="clr-namespace:DMS.WPF.ViewModels.Dialogs"
d:DataContext="{d:DesignInstance vm:MqttAliasBatchEditDialogViewModel}"
Title="批量编辑MQTT别名"
PrimaryButtonText="确定"
CloseButtonText="取消"
PrimaryButtonCommand="{Binding ConfirmCommand}"
CloseButtonCommand="{Binding CloseCommand}"
DefaultButton="Primary"
Background="White"
mc:Ignorable="d"
>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Text="为目标MQTT服务器设置变量别名"
Margin="0,0,0,10"
Style="{StaticResource BodyTextBlockStyle}" />
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,0,0,10">
<TextBlock Text="MQTT服务器" VerticalAlignment="Center" />
<TextBlock Text="{Binding SelectedMqttServer.ServerName}"
FontWeight="Bold"
Margin="5,0,0,0"
VerticalAlignment="Center" />
</StackPanel>
<DataGrid Grid.Row="2"
ItemsSource="{Binding VariableMqttAliases}"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
IsReadOnly="False">
Margin="0,0,0,10"
MinHeight="300"
MaxHeight="500">
<DataGrid.Columns>
<DataGridTextColumn Header="变量名称" Binding="{Binding Variable.Name}" IsReadOnly="True" Width="*"/>
<DataGridTextColumn Header="标识符" Binding="{Binding Identifier}" IsReadOnly="True" Width="*"/>
<DataGridTemplateColumn Header="MQTT别名" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<hc:TextBox Text="{Binding MqttAlias, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
hc:InfoElement.Placeholder="请输入别名"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="变量名称"
Binding="{Binding VariableId}"
IsReadOnly="True"
Width="*" />
<DataGridTextColumn Header="别名"
Binding="{Binding Alias}"
Width="*" />
</DataGrid.Columns>
</DataGrid>
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right">
<TextBox x:Name="PrefixTextBox"
Width="150"
Margin="0,0,10,0">
<TextBox.Resources>
<VisualBrush x:Key="HintText" AlignmentX="Left" AlignmentY="Center" Stretch="None">
<VisualBrush.Visual>
<TextBlock Text="输入前缀" Foreground="Gray" Margin="5,0,0,0" />
</VisualBrush.Visual>
</VisualBrush>
</TextBox.Resources>
<TextBox.Style>
<Style TargetType="TextBox">
<Setter Property="Background" Value="White" />
<Style.Triggers>
<Trigger Property="Text" Value="">
<Setter Property="Background" Value="{StaticResource HintText}" />
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
<Button Content="应用前缀"
Command="{Binding ApplySamePrefixCommand}"
CommandParameter="{Binding Text, ElementName=PrefixTextBox}" />
</StackPanel>
</Grid>
</ui:ContentDialog>