<UserControl x:Class="CANModule.Views.ZLGCANFDView"
                        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:CANModule.Views"
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             mc:Ignorable="d"
             xmlns:prism="http://prismlibrary.com/"
             xmlns:cons="clr-namespace:UIShare.Converters;assembly=UIShare"
             Background="White"
             prism:ViewModelLocator.AutoWireViewModel="True"
             Height="850"
             Width="900">
    <prism:Dialog.WindowStyle>
        <Style BasedOn="{StaticResource DialogUserManageStyle}"
               TargetType="Window" />
    </prism:Dialog.WindowStyle>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <i:InvokeCommandAction Command="{Binding LoadCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <UserControl.Resources>
        <cons:HexConverter x:Key="HexConverter" />
    </UserControl.Resources>
    <GroupBox Padding="0,0,0,0"
              >
        <GroupBox.Header>
            <Grid  Margin="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <TextBlock Text="CAN手动设置"
                           Foreground="White"
                           VerticalAlignment="Center"
                           Margin="5,0,10,0" />
           
            </Grid>
        </GroupBox.Header>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <!-- CAN卡连接 -->
            <StackPanel Orientation="Horizontal"
                        Margin="5"
                        Grid.Row="0">
                <Button Content="打开设备"
                        Command="{Binding ConnectCanCommand}"
                        Margin="5" />
                <Button Content="关闭设备"
                        Command="{Binding CloseCanCommand}"
                        Margin="5" />
                <Button Content="清空循环发送报文"
                        Command="{Binding ClearCycleCommand}"
                        Margin="5" />
         
            </StackPanel>
            <StackPanel Orientation="Horizontal"
                Margin="5"
                Grid.Row="1">
                <Label Content="选择通道初始化(选择前先打开设备)"
              VerticalAlignment="Center" />
                <ComboBox SelectedItem="{Binding SelectedChannel}"
                 ItemsSource="{Binding ChannelList}"
                 materialDesign:HintAssist.Hint=""
                 MinWidth="80"
                 Margin="5"
                 VerticalAlignment="Center" />
            </StackPanel>
            <TreeView Grid.Row="2">
                <!-- 监视选项 -->
                <TreeViewItem Header="监视">
                    <DataGrid x:Name="表格"
                              Width="550"
                              Height="350"
                              VirtualizingPanel.IsVirtualizing="True"
                              IsReadOnly="True"
                              AutoGenerateColumns="False"
                              ItemsSource="{Binding CanMessageList, Mode=OneWay}">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="通道" Binding="{Binding 通道}" Width="90" />
                            <DataGridTextColumn Header="报文ID" Binding="{Binding 报文ID, Converter={StaticResource HexConverter}}" Width="150" />
                            <DataGridTextColumn Header="长度" Binding="{Binding 长度}" Width="90" />
                            <DataGridTextColumn Header="时间戳" Binding="{Binding 时间戳}" Width="Auto" />
                        </DataGrid.Columns>
                    </DataGrid>
                </TreeViewItem>

                <!-- DBC 配置 -->
                <TreeViewItem Header="DBC">
                    <Label Content="请注意,要在断开CAN卡的情况下才能操作DBC!"
                           Foreground="Red" />
                    <Button Content="卸载当前通道DBC"
                            Command="{Binding UpLoadDBCCommand}" />
                    <StackPanel Orientation="Horizontal">
                        <Button Content="更换DBC"
                                Command="{Binding ChangeDBCCommand}" />
                        <Label Content="DBC文件路径"
                               VerticalContentAlignment="Center" />
                        <TextBox Text="{Binding DBCPath,Mode=TwoWay}"
                                 MinWidth="100"
                                 materialDesign:HintAssist.Hint=""
                                 VerticalAlignment="Center" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <Button Content="加载DBC"
                                Command="{Binding LoadDBCCommand}" />
                        <Label Content="通道(从0开始)"
                               VerticalContentAlignment="Center" />
                        <TextBox Text="{Binding DBCChannel,Mode=TwoWay}"
                                 materialDesign:HintAssist.Hint=""
                                 MinWidth="100"
                                 VerticalAlignment="Center" />
                        <CheckBox Margin="5 0 0 0"
                                  IsChecked="{Binding IsSaved}" />
                        <Label Content="加载记录保存"
                               VerticalContentAlignment="Center" />
                    </StackPanel>
                    <DataGrid ItemsSource="{Binding DBCAutoLoadList}"
                              Width="650"
                              IsReadOnly="True"
                              AutoGenerateColumns="False"
                              SelectedItem="{Binding SelectedDcAutoLoad}">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="通道"
                                                Binding="{Binding DBCChannel}"
                                                Width="60" />
                            <DataGridTextColumn Header="文件路径"
                                                Binding="{Binding DBCFilePath}"
                                                Width="*" />
                        </DataGrid.Columns>
                        <DataGrid.ContextMenu>
                            <ContextMenu>
                                <MenuItem Header="删除"
                                          Foreground="Red"
                                          Command="{Binding DeleteDcAutoLoadCommand}" />
                            </ContextMenu>
                        </DataGrid.ContextMenu>
                    </DataGrid>
                </TreeViewItem>

                <!-- DBC报文发送 -->
                <TreeViewItem Header="DBC报文发送">
                    <StackPanel Orientation="Horizontal">
                        <Label Content="通道(从0开始)"
                               VerticalContentAlignment="Center" />
                        <ComboBox SelectedValue="{Binding MessageSendChannel}"
          SelectedValuePath="Content"
          materialDesign:HintAssist.Hint=""
          MinWidth="60"
          VerticalAlignment="Center"
          Margin="0,5,5,5">
                            <ComboBoxItem Content="0"/>
                            <ComboBoxItem Content="1"/>
                            <ComboBoxItem Content="2"/>
                            <ComboBoxItem Content="3"/>
                        </ComboBox>
                        <Button Content="加载报文"
                                Command="{Binding LoadMessageCommand}"
                                Margin="5" />
                    </StackPanel>
                    <DockPanel>
                        <Label Content="报文" />
                        <ComboBox MinWidth="100"
                                  materialDesign:HintAssist.Hint=""
                                  SelectedItem="{Binding SelectedMessage}"
                                  ItemsSource="{Binding Message}" />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="信号" />
                        <ComboBox SelectedItem="{Binding SelectedSignal}"
                                  ItemsSource="{Binding Signal}"
                                  materialDesign:HintAssist.Hint=""
                                  MinWidth="100" />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="信号值" />
                        <TextBox Text="{Binding SignalValue}"
                                 materialDesign:HintAssist.Hint=""
                                 MinWidth="100" />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="循环发送时间间隔(ms)(0为单次发送)" />
                        <TextBox Text="{Binding CycleSendInterval}"
                                 materialDesign:HintAssist.Hint=""
                                 MinWidth="100" />
                    </DockPanel>
                    <StackPanel Orientation="Horizontal">
                        <Button Content="设置信号并发送"
                                Command="{Binding SetAndSendMessageCommand}" />
                        <CheckBox Content="直接发送"
                                  IsChecked="{Binding IsDirectlySend}" />
                    </StackPanel>
                </TreeViewItem>

                <!-- 自定义报文发送 -->
                <TreeViewItem Header="自定义报文发送">
                    <DockPanel>
                        <Label Content="通道" />
                        <ComboBox MinWidth="100"
                                  materialDesign:HintAssist.Hint=""
                                  SelectedItem="{Binding AIdxChn}"
                                  ItemsSource="{Binding APP_CHANNEL}" />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="ID" />
                        <TextBox MinWidth="100"
                                 materialDesign:HintAssist.Hint=""
                                 Text="{Binding AID, Converter={StaticResource HexConverter}, Mode=TwoWay}" />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="DLC" />
                        <TextBox MinWidth="200"
                                 materialDesign:HintAssist.Hint=""
                                 Text="{Binding ADLC}" />
                        <CheckBox Content="自动设定"
                                  IsChecked="{Binding AutoSetting}" />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="报文" />
                        <TextBox MinWidth="200"
                                 materialDesign:HintAssist.Hint=""
                                 Text="{Binding CustomMessage}" />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="循环发送时间间隔(ms)(0为单次发送)" />
                        <TextBox Text="{Binding CustomSendCycleInterval}"
                                 materialDesign:HintAssist.Hint=""
                                 MinWidth="100" />
                    </DockPanel>
                    <StackPanel Orientation="Horizontal">
                        <CheckBox Content="发送帧"
                                  IsChecked="{Binding AIsTx}" />
                        <CheckBox Content="扩展帧"
                                  IsChecked="{Binding AIsExt}" />
                        <CheckBox Content="远程帧"
                                  IsChecked="{Binding AIsRemote}" />
                        <CheckBox Content="FD"
                                  IsChecked="{Binding AIsFD}" />
                        <CheckBox Content="BRS"
                                  IsChecked="{Binding AIsBRS}" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <Button Content="发送"
                                Command="{Binding SendCustomMessageCommand}" />
                        <!--<CheckBox Margin="10"
                                  Content="更新到数据库"
                                  IsChecked="{Binding UpdateToDB}" />-->
                    </StackPanel>
                </TreeViewItem>

                <!-- 报文录制 -->
                <TreeViewItem Header="报文录制">
                    <DockPanel>
                        <Label Content="路径(开始录制时使用)"
                               VerticalContentAlignment="Center" />
                        <TextBox MinWidth="100"
                                 materialDesign:HintAssist.Hint=""
                                 Text="{Binding BLFPath}"
                                 VerticalContentAlignment="Center" />
                        <Button Content="选择路径"
                                Margin="10 0"
                                Command="{Binding SelectBLFPathCommand}" />
                        <Button Content="保存路径"
                                Command="{Binding SaveBLFPathCommand}" />
                    </DockPanel>
                    <StackPanel Orientation="Horizontal">
                        <Button Content="开始录制"
                                Command="{Binding StartTranscribeCommand}" />
                        <Button Content="结束录制"
                                Margin="10 0"
                                Command="{Binding EndTranscribeCommand}" />
                    </StackPanel>
                </TreeViewItem>
            </TreeView>
        </Grid>
    </GroupBox>
</UserControl>
