完成编辑设备和删除设备

This commit is contained in:
2025-07-01 21:34:20 +08:00
parent 0110ba9492
commit 663e4fda0c
23 changed files with 504 additions and 235 deletions

View File

@@ -8,18 +8,26 @@
xmlns:vm="clr-namespace:PMSWPF.ViewModels"
d:DataContext="{d:DesignInstance vm:DevicesViewModel}"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
d:DesignHeight="300"
d:DesignWidth="300">
<UserControl.Resources>
<DataTemplate x:Key="DeviceItemTemplate">
<Border Background="#eee" CornerRadius="10" Margin="3" Padding="10">
<ikw:SimpleStackPanel Spacing="10" Width="300" Height="200">
<Border Background="#eee"
CornerRadius="10"
Margin="3"
Padding="10">
<ikw:SimpleStackPanel Spacing="10"
Width="300"
Height="200">
<DockPanel>
<ui:ToggleSwitch
DockPanel.Dock="Right"
Margin="20 0 0 0 "
IsOn="{Binding IsActive}"
OffContent="停止" OnContent="启动" />
<TextBlock FontSize="24" FontWeight="Bold" Text="{Binding Name }" />
<ui:ToggleSwitch DockPanel.Dock="Right"
Margin="20 0 0 0 "
IsOn="{Binding IsActive}"
OffContent="停止"
OnContent="启动" />
<TextBlock FontSize="24"
FontWeight="Bold"
Text="{Binding Name }" />
</DockPanel>
<TextBlock Text="{Binding Description }" />
@@ -38,22 +46,29 @@
</UserControl.Resources>
<StackPanel>
<ui:CommandBar x:Name="PrimaryCommandBar"
DefaultLabelPosition="Right" IsOpen="False">
<ui:AppBarButton x:Name="AddButton"
Command="{Binding AddDeviceCommand}"
Label="Add">
<!-- 操作菜单栏 -->
<ui:CommandBar DefaultLabelPosition="Right"
IsOpen="False">
<!-- 添加设备 -->
<ui:AppBarButton Command="{Binding AddDeviceCommand}"
Label="添加设备">
<ui:AppBarButton.Icon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" />
</ui:AppBarButton.Icon>
</ui:AppBarButton>
<ui:AppBarButton x:Name="EditButton"
Label="Edit">
<!-- 编辑设备 -->
<ui:AppBarButton Command="{Binding EditDeviceCommand}"
Label="编辑设备">
<ui:AppBarButton.Icon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Edit}" />
</ui:AppBarButton.Icon>
</ui:AppBarButton>
<!-- 编辑设备 -->
<ui:AppBarButton Command="{Binding DeleteDeviceCommand}"
Label="删除设备">
<ui:AppBarButton.Icon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Delete}" />
</ui:AppBarButton.Icon>
</ui:AppBarButton>
<ui:AppBarButton x:Name="ShareButton"
Label="Share">
@@ -63,8 +78,8 @@
</ui:AppBarButton>
<ui:CommandBar.SecondaryCommands>
<ui:AppBarButton x:Name="SettingsButton"
Icon="Setting" Label="Settings" />
Icon="Setting"
Label="Settings" />
</ui:CommandBar.SecondaryCommands>
</ui:CommandBar>
@@ -72,7 +87,7 @@
<ui:GridView x:Name="BasicGridView"
Margin="20"
IsItemClickEnabled="True"
ItemClick="BasicGridView_ItemClick"
SelectedItem="{Binding SelectedDevice }"
ItemsSource="{Binding Devices}"
ItemTemplate="{StaticResource DeviceItemTemplate}"
SelectionMode="Single" />