EquipmentPage.xaml 6.79 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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:HHECS.DAQClient.View.EquipmentView"
      xmlns:hc="https://handyorg.github.io/handycontrol"
      mc:Ignorable="d" 
      xmlns:viewmodel="clr-namespace:HHECS.DAQClient.ViewModel.EquipmentVM"
      d:DataContext="{d:DesignInstance Type=viewmodel:EquipmentVM}"
      d:DesignHeight="450" d:DesignWidth="800"
      Title="EquipmentPage">
    <DockPanel>
        <StackPanel DockPanel.Dock="Top">
            <hc:UniformSpacingPanel Spacing="10">
                <hc:ElementGroup VerticalAlignment="Center" Height="30" Margin="0,1" Layout="Stack">
                    <Border Style="{StaticResource BorderRegion}" Padding="6,0">
                        <TextBlock Text="设备编号" Width="50" VerticalAlignment="Center"/>
                    </Border>
                    <TextBox Text="{Binding EquipmentCode,UpdateSourceTrigger=PropertyChanged}" MinWidth="150"/>
                </hc:ElementGroup>
                <hc:ElementGroup VerticalAlignment="Center" Height="30" Layout="Stack">
                    <Border Style="{StaticResource BorderRegion}" Padding="6,0">
                        <TextBlock Text="设备名称" Width="50" VerticalAlignment="Center"/>
                    </Border>
                    <TextBox Text="{Binding EquipmentName,UpdateSourceTrigger=PropertyChanged}" MinWidth="150"/>
                </hc:ElementGroup>
                <hc:ElementGroup VerticalAlignment="Center" Height="30" Layout="Stack">
                    <Border Style="{StaticResource BorderRegion}" Padding="6,0">
                        <TextBlock Text="设备类型" Width="50" VerticalAlignment="Center"/>
                    </Border>
                    <hc:ComboBox MinWidth="150" MaxWidth="200" ItemsSource="{Binding EquipmentTypes}" DisplayMemberPath="Key" SelectedValuePath="Value" SelectedValue="{Binding EquipmentTypeId}" Style="{StaticResource ComboBoxExtend}" />
                </hc:ElementGroup>
                <hc:ElementGroup VerticalAlignment="Center" Height="30" Layout="Stack">
                    <Border Style="{StaticResource BorderRegion}" Padding="6,0">
                        <TextBlock Text="区域" Width="50" VerticalAlignment="Center"/>
                    </Border>
                    <TextBox Text="{Binding DestinationArea,UpdateSourceTrigger=PropertyChanged}" MinWidth="150"/>
                </hc:ElementGroup>
            </hc:UniformSpacingPanel>
            <ToolBar Padding="4" Margin="0,1" HorizontalAlignment="Right">
                <hc:UniformSpacingPanel Spacing="5">
                    <Button Content="搜索" Command="{Binding SerachCommand}" Style="{StaticResource ButtonDefault}" hc:IconElement.Geometry="{StaticResource SearchGeometry}"/>
                    <Button Content="新增" Command="{Binding AddCommand}" Style="{StaticResource ButtonDefault}" hc:IconElement.Geometry="{StaticResource AddGeometry}"/>
                    <Button Content="批量删除" Command="{Binding BatchDeleteCommand}" CommandParameter="{Binding ElementName=DG,Path=SelectedItems}" Style="{StaticResource ButtonDanger}" hc:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}"/>
                </hc:UniformSpacingPanel>
            </ToolBar>
        </StackPanel>
        <hc:Pagination DockPanel.Dock="Bottom" MaxPageCount="{Binding MaxPage}" PageIndex="{Binding PageIndex}" DataCountPerPage="{Binding PageSize}" IsJumpEnabled="True">
            <hc:Interaction.Triggers>
                <hc:EventTrigger EventName="PageUpdated">
                    <hc:EventToCommand Command="{Binding PageUpdatedCommand}" PassEventArgsToCommand="True" />
                </hc:EventTrigger>
            </hc:Interaction.Triggers>
        </hc:Pagination>
        <DataGrid Name="DG" Style="{StaticResource DataGrid.Small}" IsReadOnly="True" hc:DataGridAttach.CanUnselectAllWithBlankArea="True" HeadersVisibility="All" RowHeaderWidth="60" AutoGenerateColumns="False" ItemsSource="{Binding Equipments}">
            <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 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 Content="详细" Command="{Binding DataContext.DetailCommand,RelativeSource={RelativeSource AncestorType=DataGrid}}" CommandParameter="{Binding}" Style="{StaticResource ButtonDefault.Small}" hc:IconElement.Geometry="{StaticResource InfoGeometry}"/>
                                <Button Content="编辑" Command="{Binding DataContext.EditCommand,RelativeSource={RelativeSource AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Style="{StaticResource ButtonDefault.Small}" hc:IconElement.Geometry="{StaticResource DropperGeometry}"/>
                                <Button Content="删除" Command="{Binding DataContext.DeleteCommand,RelativeSource={RelativeSource AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Style="{StaticResource ButtonDanger.Small}" hc:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}"/>
                            </hc:UniformSpacingPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </DockPanel>
</Page>