<UserControl x:Class="BOB.Views.Dialogs.ParameterSetting"
             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:converters="clr-namespace:BOB.Converters"
             xmlns:local="clr-namespace:BOB.Views.Dialogs"
             xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:prism="http://prismlibrary.com/"
             Background="White"
             xmlns:behavior="clr-namespace:Common.Behaviors;assembly=Common"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             prism:ViewModelLocator.AutoWireViewModel="True"
             Width="420"
             Height="284"
             mc:Ignorable="d">
    <prism:Dialog.WindowStyle>
        <Style BasedOn="{StaticResource DialogUserManageStyle}"
               TargetType="Window" />
    </prism:Dialog.WindowStyle>
    <UserControl.Resources>
        <converters:IsEnumTypeConverter x:Key="IsEnumTypeConverter" />
        <converters:ParameterValueToStringConverter x:Key="ParameterValueToStringConverter" />
    </UserControl.Resources>
    <Grid>
        <GroupBox Padding="10,15,10,0"
                  Header="{Binding Title}"
                  behavior:WindowDragBehavior.EnableWindowDrag="True">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="auto" />
                </Grid.RowDefinitions>
                <ScrollViewer>
                    <StackPanel>
                        <StackPanel Height="30"
                                    Margin="7"
                                    Orientation="Horizontal">
                            <Label Width="60"
                                   VerticalAlignment="Bottom"
                                   Content="参数名称*" />
                            <TextBox Width="120"
                                     Text="{Binding Parameter.Name}"
                                     materialDesign:HintAssist.Hint="参数名称" />
                        </StackPanel>
                        <StackPanel Height="30"
                                    Margin="7"
                                    Orientation="Horizontal">
                            <Label Width="60"
                                   VerticalAlignment="Bottom"
                                   Content="参数类型*" />
                            <ComboBox Width="120"
                                      VerticalAlignment="Bottom"
                                      ItemsSource="{Binding Types}"
                                      materialDesign:HintAssist.Hint="参数类型"
                                      SelectedItem="{Binding Parameter.Type}"
                                       />
                        </StackPanel>
                        <StackPanel Height="30"
                                    Margin="7"
                                    Orientation="Horizontal">
                            <Label Width="60"
                                   VerticalAlignment="Bottom"
                                   Content="参数类别*" />
                            <ComboBox Width="120"
                                      VerticalAlignment="Bottom"
                                      ItemsSource="{Binding Categories}"
                                      materialDesign:HintAssist.Hint="参数类别"
                                      Text="{Binding Parameter.Category}" />
                        </StackPanel>
                        <StackPanel Height="30"
                                    Margin="7"
                                    Orientation="Horizontal">
                            <Label Width="60"
                                   VerticalAlignment="Bottom"
                                   Content="参数下限" />
                            <TextBox Width="120"
                                     VerticalAlignment="Bottom"
                                     Text="{Binding Parameter.LowerLimit}"
                                     materialDesign:HintAssist.Hint="参数下限" />
                        </StackPanel>
                        <StackPanel Height="30"
                                    Margin="7"
                                    Orientation="Horizontal">
                            <Label Width="60"
                                   VerticalAlignment="Bottom"
                                   Content="参数上限" />
                            <TextBox Width="120"
                                     VerticalAlignment="Bottom"
                                     Text="{Binding Parameter.UpperLimit}"
                                     materialDesign:HintAssist.Hint="参数名上限" />
                        </StackPanel>
                        <StackPanel Height="30"
                                    Margin="7"
                                    Orientation="Horizontal">
                            <Label Width="60"
                                   VerticalAlignment="Bottom"
                                   Content="参数值" />

                            <!--  非枚举类型时显示文本框  -->
                            <TextBox MinWidth="120"
                                     VerticalAlignment="Bottom"
                                     Text="{Binding Parameter.Value, Converter={StaticResource ParameterValueToStringConverter}}"
                                     materialDesign:HintAssist.Hint="参数值"
                                     Visibility="{Binding Parameter.Type, Converter={StaticResource IsEnumTypeConverter}, ConverterParameter=Collapse}" />

                            <!--  枚举类型时显示下拉框  -->
                            <!--<ComboBox MinWidth="120"
                                      VerticalAlignment="Bottom"
                                      ItemsSource="{Binding EnumValues}"
                                      SelectedItem="{Binding Parameter.Value}"
                                      Visibility="{Binding Parameter.Type, Converter={StaticResource IsEnumTypeConverter}}" />-->
                            <CheckBox Margin="10,0"
                                      VerticalAlignment="Bottom"
                                      Content="保存数据"
                                      IsChecked="{Binding Parameter.IsSave}" />
                        </StackPanel>
                    </StackPanel>
                </ScrollViewer>
                <StackPanel Grid.Row="1"
                            Margin="5,10,5,15"
                            FlowDirection="RightToLeft"
                            Orientation="Horizontal">
                    <Button Content="取消"
                            Width="70"
                            Command="{Binding CancelCommand}" />
                    <Button Content="保存"
                            Width="70"
                            Margin="20,0"
                            Command="{Binding SaveCommand}" />
                </StackPanel>
            </Grid>

        </GroupBox>
    </Grid>
</UserControl>
