<ui:Page xmlns:props="clr-namespace:Ink_Canvas.Properties" x:Class="Ink_Canvas.Windows.SettingsViews.Pages.InkRecognitionPage"
      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:Ink_Canvas.Windows.SettingsViews.Pages"
      xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
      xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
      xmlns:sys="clr-namespace:System;assembly=mscorlib"
      xmlns:controls="clr-namespace:Ink_Canvas.Controls;assembly=InkCanvas.Controls"
      xmlns:c="clr-namespace:Ink_Canvas.Converter"
      mc:Ignorable="d"
      Title="{x:Static props:CanvasStrings.InkRecog_Title}">
    <ScrollViewer PanningMode="VerticalFirst">
        <Grid Margin="59,0,59,0">
            <FrameworkElement.Resources>
                <sys:Double x:Key="SettingsCardSpacing">4</sys:Double>
                <c:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
                <Style x:Key="SettingsSectionHeaderTextBlockStyle"
                       BasedOn="{StaticResource BodyStrongTextBlockStyle}"
                       TargetType="TextBlock">
                    <Style.Setters>
                        <Setter Property="Margin" Value="1,30,0,6" />
                    </Style.Setters>
                </Style>
            </FrameworkElement.Resources>
            <Grid>
                <ikw:SimpleStackPanel MaxWidth="1000" HorizontalAlignment="Stretch"
                    Spacing="{StaticResource SettingsCardSpacing}">

                    <TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
                        Text="{x:Static props:CanvasStrings.InkRecog_Title}" />

                    <controls:LabeledSettingsCard x:Name="CardEnableInkToShape"
                            Header="{x:Static props:CanvasStrings.InkRecog_EnableInkRecognition}"
                            Icon="{x:Static ui:SegoeFluentIcons.Draw}"
                            SwitchName="ToggleSwitchEnableInkToShape"
                            Toggled="ToggleSwitchEnableInkToShape_Toggled" />

                    <ui:SettingsCard Header="{x:Static props:CanvasStrings.InkRecog_ShapeEngine}"
                            Description="{x:Static props:CanvasStrings.InkRecog_ShapeEngineHint}">
                        <ComboBox x:Name="ComboBoxShapeRecognitionEngine"
                                  SelectionChanged="ComboBoxShapeRecognitionEngine_SelectionChanged">
                            <ComboBoxItem Content="{x:Static props:CanvasStrings.InkRecog_ShapeEngineAuto}" />
                            <ComboBoxItem Content="IACore" />
                            <ComboBoxItem Content="WinRT" />
                        </ComboBox>
                    </ui:SettingsCard>

                    <controls:LabeledSettingsCard x:Name="CardEnableWinRtHandwritingStrokeBeautify"
                            Header="{x:Static props:CanvasStrings.InkRecog_HandwritingBeautify}"
                            Description="{x:Static props:CanvasStrings.InkRecog_HandwritingBeautifyHint}"
                            Icon="{x:Static ui:SegoeFluentIcons.PenWorkspace}"
                            SwitchName="ToggleSwitchEnableWinRtHandwritingStrokeBeautify"
                            Toggled="ToggleSwitchEnableWinRtHandwritingStrokeBeautify_Toggled" />

                    <ui:SettingsCard Header="{x:Static props:CanvasStrings.InkRecog_HandwritingFont}"
                            Description="{x:Static props:CanvasStrings.InkRecog_HandwritingFontHint}"
                            Visibility="{Binding IsOn, ElementName=CardEnableWinRtHandwritingStrokeBeautify, Converter={StaticResource BooleanToVisibilityConverter}}"
                            d:Visibility="Visible">
                        <ComboBox x:Name="ComboBoxHandwritingCorrectionFont"
                                  SelectionChanged="ComboBoxHandwritingCorrectionFont_SelectionChanged">
                            <ComboBoxItem Content="{x:Static props:CanvasStrings.InkRecog_Font_InkFreeKaiti}" Tag="Ink Free,KaiTi,Segoe Script" />
                            <ComboBoxItem Content="{x:Static props:CanvasStrings.InkRecog_Font_Kaiti}" Tag="KaiTi" FontFamily="KaiTi" />
                            <ComboBoxItem Content="{x:Static props:CanvasStrings.InkRecog_Font_STKaiti}" Tag="STKaiti" FontFamily="STKaiti" />
                            <ComboBoxItem Content="{x:Static props:CanvasStrings.InkRecog_Font_STXingkai}" Tag="STXingkai" FontFamily="STXingkai" />
                            <ComboBoxItem Content="{x:Static props:CanvasStrings.InkRecog_Font_FangSong}" Tag="FangSong" FontFamily="FangSong" />
                            <ComboBoxItem Content="{x:Static props:CanvasStrings.InkRecog_Font_STFangsong}" Tag="STFangsong" FontFamily="STFangsong" />
                            <ComboBoxItem Content="{x:Static props:CanvasStrings.InkRecog_Font_LiSu}" Tag="LiSu" FontFamily="LiSu" />
                            <ComboBoxItem Content="{x:Static props:CanvasStrings.InkRecog_Font_YouYuan}" Tag="YouYuan" FontFamily="YouYuan" />
                            <ComboBoxItem Content="Ink Free" Tag="Ink Free" FontFamily="Ink Free" />
                            <ComboBoxItem Content="Segoe Script" Tag="Segoe Script" FontFamily="Segoe Script" />
                            <ComboBoxItem Content="Segoe Print" Tag="Segoe Print" FontFamily="Segoe Print" />
                            <ComboBoxItem Content="Comic Sans MS" Tag="Comic Sans MS" FontFamily="Comic Sans MS" />
                        </ComboBox>
                    </ui:SettingsCard>

                    <controls:LabeledSettingsCard x:Name="CardEnableInkToShapeNoFakePressureRectangle"
                            Header="{x:Static props:CanvasStrings.InkRecog_BlockRectFakePressure}"
                            ShowWhen="{Binding IsOn, ElementName=CardEnableInkToShape}"
                            d:Visibility="Visible"
                            Icon="{x:Static ui:SegoeFluentIcons.RectangularClipping}"
                            SwitchName="ToggleSwitchEnableInkToShapeNoFakePressureRectangle"
                            Toggled="ToggleSwitchEnableInkToShapeNoFakePressureRectangle_Toggled" />

                    <controls:LabeledSettingsCard x:Name="CardEnableInkToShapeNoFakePressureTriangle"
                            Header="{x:Static props:CanvasStrings.InkRecog_BlockTriFakePressure}"
                            ShowWhen="{Binding IsOn, ElementName=CardEnableInkToShape}"
                            d:Visibility="Visible"
                            Icon="{x:Static ui:SegoeFluentIcons.IncidentTriangle}"
                            SwitchName="ToggleSwitchEnableInkToShapeNoFakePressureTriangle"
                            Toggled="ToggleSwitchEnableInkToShapeNoFakePressureTriangle_Toggled" />

                    <ui:SettingsExpander Header="{x:Static props:CanvasStrings.InkRecog_ShapeCorrection}"
                            Visibility="{Binding IsOn, ElementName=CardEnableInkToShape, Converter={StaticResource BooleanToVisibilityConverter}}"
                            IsExpanded="{Binding IsOn, ElementName=CardEnableInkToShape, Mode=OneWay}"
                            d:Visibility="Visible" d:IsExpanded="True">
                        <ui:SettingsExpander.HeaderIcon>
                            <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Settings}" />
                        </ui:SettingsExpander.HeaderIcon>
                        <ui:SettingsExpander.Items>
                            <ui:SettingsCard ContentAlignment="Left">
                                <CheckBox x:Name="ToggleCheckboxEnableInkToShapeTriangle" IsChecked="True"
                                          Content="{x:Static props:CanvasStrings.InkRecog_FixTriangle}"
                                          Checked="ToggleCheckboxEnableInkToShapeTriangle_CheckedChanged"
                                          Unchecked="ToggleCheckboxEnableInkToShapeTriangle_CheckedChanged" />
                            </ui:SettingsCard>
                            <ui:SettingsCard ContentAlignment="Left">
                                <CheckBox x:Name="ToggleCheckboxEnableInkToShapeRectangle" IsChecked="True"
                                          Content="{x:Static props:CanvasStrings.InkRecog_FixRectangle}"
                                          Checked="ToggleCheckboxEnableInkToShapeRectangle_CheckedChanged"
                                          Unchecked="ToggleCheckboxEnableInkToShapeRectangle_CheckedChanged" />
                            </ui:SettingsCard>
                            <ui:SettingsCard ContentAlignment="Left">
                                <CheckBox x:Name="ToggleCheckboxEnableInkToShapeRounded" IsChecked="True"
                                          Content="{x:Static props:CanvasStrings.InkRecog_FixEllipse}"
                                          Checked="ToggleCheckboxEnableInkToShapeRounded_CheckedChanged"
                                          Unchecked="ToggleCheckboxEnableInkToShapeRounded_CheckedChanged" />
                            </ui:SettingsCard>
                        </ui:SettingsExpander.Items>
                    </ui:SettingsExpander>

                    <ui:SettingsExpander x:Name="ExpanderAutoStraightenLine"
                            Header="{x:Static props:CanvasStrings.InkRecog_AutoStraightLine}"
                            IsExpanded="{Binding IsOn, ElementName=ToggleSwitchAutoStraightenLine, Mode=OneWay}"
                            d:Visibility="Visible" d:IsExpanded="True">
                        <ui:SettingsExpander.HeaderIcon>
                            <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.LineDisplay}" />
                        </ui:SettingsExpander.HeaderIcon>
                        <ui:ToggleSwitch x:Name="ToggleSwitchAutoStraightenLine"
                                Toggled="ToggleSwitchAutoStraightenLine_Toggled" />
                        <ui:SettingsExpander.Items>
                            <ui:SettingsCard Header="{x:Static props:CanvasStrings.InkRecog_LengthThreshold}">
                                <ikw:SimpleStackPanel Orientation="Horizontal" Spacing="8">
                                    <TextBlock x:Name="AutoStraightenLineThresholdText"
                                               VerticalAlignment="Center" FontFamily="Consolas" TextAlignment="Right"/>
                                    <Slider x:Name="AutoStraightenLineThresholdSlider" Width="200" Minimum="30" Maximum="300"
                                            Value="80" TickFrequency="30" IsSnapToTickEnabled="True"
                                            ValueChanged="AutoStraightenLineThresholdSlider_ValueChanged" />
                                </ikw:SimpleStackPanel>
                            </ui:SettingsCard>
                            <ui:SettingsCard Header="{x:Static props:CanvasStrings.InkRecog_Sensitivity}">
                                <ikw:SimpleStackPanel Orientation="Horizontal" Spacing="8">
                                    <TextBlock x:Name="LineStraightenSensitivityText"
                                               VerticalAlignment="Center" FontFamily="Consolas" TextAlignment="Right"/>
                                    <Slider x:Name="LineStraightenSensitivitySlider" Width="200" Minimum="0.05" Maximum="2.0"
                                            Value="0.20" TickFrequency="0.05" IsSnapToTickEnabled="True"
                                            ValueChanged="LineStraightenSensitivitySlider_ValueChanged" />
                                </ikw:SimpleStackPanel>
                            </ui:SettingsCard>
                            <ui:SettingsCard Header="{x:Static props:CanvasStrings.InkRecog_HighPrecisionStraighten}"
                                    Description="{x:Static props:CanvasStrings.InkRecog_HighPrecisionHint}">
                                <ui:ToggleSwitch x:Name="ToggleSwitchHighPrecisionLineStraighten"
                                        Toggled="ToggleSwitchHighPrecisionLineStraighten_Toggled" />
                            </ui:SettingsCard>
                            <ui:SettingsCard Header="{x:Static props:CanvasStrings.InkRecog_PauseStraightenLine}"
                                    Description="{x:Static props:CanvasStrings.InkRecog_PauseStraightenHint}">
                                <ui:ToggleSwitch x:Name="ToggleSwitchPauseStraightenLine"
                                        Toggled="ToggleSwitchPauseStraightenLine_Toggled" />
                            </ui:SettingsCard>
                            <ui:SettingsCard Header="{x:Static props:CanvasStrings.InkRecog_PauseStraightenDelay}">
                                <ikw:SimpleStackPanel Orientation="Horizontal" Spacing="8">
                                    <TextBlock x:Name="PauseStraightenDelayText"
                                               VerticalAlignment="Center" FontFamily="Consolas" TextAlignment="Right"/>
                                    <Slider x:Name="PauseStraightenDelaySlider" Width="200" Minimum="100" Maximum="1000"
                                            Value="300" TickFrequency="50" IsSnapToTickEnabled="True"
                                            ValueChanged="PauseStraightenDelaySlider_ValueChanged" />
                                </ikw:SimpleStackPanel>
                            </ui:SettingsCard>
                        </ui:SettingsExpander.Items>
                    </ui:SettingsExpander>

                    <ui:SettingsExpander x:Name="ExpanderLineEndpointSnapping"
                            Header="{x:Static props:CanvasStrings.InkRecog_LineEndpointSnapping}"
                            IsExpanded="{Binding IsOn, ElementName=ToggleSwitchLineEndpointSnapping, Mode=OneWay}"
                            d:Visibility="Visible" d:IsExpanded="True">
                        <ui:SettingsExpander.HeaderIcon>
                            <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Link}" />
                        </ui:SettingsExpander.HeaderIcon>
                        <ui:ToggleSwitch x:Name="ToggleSwitchLineEndpointSnapping"
                                Toggled="ToggleSwitchLineEndpointSnapping_Toggled" />
                        <ui:SettingsExpander.Items>
                            <ui:SettingsCard Header="{x:Static props:CanvasStrings.InkRecog_SnappingDistance}"
                                    Description="{x:Static props:CanvasStrings.InkRecog_LineEndpointSnappingHint}">
                                <ikw:SimpleStackPanel Orientation="Horizontal" Spacing="8">
                                    <TextBlock x:Name="LineEndpointSnappingThresholdText"
                                               VerticalAlignment="Center" FontFamily="Consolas" TextAlignment="Right"/>
                                    <Slider x:Name="LineEndpointSnappingThresholdSlider" Width="200" Minimum="5" Maximum="50"
                                            Value="15" TickFrequency="5" IsSnapToTickEnabled="True"
                                            ValueChanged="LineEndpointSnappingThresholdSlider_ValueChanged" />
                                </ikw:SimpleStackPanel>
                            </ui:SettingsCard>
                        </ui:SettingsExpander.Items>
                    </ui:SettingsExpander>

                    <Rectangle Height="48" />

                </ikw:SimpleStackPanel>
            </Grid>
        </Grid>
    </ScrollViewer>
</ui:Page>
