BOB/BOB/Views/Dialogs/DeviceSetting.xaml
2025-11-10 15:46:29 +08:00

133 lines
7.4 KiB
XML

<UserControl x:Class="BOB.Views.Dialogs.DeviceSetting"
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:converters="clr-namespace:BOB.Converters"
xmlns:prism="http://prismlibrary.com/"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:behavior="clr-namespace:Common.Behaviors;assembly=Common"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
prism:ViewModelLocator.AutoWireViewModel="True"
Background="White"
Panel.ZIndex="1000"
mc:Ignorable="d"
Height="290"
Width="450">
<prism:Dialog.WindowStyle>
<Style BasedOn="{StaticResource DialogUserManageStyle}"
TargetType="Window" />
</prism:Dialog.WindowStyle>
<UserControl.Resources>
<converters:DeviceNameConverter x:Key="DeviceNameConverter" />
<converters:StringToVisibilityConverter x:Key="StringToVisibilityConverter" />
</UserControl.Resources>
<Grid>
<GroupBox Header="{Binding Title}"
Padding="10,15,10,0"
behavior:WindowDragBehavior.EnableWindowDrag="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<ScrollViewer>
<StackPanel>
<StackPanel Height="30"
Visibility="{Binding Device.ErrorMessage, Converter={StaticResource StringToVisibilityConverter}}"
Orientation="Horizontal"
Margin="7,7,0,7">
<TextBlock Text="{Binding Device.ErrorMessage}"
Padding="0,11"
Height="30"
Foreground="Red" />
</StackPanel>
<StackPanel Height="30"
Orientation="Horizontal"
Margin="7">
<Label Content="设备名称"
VerticalAlignment="Bottom"
Width="85" />
<TextBox Text="{Binding Device.Name}"
VerticalAlignment="Bottom"
materialDesign:HintAssist.Hint="设备名称"
Width="120" />
</StackPanel>
<StackPanel Height="30"
Orientation="Horizontal"
Margin="7">
<Label Content="通讯协议类型"
VerticalAlignment="Bottom"
Width="85" />
<ComboBox ItemsSource="{Binding Types}"
SelectedItem="{Binding Device.Type,UpdateSourceTrigger=PropertyChanged}"
VerticalAlignment="Bottom"
Width="120"
materialDesign:HintAssist.Hint="通讯协议类型"
IsEnabled="{Binding IsAdd}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<prism:InvokeCommandAction Command="{Binding SelectionChangedCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Height="30"
Orientation="Horizontal"
Margin="7">
<Label Content="设备描述"
Width="85"
VerticalAlignment="Bottom" />
<TextBox Text="{Binding Device.Description}"
VerticalAlignment="Bottom"
materialDesign:HintAssist.Hint="设备描述"
Width="120" />
</StackPanel>
<Label Content="连接参数"
Height="30"
Margin="7"
VerticalContentAlignment="Bottom" />
<ItemsControl ItemsSource="{Binding DeviceConnectSettings}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal"
Height="30"
Margin="0,7">
<Label Content="{Binding Name}"
Width="75"
Margin="40,0,4,0"
VerticalContentAlignment="Bottom" />
<TextBox VerticalAlignment="Bottom"
Visibility="{Binding Name, Converter={StaticResource DeviceNameConverter}}"
materialDesign:HintAssist.Hint=""
Text="{Binding Value}"
Width="120" />
<ComboBox VerticalAlignment="Bottom"
materialDesign:HintAssist.Hint=""
Visibility="{Binding Name, Converter={StaticResource DeviceNameConverter}, ConverterParameter=Inverse}"
ItemsSource="{Binding Name, Converter={StaticResource DeviceNameConverter}, ConverterParameter=Items}"
SelectedItem="{Binding Value}"
Width="120" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</ScrollViewer>
<StackPanel Grid.Row="1"
Orientation="Horizontal"
FlowDirection="RightToLeft"
Margin="5,10,5,15">
<Button Content="取消"
Width="70"
Command="{Binding CancelCommand}" />
<Button Content="保存"
Width="70"
Margin="20,0"
Command="{Binding SaveCommand}" />
</StackPanel>
</Grid>
</GroupBox>
</Grid>
</UserControl>