EquipmentPage.xaml 8.72 KB
<Page
    x:Class="HHECS.DAQClient.View.EquipmentView.EquipmentPage"
    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:local="clr-namespace:HHECS.DAQClient.View.EquipmentView"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewmodel="clr-namespace:HHECS.DAQClient.ViewModel.EquipmentVM"
    Title="EquipmentPage"
    d:DataContext="{d:DesignInstance Type=viewmodel:EquipmentVM}"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">
    <DockPanel>
        <StackPanel DockPanel.Dock="Top">
            <hc:UniformSpacingPanel Spacing="10">
                <hc:ElementGroup
                    Height="30"
                    Margin="0,1"
                    VerticalAlignment="Center"
                    Layout="Stack">
                    <Border Padding="6,0" Style="{StaticResource BorderRegion}">
                        <TextBlock
                            Width="50"
                            VerticalAlignment="Center"
                            Text="设备编号" />
                    </Border>
                    <TextBox MinWidth="150" Text="{Binding EquipmentCode, UpdateSourceTrigger=PropertyChanged}" />
                </hc:ElementGroup>
                <hc:ElementGroup
                    Height="30"
                    VerticalAlignment="Center"
                    Layout="Stack">
                    <Border Padding="6,0" Style="{StaticResource BorderRegion}">
                        <TextBlock
                            Width="50"
                            VerticalAlignment="Center"
                            Text="设备名称" />
                    </Border>
                    <TextBox MinWidth="150" Text="{Binding EquipmentName, UpdateSourceTrigger=PropertyChanged}" />
                </hc:ElementGroup>
                <hc:ElementGroup
                    Height="30"
                    VerticalAlignment="Center"
                    Layout="Stack">
                    <Border Padding="6,0" Style="{StaticResource BorderRegion}">
                        <TextBlock
                            Width="50"
                            VerticalAlignment="Center"
                            Text="设备类型" />
                    </Border>
                    <hc:ComboBox
                        MinWidth="150"
                        MaxWidth="200"
                        DisplayMemberPath="Value"
                        ItemsSource="{Binding EquipmentTypes}"
                        SelectedValue="{Binding EquipmentTypeId}"
                        SelectedValuePath="Key"
                        Style="{StaticResource ComboBoxExtend}" />
                </hc:ElementGroup>
                <hc:ElementGroup
                    Height="30"
                    VerticalAlignment="Center"
                    Layout="Stack">
                    <Border Padding="6,0" Style="{StaticResource BorderRegion}">
                        <TextBlock
                            Width="50"
                            VerticalAlignment="Center"
                            Text="区域" />
                    </Border>
                    <TextBox MinWidth="150" Text="{Binding DestinationArea, UpdateSourceTrigger=PropertyChanged}" />
                </hc:ElementGroup>
            </hc:UniformSpacingPanel>
            <ToolBar
                Margin="0,1"
                Padding="4"
                HorizontalAlignment="Right">
                <hc:UniformSpacingPanel Spacing="5">
                    <Button
                        hc:IconElement.Geometry="{StaticResource SearchGeometry}"
                        Command="{Binding SerachCommand}"
                        Content="搜索"
                        Style="{StaticResource ButtonDefault}" />
                    <Button
                        hc:IconElement.Geometry="{StaticResource AddGeometry}"
                        Command="{Binding AddCommand}"
                        Content="新增"
                        Style="{StaticResource ButtonDefault}" />
                    <Button
                        hc:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}"
                        Command="{Binding BatchDeleteCommand}"
                        CommandParameter="{Binding ElementName=DG, Path=SelectedItems}"
                        Content="批量删除"
                        Style="{StaticResource ButtonDanger}" />
                </hc:UniformSpacingPanel>
            </ToolBar>
        </StackPanel>
        <hc:Pagination
            DataCountPerPage="{Binding PageSize}"
            DockPanel.Dock="Bottom"
            IsJumpEnabled="True"
            MaxPageCount="{Binding MaxPage}"
            PageIndex="{Binding PageIndex}">
            <hc:Interaction.Triggers>
                <hc:EventTrigger EventName="PageUpdated">
                    <hc:EventToCommand Command="{Binding PageUpdatedCommand}" PassEventArgsToCommand="True" />
                </hc:EventTrigger>
            </hc:Interaction.Triggers>
        </hc:Pagination>
        <DataGrid
            Name="DG"
            hc:DataGridAttach.CanUnselectAllWithBlankArea="True"
            AutoGenerateColumns="False"
            HeadersVisibility="All"
            IsReadOnly="True"
            ItemsSource="{Binding Equipments}"
            RowHeaderWidth="60"
            Style="{StaticResource DataGrid.Small}">
            <DataGrid.RowHeaderTemplate>
                <DataTemplate>
                    <CheckBox IsChecked="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow}}" />
                </DataTemplate>
            </DataGrid.RowHeaderTemplate>
            <DataGrid.Columns>
                <DataGridTextColumn
                    Binding="{Binding Id}"
                    Header="Id"
                    Visibility="Hidden" />
                <DataGridTextColumn Binding="{Binding Code}" Header="编号" />
                <DataGridTextColumn Binding="{Binding Name}" Header="名称" />
                <DataGridTextColumn Binding="{Binding EquipmentType.Name}" Header="设备类型名称" />
                <DataGridTextColumn Binding="{Binding IP}" Header="IP地址" />
                <DataGridTextColumn Binding="{Binding ConnectName}" Header="连接名称" />
                <DataGridTextColumn Binding="{Binding DestinationArea}" Header="区域" />
                <DataGridTextColumn Binding="{Binding Disable}" Header="是否禁用" />
                <DataGridTextColumn Binding="{Binding Description}" Header="描述" />
                <DataGridTextColumn Binding="{Binding Created, StringFormat={}{0:yyyy/MM/dd HH:mm:ss}}" Header="创建时间" />
                <DataGridTextColumn Binding="{Binding Updated, StringFormat={}{0:yyyy/MM/dd HH:mm:ss}}" Header="修改时间" />
                <DataGridTemplateColumn Header="操作">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <hc:UniformSpacingPanel Spacing="5">
                                <Button
                                    hc:IconElement.Geometry="{StaticResource InfoGeometry}"
                                    Command="{Binding DataContext.DetailCommand, RelativeSource={RelativeSource AncestorType=DataGrid}}"
                                    CommandParameter="{Binding}"
                                    Content="详细"
                                    Style="{StaticResource ButtonDefault.Small}" />
                                <Button
                                    hc:IconElement.Geometry="{StaticResource DropperGeometry}"
                                    Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=DataGrid}}"
                                    CommandParameter="{Binding Id}"
                                    Content="编辑"
                                    Style="{StaticResource ButtonDefault.Small}" />
                                <Button
                                    hc:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}"
                                    Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource AncestorType=DataGrid}}"
                                    CommandParameter="{Binding Id}"
                                    Content="删除"
                                    Style="{StaticResource ButtonDanger.Small}" />
                            </hc:UniformSpacingPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </DockPanel>
</Page>