2025-08-24 18:29:26 +08:00
|
|
|
<UserControl
|
|
|
|
|
x:Class="DMS.WPF.Views.DevicesView"
|
|
|
|
|
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:hc="https://handyorg.github.io/handycontrol"
|
|
|
|
|
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
|
|
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
|
|
|
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
|
|
|
|
xmlns:vm="clr-namespace:DMS.WPF.ViewModels"
|
|
|
|
|
d:DataContext="{d:DesignInstance vm:DevicesViewModel}"
|
|
|
|
|
d:DesignHeight="300"
|
|
|
|
|
d:DesignWidth="300"
|
|
|
|
|
mc:Ignorable="d">
|
2025-06-22 21:00:06 +08:00
|
|
|
<UserControl.Resources>
|
|
|
|
|
<DataTemplate x:Key="DeviceItemTemplate">
|
2025-08-24 18:29:26 +08:00
|
|
|
<Border
|
|
|
|
|
Margin="5"
|
|
|
|
|
Padding="15"
|
|
|
|
|
Background="{DynamicResource SystemControlBackgroundAltHighBrush}"
|
|
|
|
|
BorderBrush="{DynamicResource SystemControlHighlightBaseMediumLowBrush}"
|
|
|
|
|
BorderThickness="1"
|
|
|
|
|
CornerRadius="8">
|
2025-07-04 18:33:48 +08:00
|
|
|
<Border.Effect>
|
2025-08-24 18:29:26 +08:00
|
|
|
<DropShadowEffect
|
|
|
|
|
BlurRadius="5"
|
|
|
|
|
Opacity="0.1"
|
|
|
|
|
ShadowDepth="1"
|
|
|
|
|
Color="Black" />
|
2025-07-04 18:33:48 +08:00
|
|
|
</Border.Effect>
|
2025-07-13 18:05:31 +08:00
|
|
|
<Border.Style>
|
|
|
|
|
<Style TargetType="Border">
|
|
|
|
|
<Style.Triggers>
|
2025-08-24 18:29:26 +08:00
|
|
|
<DataTrigger Binding="{Binding IsRunning}" Value="True">
|
|
|
|
|
<Setter Property="Background" Value="Aquamarine" />
|
2025-07-13 18:05:31 +08:00
|
|
|
</DataTrigger>
|
2025-08-24 18:29:26 +08:00
|
|
|
|
2025-07-13 18:05:31 +08:00
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
|
|
|
|
</Border.Style>
|
2025-08-24 18:29:26 +08:00
|
|
|
|
|
|
|
|
|
2025-07-04 18:33:48 +08:00
|
|
|
<Grid>
|
|
|
|
|
<Grid.RowDefinitions>
|
|
|
|
|
<RowDefinition Height="Auto" />
|
|
|
|
|
<RowDefinition Height="Auto" />
|
|
|
|
|
<RowDefinition Height="*" />
|
|
|
|
|
</Grid.RowDefinitions>
|
|
|
|
|
|
|
|
|
|
<!-- Row 0: Header with Name and ToggleSwitch -->
|
2025-08-24 18:29:26 +08:00
|
|
|
<DockPanel Grid.Row="0" Margin="0,0,0,10">
|
|
|
|
|
<ui:ToggleSwitch
|
|
|
|
|
DockPanel.Dock="Right"
|
|
|
|
|
IsOn="{Binding IsActive}"
|
|
|
|
|
OffContent="停止"
|
|
|
|
|
OnContent="启动" />
|
|
|
|
|
<TextBlock
|
|
|
|
|
VerticalAlignment="Center"
|
|
|
|
|
FontSize="20"
|
|
|
|
|
FontWeight="SemiBold"
|
|
|
|
|
Text="{Binding Name}" />
|
2025-06-22 21:00:06 +08:00
|
|
|
</DockPanel>
|
2025-06-23 17:01:06 +08:00
|
|
|
|
2025-07-04 18:33:48 +08:00
|
|
|
<!-- Row 1: Details with Icons -->
|
2025-08-24 18:29:26 +08:00
|
|
|
<StackPanel Grid.Row="1" Margin="0,0,0,10">
|
|
|
|
|
<StackPanel Margin="0,2" Orientation="Horizontal">
|
|
|
|
|
<ui:FontIcon
|
|
|
|
|
Margin="0,0,8,0"
|
|
|
|
|
VerticalAlignment="Center"
|
|
|
|
|
FontSize="14"
|
|
|
|
|
Icon="{x:Static ui:SegoeFluentIcons.Info}" />
|
|
|
|
|
<TextBlock
|
|
|
|
|
Foreground="{DynamicResource SystemControlForegroundBaseMediumBrush}"
|
|
|
|
|
Text="{Binding Description}"
|
|
|
|
|
TextTrimming="CharacterEllipsis" />
|
2025-07-04 18:33:48 +08:00
|
|
|
</StackPanel>
|
2025-08-24 18:29:26 +08:00
|
|
|
<StackPanel Margin="0,2" Orientation="Horizontal">
|
|
|
|
|
<ui:FontIcon
|
|
|
|
|
Margin="0,0,8,0"
|
|
|
|
|
VerticalAlignment="Center"
|
|
|
|
|
FontSize="14"
|
|
|
|
|
Icon="{x:Static ui:SegoeFluentIcons.Connect}" />
|
2025-07-04 18:33:48 +08:00
|
|
|
<TextBlock>
|
2025-07-27 21:08:58 +08:00
|
|
|
<Run Text="{Binding IpAddress, FallbackValue='192.168.1.1'}" />
|
2025-07-04 18:33:48 +08:00
|
|
|
<Run Text=":" />
|
2025-07-27 21:08:58 +08:00
|
|
|
<Run Text="{Binding Port, FallbackValue='102'}" />
|
2025-07-04 18:33:48 +08:00
|
|
|
</TextBlock>
|
|
|
|
|
</StackPanel>
|
2025-08-24 18:29:26 +08:00
|
|
|
<StackPanel Margin="0,2" Orientation="Horizontal">
|
|
|
|
|
<ui:FontIcon
|
|
|
|
|
Margin="0,0,8,0"
|
|
|
|
|
VerticalAlignment="Center"
|
|
|
|
|
FontSize="14"
|
|
|
|
|
Icon="{x:Static ui:SegoeFluentIcons.DeveloperTools}" />
|
2025-07-04 18:33:48 +08:00
|
|
|
<TextBlock>
|
|
|
|
|
<Run Text="{Binding DeviceType, FallbackValue='S7_1200'}" />
|
|
|
|
|
<Run Text=" / " />
|
2025-08-24 18:29:26 +08:00
|
|
|
<Run Text="{Binding Protocol, FallbackValue='S7'}" />
|
2025-07-04 18:33:48 +08:00
|
|
|
</TextBlock>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</StackPanel>
|
2025-06-23 17:01:06 +08:00
|
|
|
|
2025-07-04 18:33:48 +08:00
|
|
|
<!-- Row 2: Variable Tables -->
|
2025-08-24 18:29:26 +08:00
|
|
|
<GroupBox
|
|
|
|
|
Grid.Row="2"
|
|
|
|
|
Padding="5"
|
|
|
|
|
Header="变量表">
|
|
|
|
|
<ListBox ItemsSource="{Binding VariableTables}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
2025-07-04 18:33:48 +08:00
|
|
|
<ListBox.ItemsPanel>
|
|
|
|
|
<ItemsPanelTemplate>
|
|
|
|
|
<WrapPanel />
|
|
|
|
|
</ItemsPanelTemplate>
|
|
|
|
|
</ListBox.ItemsPanel>
|
|
|
|
|
<ListBox.ItemTemplate>
|
|
|
|
|
<DataTemplate>
|
2025-08-24 18:29:26 +08:00
|
|
|
<Border
|
|
|
|
|
Margin="2"
|
|
|
|
|
Padding="8,4"
|
|
|
|
|
Background="{DynamicResource SystemControlBackgroundListLowBrush}"
|
|
|
|
|
CornerRadius="4">
|
2025-07-04 18:33:48 +08:00
|
|
|
<TextBlock Text="{Binding Name}" />
|
|
|
|
|
</Border>
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</ListBox.ItemTemplate>
|
|
|
|
|
</ListBox>
|
|
|
|
|
</GroupBox>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Border>
|
2025-06-22 21:00:06 +08:00
|
|
|
</DataTemplate>
|
|
|
|
|
</UserControl.Resources>
|
2025-06-23 17:01:06 +08:00
|
|
|
|
|
|
|
|
<StackPanel>
|
2025-08-24 18:29:26 +08:00
|
|
|
<!-- 操作菜单栏 -->
|
|
|
|
|
<ui:CommandBar DefaultLabelPosition="Right" IsOpen="False">
|
|
|
|
|
<!-- 添加设备 -->
|
|
|
|
|
<ui:AppBarButton Command="{Binding AddDeviceCommand}" Label="添加设备">
|
2025-06-22 21:00:06 +08:00
|
|
|
<ui:AppBarButton.Icon>
|
2025-06-23 17:01:06 +08:00
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" />
|
2025-06-22 21:00:06 +08:00
|
|
|
</ui:AppBarButton.Icon>
|
|
|
|
|
</ui:AppBarButton>
|
2025-08-24 18:29:26 +08:00
|
|
|
<!-- 编辑设备 -->
|
|
|
|
|
<ui:AppBarButton Command="{Binding EditDeviceCommand}" Label="编辑设备">
|
2025-06-22 21:00:06 +08:00
|
|
|
<ui:AppBarButton.Icon>
|
2025-06-23 17:01:06 +08:00
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Edit}" />
|
2025-06-22 21:00:06 +08:00
|
|
|
</ui:AppBarButton.Icon>
|
2025-07-01 21:34:20 +08:00
|
|
|
</ui:AppBarButton>
|
2025-08-24 18:29:26 +08:00
|
|
|
<!-- 编辑设备 -->
|
|
|
|
|
<ui:AppBarButton Command="{Binding DeleteDeviceCommand}" Label="删除设备">
|
2025-07-01 21:34:20 +08:00
|
|
|
<ui:AppBarButton.Icon>
|
|
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Delete}" />
|
|
|
|
|
</ui:AppBarButton.Icon>
|
2025-06-22 21:00:06 +08:00
|
|
|
</ui:AppBarButton>
|
2025-08-24 18:29:26 +08:00
|
|
|
<ui:AppBarButton x:Name="ShareButton" Label="Share">
|
2025-06-22 21:00:06 +08:00
|
|
|
<ui:AppBarButton.Icon>
|
2025-06-23 17:01:06 +08:00
|
|
|
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Share}" />
|
2025-06-22 21:00:06 +08:00
|
|
|
</ui:AppBarButton.Icon>
|
|
|
|
|
</ui:AppBarButton>
|
|
|
|
|
<ui:CommandBar.SecondaryCommands>
|
2025-08-24 18:29:26 +08:00
|
|
|
<ui:AppBarButton
|
|
|
|
|
x:Name="SettingsButton"
|
|
|
|
|
Icon="Setting"
|
|
|
|
|
Label="Settings" />
|
2025-06-22 21:00:06 +08:00
|
|
|
</ui:CommandBar.SecondaryCommands>
|
|
|
|
|
</ui:CommandBar>
|
2025-06-23 17:01:06 +08:00
|
|
|
|
|
|
|
|
|
2025-08-24 18:29:26 +08:00
|
|
|
<ui:GridView
|
|
|
|
|
x:Name="BasicGridView"
|
|
|
|
|
Margin="20"
|
|
|
|
|
IsItemClickEnabled="True"
|
|
|
|
|
ItemTemplate="{StaticResource DeviceItemTemplate}"
|
|
|
|
|
ItemsSource="{Binding DataServices.Devices}"
|
|
|
|
|
SelectedItem="{Binding SelectedDevice}"
|
|
|
|
|
SelectionMode="Single">
|
2025-07-16 18:39:00 +08:00
|
|
|
<hc:Interaction.Triggers>
|
|
|
|
|
<hc:EventTrigger EventName="MouseDoubleClick">
|
|
|
|
|
<hc:InvokeCommandAction Command="{Binding NavigateToDetailCommand}" />
|
|
|
|
|
</hc:EventTrigger>
|
|
|
|
|
</hc:Interaction.Triggers>
|
|
|
|
|
</ui:GridView>
|
2025-06-10 22:13:06 +08:00
|
|
|
</StackPanel>
|
2025-06-23 17:01:06 +08:00
|
|
|
|
|
|
|
|
</UserControl>
|