Files
WCS/Plugins/Driver/Cowain.Driver/Views/DeviceManagementView.axaml
2026-03-02 09:08:20 +08:00

154 lines
6.8 KiB
XML

<UserControl xmlns="https://github.com/avaloniaui"
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:semi="https://irihi.tech/semi"
xmlns:u="https://irihi.tech/ursa"
xmlns:i18n="clr-namespace:Ke.Bee.Localization.Extensions;assembly=Ke.Bee.Localization"
xmlns:vm="using:Plugin.Cowain.Driver.ViewModels"
xmlns:conv="using:Cowain.Base.Converters"
xmlns:extensions="using:Cowain.Base.Extensions"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:DataType="vm:DeviceManagementViewModel"
x:Class="Plugin.Cowain.Driver.Views.DeviceManagementView">
<UserControl.Resources>
<conv:I18nLocalizeConverter x:Key="i18nConverter" />
</UserControl.Resources>
<Grid RowDefinitions="Auto * Auto">
<StackPanel Grid.Row="0" Orientation="Horizontal" Spacing="10" Margin="10 8">
<u:IconButton
ToolTip.Tip="{i18n:Localize DeviceManagement.Tooltip.Add}"
IsEnabled="{extensions:MenuEnable DeviceManagementView,add}"
Command="{Binding AddDeviceCommand}"
Theme="{DynamicResource BorderlessIconButton}">
<u:IconButton.Icon>
<PathIcon
Width="16"
Height="16"
Data="{StaticResource SemiIconPlusStroked}" />
</u:IconButton.Icon>
</u:IconButton>
<u:IconButton
ToolTip.Tip="{i18n:Localize DeviceManagement.Tooltip.Refresh}"
Command="{Binding RefreshCommand}"
CommandParameter="{Binding #page.CurrentPage}"
Theme="{DynamicResource BorderlessIconButton}">
<u:IconButton.Icon>
<PathIcon
Width="16"
Height="16"
Data="{StaticResource SemiIconRedoStroked}" />
</u:IconButton.Icon>
</u:IconButton>
<u:IconButton
ToolTip.Tip="{i18n:Localize DeviceManagement.Tooltip.Export}"
Theme="{DynamicResource BorderlessIconButton}">
<u:IconButton.Icon>
<PathIcon
Width="16"
Height="16"
Data="{StaticResource SemiIconExternalOpenStroked}" />
</u:IconButton.Icon>
</u:IconButton>
</StackPanel>
<DataGrid Grid.Row="1" FrozenColumnCount="2"
CanUserReorderColumns="True"
CanUserResizeColumns="True"
CanUserSortColumns="True"
HeadersVisibility="All"
RowHeight="30"
IsReadOnly="True"
ItemsSource="{Binding Devices}"
HorizontalScrollBarVisibility="Auto">
<DataGrid.Columns>
<DataGridTextColumn Width="80"
x:DataType="vm:DeviceViewModel"
Binding="{Binding Id}"
IsReadOnly="True"
Header="{i18n:Localize DeviceManagement.DataGrid.Id}" />
<DataGridTemplateColumn
Header="{i18n:Localize DeviceManagement.DataGrid.Edit}"
Width="100">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Spacing="10">
<u:IconButton
ToolTip.Tip="{i18n:Localize DeviceManagement.Tooltip.Edit}"
x:CompileBindings="False"
IsEnabled="{extensions:MenuEnable DeviceManagementView,edit}"
Command="{Binding $parent[DataGrid].DataContext.EditDeviceCommand}"
CommandParameter="{Binding}"
Theme="{DynamicResource BorderlessIconButton}">
<u:IconButton.Icon>
<PathIcon Width="16" Height="16" Data="{StaticResource SemiIconEdit2Stroked}" />
</u:IconButton.Icon>
</u:IconButton>
<u:IconButton
ToolTip.Tip="{i18n:Localize DeviceManagement.Tooltip.Delete}"
x:CompileBindings="False"
IsEnabled="{extensions:MenuEnable DeviceManagementView,delete}"
Command="{Binding $parent[DataGrid].DataContext.DeleteDeviceCommand}"
CommandParameter="{Binding}"
Theme="{DynamicResource BorderlessIconButton}">
<u:IconButton.Icon>
<PathIcon Width="16" Height="16" Data="{StaticResource SemiIconDeleteStroked}" />
</u:IconButton.Icon>
</u:IconButton>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Width="140"
x:DataType="vm:DeviceViewModel"
Binding="{Binding DeviceName}"
IsReadOnly="True"
Header="{i18n:Localize DeviceManagement.DataGrid.DeviceName}" />
<DataGridTextColumn Width="140"
x:DataType="vm:DeviceViewModel"
Binding="{Binding DriverName}"
IsReadOnly="True"
Header="{i18n:Localize DeviceManagement.DataGrid.DriverName}" />
<DataGridTextColumn Width="120"
x:DataType="vm:DeviceViewModel"
Binding="{Binding DeviceType}"
IsReadOnly="True"
Header="{i18n:Localize DeviceManagement.DataGrid.DeviceType}" />
<DataGridTemplateColumn
Header="{i18n:Localize DeviceManagement.DataGrid.Param}"
Width="300">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{i18n:Localize DeviceManagement.DataGrid.Param.Placeholder}"
IsReadOnly="True"
ToolTip.Tip="{Binding Param}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Width="200"
x:DataType="vm:DeviceViewModel"
Binding="{Binding Desc}"
IsReadOnly="True"
Header="{i18n:Localize DeviceManagement.DataGrid.Desc}" />
<DataGridTextColumn Width="60"
x:DataType="vm:DeviceViewModel"
Binding="{Binding Enable}"
IsReadOnly="True"
Header="{i18n:Localize DeviceManagement.DataGrid.Enable}" />
</DataGrid.Columns>
</DataGrid>
<u:Pagination Grid.Row="2"
Name="page"
PageSizeOptions="10, 20, 50, 100"
ShowQuickJump="True"
ShowPageSizeSelector="True"
PageSize="{Binding PageSize,Mode=TwoWay}"
CurrentPage="{Binding PageIndex,Mode=TwoWay}"
Command="{Binding RefreshCommand}"
CommandParameter="{Binding $self.CurrentPage}"
TotalCount="{Binding Totals}" />
</Grid>
</UserControl>