<UserControl x:Class="BOB.Views.Dialogs.CANView"
             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:BOB.Views.Dialogs"
             xmlns:oxy="http://oxyplot.org/wpf"
             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:BOB.Converters"
             xmlns:ucs="clr-namespace:BOB.Views.UserControls"
             Background="White"
             prism:ViewModelLocator.AutoWireViewModel="True"
             Height="850"
             Width="900">
    <prism:Dialog.WindowStyle>
        <Style BasedOn="{StaticResource DialogUserManageStyle}"
               TargetType="Window" />
    </prism:Dialog.WindowStyle>
    <UserControl.Resources>
        <cons:HexConverter x:Key="HexConverter" />
    </UserControl.Resources>
    <GroupBox Header="CAN手动设置"
              Padding="0,0,0,0"
              MouseLeftButtonDown="MouseLeftButtonDown">

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <!-- TreeView 用于显示不同选项 -->
            <TreeView Grid.Row="1">
                <!-- 调试选项 -->
                <TreeViewItem Header="调试选项"
                              Visibility="{Binding 高级模式可见度}">
                    <Button Content="初始化TSMaster"
                            Command="{Binding ButtonClickCommand}"
                            CommandParameter="初始化TSMaster" />
                    <Button Content="释放TSMaster"
                            Command="{Binding ButtonClickCommand}"
                            CommandParameter="释放TSMaster" />
                    <Button Content="注册监听事件"
                            Command="{Binding ButtonClickCommand}"
                            CommandParameter="注册监听事件" />
                </TreeViewItem>

                <!-- 监视选项 -->
                <TreeViewItem Header="监视">
                    <Frame x:Name="监视Frame"
                           Height="400"
                           Width="700" />
                </TreeViewItem>

                <!-- DBC 配置 -->
                <TreeViewItem Header="DBC">
                    <Label Content="请注意,要在断开CAN卡的情况下才能操作DBC!"
                           Foreground="Red" />
                    <Button Content="卸载所有DBC"
                            Command="{Binding ButtonClickCommand}"
                            CommandParameter="卸载DBC" />
                    <StackPanel Orientation="Horizontal">
                        <Button Margin="0 0 10 0"
                                Content="更换DBC"
                                Command="{Binding ButtonClickCommand}"
                                CommandParameter="更换DBC" />
                        <Button Content="加载DBC"
                                Command="{Binding ButtonClickCommand}"
                                CommandParameter="加载DBC" />
                        <Label Content="通道(从0开始)"
                               VerticalContentAlignment="Center" />
                        <TextBox Text="{Binding DBC加载通道}"
                                 MinWidth="100"
                                 VerticalAlignment="Center" />
                    </StackPanel>
                    <Button Content="查看DBC"
                            Command="{Binding ButtonClickCommand}"
                            CommandParameter="查看DBC" />
                </TreeViewItem>

                <!-- CAN卡连接选项 -->
                <TreeViewItem Header="CAN卡连接">
                    <Button Content="连接"
                            Command="{Binding ButtonClickCommand}"
                            CommandParameter="连接" />
                    <Button Content="断开"
                            Command="{Binding ButtonClickCommand}"
                            CommandParameter="断开" />
                    <Button Content="清空循环发送报文"
                            Command="{Binding ButtonClickCommand}"
                            CommandParameter="清空循环发送报文" />
                    <Button Content="硬件配置"
                            Command="{Binding ButtonClickCommand}"
                            CommandParameter="硬件配置" />
                </TreeViewItem>

                <!-- DBC报文发送 -->
                <TreeViewItem Header="DBC报文发送">
                    <DockPanel>
                        <Label Content="报文" />
                        <ComboBox MinWidth="100"
                                  SelectedIndex="{Binding 选中报文}"
                                  ItemsSource="{Binding 报文}"
                                   />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="信号" />
                        <ComboBox SelectedIndex="{Binding 选中信号}"
                                  ItemsSource="{Binding 信号}"
                                  MinWidth="100" />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="信号值" />
                        <TextBox Text="{Binding can报文}"
                                 MinWidth="100" />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="循环发送时间间隔(ms)(0为单次发送)" />
                        <TextBox Text="{Binding dbc循环发送时间间隔}"
                                 MinWidth="100" />
                    </DockPanel>
                    <StackPanel Orientation="Horizontal">
                        <Label Content="通道(从0开始)"
                               VerticalContentAlignment="Center" />
                        <TextBox Text="{Binding 报文发送通道}"
                                 MinWidth="100"
                                 VerticalAlignment="Center"
                                 Margin="0,10,10,10" />
                        <Button Content="加载报文"
                                Command="{Binding ButtonClickCommand}"
                                CommandParameter="加载报文"
                                Margin="10" />
                        <Button Content="设置信号并发送"
                                Command="{Binding ButtonClickCommand}"
                                CommandParameter="设置" />
                        <CheckBox Content="直接发送"
                                  IsChecked="{Binding 直接发送}" />
                    </StackPanel>
                </TreeViewItem>

                <!-- 自定义报文发送 -->
                <TreeViewItem Header="自定义报文发送">
                    <DockPanel>
                        <Label Content="通道" />
                        <ComboBox MinWidth="100"
                                  SelectedItem="{Binding AIdxChn}"
                                  ItemsSource="{Binding APP_CHANNEL名称}"
                                 />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="ID" />
                        <TextBox MinWidth="100"
                                 Text="{Binding AID, Converter={StaticResource HexConverter}, Mode=TwoWay}" />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="DLC" />
                        <TextBox MinWidth="200"
                                 Text="{Binding ADLC}" />
                        <CheckBox Content="自动设定"
                                  IsChecked="{Binding 自动设定}" />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="报文" />
                        <TextBox MinWidth="200"
                                 Text="{Binding 自定义报文}" />
                    </DockPanel>
                    <DockPanel>
                        <Label Content="循环发送时间间隔(ms)(0为单次发送)" />
                        <TextBox Text="{Binding 自定义循环发送时间间隔}"
                                 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 ButtonClickCommand}"
                                CommandParameter="自定义报文发送" />
                        <CheckBox Margin="10"
                                  Content="更新到数据库"
                                  IsChecked="{Binding 更新到数据库}" />
                    </StackPanel>
                </TreeViewItem>

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