<settingspagebase:SettingsPageBase
        xmlns:settingspagebase="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
        x:Class="FasdDesktopUi.Pages.PhoneSettingsPage.PhoneSettingsPage"
        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:FasdDesktopUi.Pages.PhoneSettingsPage"
        xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
        xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        mc:Ignorable="d"
        Title="PhoneSettingsPage"
        ResizeMode="NoResize"
        WindowStyle="None"
        AllowsTransparency="True"
        Background="Transparent"
        MinHeight="100"
        MinWidth="400"
        ShowInTaskbar="False"
        Topmost="True"
        SizeToContent="WidthAndHeight"
        WindowStartupLocation="CenterScreen"
        x:Name="PhoneSettingsWindow"
        Closed="PhoneSettingsWindow_Closed" IsVisibleChanged="PhoneSettingsWindow_IsVisibleChanged"
    >

    <WindowChrome.WindowChrome>
        <WindowChrome CaptionHeight="40" />
    </WindowChrome.WindowChrome>

    <settingspagebase:SettingsPageBase.Resources>
        <vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
        <SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
        <SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA"/>
        <SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5"/>
        <Style x:Key="TextBoxStyle1" TargetType="{x:Type TextBox}">
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
            <Setter Property="BorderBrush" Value="{StaticResource TextBox.Static.Border}"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="AllowDrop" Value="true"/>
            <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
            <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TextBox}">
                        <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True" CornerRadius="10">
                            <ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" HorizontalAlignment="Right" Width="58"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Opacity" TargetName="border" Value="0.56"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
                            </Trigger>
                            <Trigger Property="IsKeyboardFocused" Value="true">
                                <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.Focus.Border}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
                        <Condition Property="IsSelectionActive" Value="false"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
                </MultiTrigger>
            </Style.Triggers>
        </Style>
    </settingspagebase:SettingsPageBase.Resources>

    <Border CornerRadius="10"
            Background="{DynamicResource BackgroundColor.Menu.Categories}"
            Padding="10">

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

            <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.SystemTray}"
                       TextTrimming="CharacterEllipsis"
                       FontSize="18"
                       Margin="30 0 0 0"
                       VerticalAlignment="Center"
                       FontFamily="Calibri"
                       FontWeight="Bold"
                       Foreground="{DynamicResource FontColor.SlimPage.WidgetCollection.Header}" />

            <ico:AdaptableIcon x:Name="CloseButton"
                               Grid.Row="0"
                               HorizontalAlignment="Right"
                               Style="{DynamicResource SettingsPage.Close.Icon}"
                               MouseLeftButtonUp="CloseButton_MouseLeftButtonUp"
                               TouchDown="CloseButton_TouchDown"
                               SelectedInternIcon="window_close" />

            <Border Grid.Row="1"
                    CornerRadius="7.5"
                    Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
                    Margin="5"
                    Padding="10 5">
                <Grid Grid.IsSharedSizeScope="True">
                    <Grid.Resources>
                        <Style TargetType="TextBlock">
                            <Setter Property="Margin"
                                    Value="0, 0, 20, 0" />
                            <Setter Property="FontSize"
                                    Value="14" />
                            <Setter Property="FontFamily"
                                    Value="Calibri" />
                            <Setter Property="FontWeight"
                                    Value="Bold" />
                            <Setter Property="Foreground"
                                    Value="{DynamicResource FontColor.Menu.Categories}" />
                            <Setter Property="VerticalAlignment"
                                    Value="Center" />
                            <Setter Property="Margin"
                                    Value="0 7.5 15 7.5" />
                        </Style>
                    </Grid.Resources>

                    <Grid.RowDefinitions>
                        <RowDefinition SharedSizeGroup="RowsHeight" />
                        <RowDefinition SharedSizeGroup="RowsHeight" />
                        <RowDefinition SharedSizeGroup="RowsHeight" />
                        <RowDefinition SharedSizeGroup="RowsHeight" />
                        <RowDefinition SharedSizeGroup="RowsHeight" />
                        <RowDefinition SharedSizeGroup="RowsHeight" />
                        <RowDefinition SharedSizeGroup="RowsHeight" />
                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.PhoneSupport.Disable}"
                               Grid.Row="0"
                               Grid.Column="0" />
                    <CheckBox x:Name="PhoneSupportCheck"
                              Style="{DynamicResource ToggleSwitch}"
                              IsChecked="{Binding ElementName=PhoneSettingsWindow, Path=IsPhoneSupportDisabled}"
                              Grid.Row="0"
                              Grid.Column="1"
                              HorizontalAlignment="Left"
                              Margin="0 7.5" />

                    <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.SwyxIt.PreferNative}"
                               Grid.Row="1"
                               Grid.Column="0" />
                    <CheckBox x:Name="SwyxNativeCheck"
                              IsChecked="{Binding ElementName=PhoneSettingsWindow, Path=IsNativeSwyxItPreferred}"
                              Style="{DynamicResource ToggleSwitch}"
                              Grid.Row="1"
                              Grid.Column="1"
                              HorizontalAlignment="Left"
                              Margin="0 7.5"
                              ToolTipService.ShowOnDisabled="True" />

                    <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.Tapi.PreferredLine}"
                               Grid.Row="2"
                               Grid.Column="0" />

                    <ComboBox x:Name="PreferredTapiLineComboBox"
                              MinWidth="150"
                              Grid.Row="2"
                              Grid.Column="1"
                              ToolTipService.ShowOnDisabled="True"
                              Margin="0 5" />

                    <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.Tapi.BitMode32}"
                               Grid.Row="3"
                               Grid.Column="0" />
                    <CheckBox x:Name="UseTapi32BitCheck"
                              IsChecked="{Binding ElementName=PhoneSettingsWindow, Path=UseTapi32Bit}"
                              Style="{DynamicResource ToggleSwitch}"
                              Grid.Row="3"
                              Grid.Column="1"
                              HorizontalAlignment="Left"
                              Margin="0 7.5"
                              ToolTipService.ShowOnDisabled="True" />
                    <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.Tapi.SignalOutgoingCalls}"
                               Grid.Row="4"
                               Grid.Column="0" />
                    <CheckBox x:Name="SignalOutgoingCalls"
                              IsChecked="{Binding ElementName=PhoneSettingsWindow, Path=boolSignalOutgoingCalls}"
                              Style="{DynamicResource ToggleSwitch}"
                              Grid.Row="4"
                              Grid.Column="1"
                              HorizontalAlignment="Left"
                              Margin="0 7.5"
                              ToolTipService.ShowOnDisabled="True" />
                    <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.Tapi.ShowUnresolvedPhoneNumbers}"
                               Grid.Row="5"
                               Grid.Column="0" />
                    <CheckBox x:Name="ShowUnresolvedPhoneNumbers"
                              IsChecked="{Binding ElementName=PhoneSettingsWindow, Path=boolShowUnresolvedPhoneNumbers}"
                              Style="{DynamicResource ToggleSwitch}"
                              Grid.Row="5"
                              Grid.Column="1"
                              HorizontalAlignment="Left"
                              Margin="0 7.5"
                              ToolTipService.ShowOnDisabled="True" />
                    <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=PhoneSettings.Tapi.ExternalCallPrefix}"
                               Grid.Row="6"
                               Grid.Column="0" />
                    <TextBox x:Name="ExternalCallPrefix"
                             Grid.Row="6" Grid.Column="1"
                             Style="{DynamicResource TextBoxStyle1}"
                             Text="{Binding ElementName=PhoneSettingsWindow, Path=strExternalCallPrefix, Mode=TwoWay}"
                             MaxLength="4"
                             FontSize="14"
                             Width="60"
                             HorizontalAlignment="Left"
                             Margin="0 5"/>
                </Grid>
            </Border>

            <Grid Grid.Row="2">

                <Grid.Resources>
                    <Style TargetType="ico:AdaptableIcon">
                        <Setter Property="Margin"
                                Value="0 10 0 0" />
                        <Setter Property="IconWidth"
                                Value="125" />
                        <Setter Property="PrimaryIconColor"
                                Value="{DynamicResource Color.Menu.Icon}" />
                        <Setter Property="BorderPadding"
                                Value="2.5" />
                        <Setter Property="HorizontalAlignment"
                                Value="Center" />
                        <Setter Property="Cursor"
                                Value="Hand" />

                        <EventSetter Event="MouseLeftButtonUp"
                                     Handler="DialogButton_MouseLeftButtonUp" />
                        <EventSetter Event="TouchDown"
                                     Handler="DialogButton_TouchDown" />
                    </Style>
                </Grid.Resources>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <ico:AdaptableIcon x:Name="ConfirmButton"
                                   Grid.Column="0"
                                   SelectedMaterialIcon="ic_check">
                    <ico:AdaptableIcon.Tag>
                        <sys:Boolean>True</sys:Boolean>
                    </ico:AdaptableIcon.Tag>
                    <ico:AdaptableIcon.Resources>
                        <Style TargetType="ico:AdaptableIcon"
                               BasedOn="{StaticResource  {x:Type ico:AdaptableIcon}}">
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver"
                                         Value="True">
                                    <Setter Property="PrimaryIconColor"
                                            Value="{DynamicResource Color.Green}" />
                                    <Setter Property="IconBackgroundColor"
                                            Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ico:AdaptableIcon.Resources>

                </ico:AdaptableIcon>

                <ico:AdaptableIcon x:Name="CancelButton"
                                   Grid.Column="1"
                                   SelectedMaterialIcon="ic_close">
                    <ico:AdaptableIcon.Tag>
                        <sys:Boolean>False</sys:Boolean>
                    </ico:AdaptableIcon.Tag>
                    <ico:AdaptableIcon.Resources>
                        <Style TargetType="ico:AdaptableIcon"
                               BasedOn="{StaticResource  {x:Type ico:AdaptableIcon}}">
                            <Setter Property="PrimaryIconColor"
                                    Value="{DynamicResource Color.Menu.Icon}" />
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver"
                                         Value="True">
                                    <Setter Property="PrimaryIconColor"
                                            Value="{DynamicResource Color.Red}" />
                                    <Setter Property="IconBackgroundColor"
                                            Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ico:AdaptableIcon.Resources>
                </ico:AdaptableIcon>

            </Grid>

        </Grid>

    </Border>

</settingspagebase:SettingsPageBase>
