<UserControl x:Class="BOB.Views.Dialogs.BackfeedView"
             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: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>
    <Grid MouseLeftButtonDown="MouseLeftButtonDown">
        <Grid.RowDefinitions>
            <RowDefinition Height="220" />
            <RowDefinition />
            <RowDefinition Height="350" />
        </Grid.RowDefinitions>

        <!-- 实时监控 -->
        <GroupBox x:Name="实时监控区"
                  Header="实时监控"
                  Padding="0,0,0,0">
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <ucs:NumericalDisplay DataContext="{Binding 电压MV,Mode=TwoWay}"
                                      Grid.Column="0" />
                <ucs:NumericalDisplay DataContext="{Binding 电流MV,Mode=TwoWay}"
                                      Grid.Column="1" />
                <ucs:NumericalDisplay DataContext="{Binding 功率MV,Mode=TwoWay}"
                                      Grid.Column="2" />
            </Grid>
        </GroupBox>

        <!-- 实时曲线 -->
        <GroupBox Header="实时曲线"
                  Grid.Row="1"
                  Padding="0,0,0,0">
            <oxy:PlotView Model="{Binding 曲线Model}">
                <oxy:PlotView.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="视图复位"
                                  Command="{Binding ResetViewCommand}" />
                    </ContextMenu>
                </oxy:PlotView.ContextMenu>
            </oxy:PlotView>
        </GroupBox>

        <!-- 调试选项 -->
        <GroupBox Header="调试选项"
                  Grid.Row="2">
            <TreeView Margin="10">
                <!-- 连接状态设置 -->
                <TreeViewItem Header="连接状态设置">
                    <StackPanel Orientation="Horizontal">
                        <Button Content="连接"
                                Margin="5"
                                Command="{Binding ConnectCommand}" />
                        <Button Content="断开"
                                Margin="5"
                                Command="{Binding DisconnectCommand}" />
                    </StackPanel>
                </TreeViewItem>

                <!-- 查询 -->
                <TreeViewItem Header="查询">
                    <TreeViewItem Header="查询设备标识">
                        <StackPanel Orientation="Horizontal">
                            <Button Content="查询设备标识"
                                    Margin="5"
                                    Command="{Binding QueryDeviceCommand}" />
                            <Label Content="结果"
                                   Margin="5"
                                   VerticalContentAlignment="Center" />
                            <TextBox Text="{Binding 设备标识字符串}"
                                     MinWidth="100"
                                     Margin="5"
                                     materialDesign:HintAssist.Hint=""
                                     VerticalContentAlignment="Center" />
                        </StackPanel>
                    </TreeViewItem>
                </TreeViewItem>

                <!-- 设置 -->
                <TreeViewItem Header="设置">
                    <!-- 远程模式 -->
                    <TreeViewItem Header="远程">
                        <Button Content="设置为远程模式"
                                Command="{Binding SetRemoteModeCommand}"
                                Margin="5" />
                    </TreeViewItem>

                    <!-- 输出设置 -->
                    <TreeViewItem Header="输出">
                        <StackPanel Orientation="Horizontal">
                            <Button Content="开"
                                    Command="{Binding OutputOnCommand}"
                                    Margin="5" />
                            <Button Content="关"
                                    Command="{Binding OutputOffCommand}"
                                    Margin="5" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="设置电压(V)"
                                    Command="{Binding SetVoltageCommand}"
                                    Margin="5" />
                            <Label Content="值:"
                                   VerticalAlignment="Center" />
                            <TextBox Text="{Binding 输出电压}"
                                     materialDesign:HintAssist.Hint=""
                                     MinWidth="100"
                                     VerticalAlignment="Center" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="设置电流(A)"
                                    Command="{Binding SetCurrentCommand}"
                                    Margin="5" />
                            <Label Content="值:"
                                   VerticalAlignment="Center" />
                            <TextBox Text="{Binding 输出电流}"
                                     MinWidth="100"
                                     materialDesign:HintAssist.Hint=""
                                     VerticalAlignment="Center" />
                        </StackPanel>
                    </TreeViewItem>

                    <!-- 电流保护 -->
                    <TreeViewItem Header="电流保护(OCP)">
                        <StackPanel Orientation="Horizontal">
                            <Button Content="开"
                                    Command="{Binding EnableOCPCommand}"
                                    Margin="5" />
                            <Button Content="关"
                                    Command="{Binding DisableOCPCommand}"
                                    Margin="5" />
                            <Button Content="清除报警"
                                    Command="{Binding ClearOCPAlarmCommand}"
                                    Margin="5" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="设置电流保护(A)"
                                    Command="{Binding SetOCPCommand}"
                                    Margin="5" />
                            <Label Content="值:"
                                   VerticalAlignment="Center" />
                            <TextBox Text="{Binding OCP电流}"
                                     MinWidth="100"
                                     materialDesign:HintAssist.Hint=""
                                     VerticalAlignment="Center" />
                        </StackPanel>
                    </TreeViewItem>

                    <!-- 电压保护 -->
                    <TreeViewItem Header="电压保护(OVP)">
                        <StackPanel Orientation="Horizontal">
                            <Button Content="开"
                                    Command="{Binding EnableOVPCommand}"
                                    Margin="5" />
                            <Button Content="关"
                                    Command="{Binding DisableOVPCommand}"
                                    Margin="5" />
                            <Button Content="清除报警"
                                    Command="{Binding ClearOVPAlarmCommand}"
                                    Margin="5" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="设置电压保护(V)"
                                    Command="{Binding SetOVPCommand}"
                                    Margin="5" />
                            <Label Content="值:"
                                   VerticalAlignment="Center" />
                            <TextBox Text="{Binding OVP电压}"
                                     materialDesign:HintAssist.Hint=""
                                     MinWidth="100"
                                     VerticalAlignment="Center" />
                        </StackPanel>
                    </TreeViewItem>

                    <!-- 功率保护 -->
                    <TreeViewItem Header="功率保护(OPP)">
                        <StackPanel Orientation="Horizontal">
                            <Button Content="开"
                                    Command="{Binding EnableOPPCommand}"
                                    Margin="5" />
                            <Button Content="关"
                                    Command="{Binding DisableOPPCommand}"
                                    Margin="5" />
                            <Button Content="清除报警"
                                    Command="{Binding ClearOPPAlarmCommand}"
                                    Margin="5" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="设置功率(W)"
                                    Command="{Binding SetOPPCommand}"
                                    Margin="5" />
                            <Label Content="值:"
                                   VerticalAlignment="Center" />
                            <TextBox Text="{Binding OPP功率}"
                                     materialDesign:HintAssist.Hint=""
                                     MinWidth="100"
                                     VerticalAlignment="Center" />
                        </StackPanel>
                    </TreeViewItem>
                </TreeViewItem>
            </TreeView>
        </GroupBox>
        <StackPanel Grid.Row="2"
                    VerticalAlignment="Bottom">
            <Button Content="关闭"
                    Width="70"
                    Margin="10"
                    HorizontalAlignment="Right"
                    Command="{Binding CloseCommand}" />
        </StackPanel>
    </Grid>
</UserControl>
