<pu:WindowX  xmlns:pu="https://opensource.panuon.com/wpf-ui"
             x:Class="SWRIS.Pages.ParameterDialog"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:local="clr-namespace:SWRIS.Pages.RealTime" 
             xmlns:vm="clr-namespace:SWRIS.Models.ViewModel"  MaskBrush="#66000000"
             xmlns:cvt="clr-namespace:SWRIS.Converters" AllowsTransparency="True"
             mc:Ignorable="d" Foreground="#7886B2" FontFamily="{StaticResource PuHuiTiRegular}"
             FontSize="18" Background="Transparent" WindowStyle="None" ResizeMode="NoResize" 
             pu:WindowXCaption.Height="0" WindowStartupLocation="CenterScreen" IsEscEnabled="True"
             Title="ParameterDialog" Height="900" Width="1300">
    <Window.DataContext>
        <vm:EquipmentSettingViewModel/>
    </Window.DataContext>
    <pu:WindowX.Resources>
        <cvt:BooleanInverterConverter x:Key="InverterConverter"/>
        <cvt:EncoderDirectionToBooleanConverter x:Key="EncoderDirectionConverter"/>
        <cvt:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
        <cvt:ResetTypeToBooleanConverter x:Key="ResetTypeConverter"/>
    </pu:WindowX.Resources>
    <Border BorderThickness="2" BorderBrush="#3B3B7B" CornerRadius="10" Background="#141332">
        <Grid Margin="0" HorizontalAlignment="Center">
            <Grid.RowDefinitions>
                <RowDefinition Height="70"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="130"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="1.6*"/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Row="0" Grid.ColumnSpan="3" Text="参数设置" Foreground="#FFFFFF" FontSize="36" 
                       FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
            <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" Margin="10,0">
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                        <Rectangle Height="2" Width="140" Stroke="#3B3B7B"/>
                        <TextBlock Text="设备" Foreground="#615CDD" FontSize="24" Margin="15" FontWeight="Regular"/>
                        <Rectangle Height="2" Width="140" Stroke="#3B3B7B"/>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
                        <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                            <TextBlock Text="版本号" VerticalAlignment="Center"/>
                            <TextBox Text="{Binding Parameter.MainBoardSoftwareVersion}" IsEnabled="False" Margin="15,0"/>
                            <Image Source="/Resources/upgrade.png" Width="26" Height="26" Margin="0,0,-26,0" Cursor="Hand"
                                   Visibility="{Binding IsConnected, Converter={StaticResource BoolToVisibilityConverter}}"
                                   MouseDown="Upgrade_MouseDown"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="0,7"  HorizontalAlignment="Right">
                            <TextBlock Text="设备地址" VerticalAlignment="Center"/>
                            <TextBox Margin="15,0" Text="{Binding IpAddress}"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="0,7"  HorizontalAlignment="Right">
                            <TextBlock Text="传感器数量" VerticalAlignment="Center"/>
                            <TextBox Margin="15,0" Text="{Binding Parameter.SensorCount}"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right" Visibility="Visible">
                            <TextBlock Text="位/高比例" VerticalAlignment="Center"/>
                            <TextBox Margin="15,0" Text="{Binding LiftHightRatio}"/>
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                        <Rectangle Height="2" Width="140" Stroke="#3B3B7B"/>
                        <TextBlock Text="同步" Foreground="#615CDD" FontSize="24" Margin="15" FontWeight="Regular"/>
                        <Rectangle Height="2" Width="140" Stroke="#3B3B7B"/>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="0,0,32,0">
                        <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                            <TextBlock Text="编码器" Margin="10,0" VerticalAlignment="Center"/>
                            <StackPanel Orientation="Horizontal">
                                <ToggleButton Content="正向" Margin="12,0,5,0" FontSize="18"
                                          IsChecked="{Binding Parameter.EncoderDirection,
                                          Converter={StaticResource EncoderDirectionConverter},
                                          ConverterParameter=Forward}"/>
                                <ToggleButton Content="反向" Margin="5,0,15,0" FontSize="18"
                                          IsChecked="{Binding Parameter.EncoderDirection,
                                          Converter={StaticResource EncoderDirectionConverter},
                                          ConverterParameter=Reverse}"/>
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="0,7"  HorizontalAlignment="Right">
                            <TextBlock Text="时钟" VerticalAlignment="Center"/>
                            <TextBox Margin="15,0" Width="200" GotFocus="Clock_GotFocus"
                                 Text="{Binding Parameter.SystemTime,StringFormat='yyyy-MM-dd HH:mm:ss',TargetNullValue='',Mode=TwoWay}"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="10,0" IsEnabled="{Binding IsConnected}">
                            <Button Content="读" Width="60" Height="40" Margin="5" Click="ReadClockAndDirection_Click"/>
                            <Button Content="设" Width="60" Height="40" Margin="5"  Click="SetClockAndDirection_Click"/>
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                        <Rectangle Height="2" Width="140" Stroke="#3B3B7B"/>
                        <TextBlock Text="序列号" Foreground="#615CDD" FontSize="24" Margin="15" FontWeight="Regular"/>
                        <Rectangle Height="2" Width="140" Stroke="#3B3B7B"/>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="0,0,32,0">
                        <StackPanel Orientation="Horizontal" Margin="0,7"  HorizontalAlignment="Right">
                            <TextBlock Text="序列号" Margin="7,0" VerticalAlignment="Center"/>
                            <TextBox Margin="15,0" Width="200" Text="{Binding SerialNo}" GotFocus="SerialNo_GotFocus"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="10,0" IsEnabled="{Binding IsConnected}">
                            <Button Content="设" Width="60" Height="40" Margin="5"  Click="SetSerialNo_Click"/>
                        </StackPanel>
                    </StackPanel>
                
                </StackPanel>
            </StackPanel>
            <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="1" Margin="10,0,10,0">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                    <Rectangle Height="2" Width="140" Stroke="#3B3B7B"/>
                    <TextBlock Text="钢丝绳" Foreground="#615CDD" FontSize="24" Margin="15" FontWeight="Regular"/>
                    <Rectangle Height="2" Width="140" Stroke="#3B3B7B"/>
                </StackPanel>
                <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
                    <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                        <TextBlock Text="钢丝绳绳号" VerticalAlignment="Center"/>
                        <TextBox Text="{Binding RopeNumber}" Margin="15,0"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,7"  HorizontalAlignment="Right">
                        <TextBlock Text="钢丝绳名称" VerticalAlignment="Center"/>
                        <TextBox Margin="15,0" Text="{Binding RopeName}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,7"  HorizontalAlignment="Right">
                        <TextBlock Text="直径" VerticalAlignment="Center"/>
                        <TextBox Margin="15,0" Text="{Binding Parameter.WireRopeDiameter}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,7"  HorizontalAlignment="Right">
                        <TextBlock Text="股丝" VerticalAlignment="Center"/>
                        <TextBox Margin="10,0,8,0" Width="64" Text="{Binding Parameter.WireRopeStrandCount}"/>
                        <TextBlock Text="*" VerticalAlignment="Center"/>
                        <TextBox Margin="7,0,15,0" Width="64" Text="{Binding Parameter.WireRopeStrandWireCount}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,7"  HorizontalAlignment="Right">
                        <TextBlock Text="长度" VerticalAlignment="Center"/>
                        <TextBox Margin="15,0" Text="{Binding Parameter.WireRopeLength}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,7"  HorizontalAlignment="Right">
                        <TextBlock Text="采样步长" VerticalAlignment="Center"/>
                        <TextBox Margin="15,0" Text="{Binding Parameter.SamplingStep}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,7"  HorizontalAlignment="Right">
                        <TextBlock Text="判伤捻距系数" VerticalAlignment="Center"/>
                        <TextBox Margin="15,0" Text="{Binding Parameter.TwistFactor}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,7"  HorizontalAlignment="Right">
                        <TextBlock Text="钢丝材质" VerticalAlignment="Center"/>
                        <ComboBox Margin="15,0" Width="150"
                                  ItemsSource="{Binding RopeCoreTypes}" 
                                  DisplayMemberPath="Value" SelectedValuePath="Key" 
                                  SelectedValue="{Binding RopeCoreType}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,7"  HorizontalAlignment="Right">
                        <TextBlock Text="绳芯材质" VerticalAlignment="Center"/>
                        <ComboBox Margin="15,0"  Width="150"
                                  ItemsSource="{Binding WireMaterialTypes}" 
                                  SelectedValue="{Binding WireMaterialType}"
                                  DisplayMemberPath="Value" SelectedValuePath="Key" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                        <TextBlock Text="捻制方法" VerticalAlignment="Center"/>
                        <ComboBox Margin="15,0" Width="150"
                                  ItemsSource="{Binding LayTypes}" 
                                  SelectedValue="{Binding LayType}"
                                  DisplayMemberPath="Value" SelectedValuePath="Key" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                        <TextBlock Text="表面状态" VerticalAlignment="Center"/>
                        <ComboBox Margin="15,0" Width="150" 
                                  ItemsSource="{Binding WireSurfaceTypes}" 
                                  SelectedValue="{Binding WireSurfaceType}" 
                                  DisplayMemberPath="Value" SelectedValuePath="Key" />
                    </StackPanel>
                </StackPanel>
            </StackPanel>
            <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="2" Margin="10,0,10,0">
                <StackPanel Orientation="Vertical" >
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                        <Rectangle Height="2" Width="200" Stroke="#3B3B7B"/>
                        <TextBlock Text="其它参数" Foreground="#615CDD" FontSize="24" Margin="15" FontWeight="Regular"/>
                        <Rectangle Height="2" Width="200" Stroke="#3B3B7B"/>
                    </StackPanel>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="80"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <StackPanel Orientation="Vertical" Grid.Column="0" HorizontalAlignment="Center">
                            <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                                <TextBlock Text="分频系数" VerticalAlignment="Center"/>
                                <TextBox Margin="15,0" Width="120" Text="{Binding Parameter.FrequencyDivisionFactor}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                                <TextBlock Text="时域频率" VerticalAlignment="Center"/>
                                <TextBox Margin="15,0" Width="120" Text="{Binding Parameter.TimeDomainFrequency}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                                <TextBlock Text="前磁极" VerticalAlignment="Center"/>
                                <StackPanel Orientation="Horizontal"  Margin="0,0,4,0">
                                    <TextBox Margin="15,0,6,0" Width="80" Text="{Binding Parameter.FrontMagnetLength}"/>
                                    <TextBlock  Text="mm" Width="45" VerticalAlignment="Center"/>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                                <TextBlock Text="后磁极" VerticalAlignment="Center"/>
                                <StackPanel Orientation="Horizontal"  Margin="0,0,4,0">
                                    <TextBox Margin="15,0,6,0" Width="80" Text="{Binding Parameter.BackMagnetLength}"/>
                                    <TextBlock  Text="mm" Width="45" VerticalAlignment="Center"/>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                                <TextBlock Text="报废上限" VerticalAlignment="Center"/>
                                <TextBox Margin="15,0" Width="120" Text="{Binding Parameter.ScrapUpperLimit}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                                <TextBlock Text="损伤门限" VerticalAlignment="Center"/>
                                <TextBox Margin="15,0" Width="120" Text="{Binding Parameter.DamageThreshold}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                                <TextBlock Text="量值系数" VerticalAlignment="Center"/>
                                <TextBox Margin="15,0" Width="120" Text="{Binding Parameter.ValueCoefficient}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,5" HorizontalAlignment="Right">
                                <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                    <TextBlock Text="零点位有效行程" HorizontalAlignment="Right"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal"  Margin="0,0,4,0">
                                    <TextBox Margin="15,0,6,0" Width="90" Text="{Binding Parameter.EffectiveStrokeLength}"/>
                                    <TextBlock Text="m" Width="35" VerticalAlignment="Center"/>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,5" HorizontalAlignment="Right">
                                <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                    <TextBlock Text="零点位静止时长" HorizontalAlignment="Right"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal"  Margin="0,0,4,0">
                                    <TextBox Margin="15,0,6,0" Width="90" Text="{Binding Parameter.ZeroPositionCorrectionDuration}"/>
                                    <TextBlock Text="秒" Width="35" VerticalAlignment="Center"/>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,5" HorizontalAlignment="Right">
                                <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                    <TextBlock Text="零点位偏移值" HorizontalAlignment="Right"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal"  Margin="0,0,4,0">
                                    <TextBox Margin="15,0,6,0" Width="90" Text="{Binding Parameter.ZeroPositionCorrectionOffset}"/>
                                    <TextBlock Text="mm" Width="35" VerticalAlignment="Center"/>
                                </StackPanel>
                            </StackPanel>
                        </StackPanel >
                        <StackPanel Orientation="Vertical" Grid.Column="1" HorizontalAlignment="Center">
                            <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                                <TextBlock Text="黄色警报" VerticalAlignment="Center"/>
                                <TextBox Margin="15,0" Width="120" Text="{Binding Parameter.WarningValue}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,7" HorizontalAlignment="Right">
                                <TextBlock Text="红色警报" VerticalAlignment="Center"/>
                                <TextBox Margin="15,0" Width="120" Text="{Binding Parameter.AlarmValue}"/>
                            </StackPanel>

                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="0,7" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="报警重置" VerticalAlignment="Center"/>
                                <ToggleButton Content="不重置" Width="90" Margin="10,0,5,0" FontSize="18"
                                              IsChecked="{Binding Parameter.SoundLightAlarmAutoResetMode,Converter={StaticResource ResetTypeConverter},ConverterParameter=0}"/>
                            </StackPanel>
                            <ToggleButton Content="新测试重置" Width="110" Margin="5,5" FontSize="18" IsChecked="{Binding Parameter.SoundLightAlarmAutoResetMode,Converter={StaticResource ResetTypeConverter},ConverterParameter=-1}"/>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                                <StackPanel Orientation="Horizontal" Margin="5,7" HorizontalAlignment="Right">
                                    <ToggleButton Content="延时重置" Width="90" FontSize="18" 
                                                  IsChecked="{Binding Parameter.SoundLightAlarmAutoResetMode,Converter={StaticResource ResetTypeConverter},ConverterParameter=1}"/>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Margin="6,0,3,0" Width="40" Text="{Binding Parameter.SoundLightAlarmAutoResetMode}"/>
                                        <TextBlock Text="秒" Width="30" VerticalAlignment="Center"/>
                                    </StackPanel>
                                </StackPanel>

                            </StackPanel>
                        </StackPanel>
                    </Grid>
                </StackPanel>
            </StackPanel>
            <StackPanel Orientation="Horizontal"  Grid.ColumnSpan="3" Grid.Row="2" Margin="30" HorizontalAlignment="Center">
                <Button  Content="取消" Width="100" Height="50" Margin="10,0" IsCancel="True" Style="{StaticResource CancelButton}"/>
                <Button  Content="保存" Width="150" Height="50" Margin="20,0" IsDefault="True" Click="Save_Click" IsEnabled="{Binding IsConnected}"/>
            </StackPanel>
        </Grid>
    </Border>
</pu:WindowX>
