CommunicationPage.xaml 6.07 KB
<Page x:Class="HHECS.DAQClient.View.CommunicationView.CommunicationPage"
      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.CommunicationView"
      xmlns:hc="https://handyorg.github.io/handycontrol"
      mc:Ignorable="d" 
      xmlns:viewmodel="clr-namespace:HHECS.DAQClient.ViewModel.CommunicationVM"
      d:DataContext="{d:DesignInstance Type=viewmodel:CommunicationVM}"
      d:DesignHeight="450" d:DesignWidth="800"
      Title="CommunicationPage">

    <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 Code,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 Name,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 CommunicationTypes}" DisplayMemberPath="Key" SelectedValuePath="Value" SelectedValue="{Binding CommunicationType}" Style="{StaticResource ComboBoxExtend}" />
                </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 CommunicationConfigs}">
            <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 CommunicationType}" Header="类型"/>
                <DataGridTextColumn Binding="{Binding IpAddress}" Header="IP地址"/>
                <DataGridTextColumn Binding="{Binding Port}" Header="端口号"/>
                <DataGridTextColumn Binding="{Binding Disable}" Header="是否禁用"/>
                <DataGridTextColumn Binding="{Binding Remark}" Header="备注"/>
                <DataGridTextColumn Binding="{Binding CreateTIme, StringFormat={}{0:yyyy/MM/dd HH:mm:ss}}" Header="创建时间"/>
                <DataGridTextColumn Binding="{Binding UpdatedTime, StringFormat={}{0:yyyy/MM/dd HH:mm:ss}}" Header="修改时间"/>
                <DataGridTemplateColumn Header="操作">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <hc:UniformSpacingPanel Spacing="5">
                                <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>