<UserControl x:Class="CalculatorApp.CalculatorProgrammerRadixOperators"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:common="using:CalculatorApp.Common"
             xmlns:controls="using:CalculatorApp.Controls"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="using:CalculatorApp"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             x:Name="ControlRoot"
             d:DesignHeight="395"
             d:DesignWidth="315"
             Loaded="OnLoaded"
             Unloaded="OnUnloaded"
             mc:Ignorable="d">

    <Grid x:Name="ProgRadixOps">
        <Grid.RowDefinitions>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition x:Name="GutterLeft" Width="0"/>
            <ColumnDefinition x:Name="C0" Width="1*"/>
            <ColumnDefinition x:Name="C1" Width="1*"/>
            <ColumnDefinition x:Name="C2" Width="1*"/>
            <ColumnDefinition x:Name="C3" Width="1*"/>
            <ColumnDefinition x:Name="C4" Width="1*"/>
            <ColumnDefinition x:Name="C5" Width="1*"/>
            <ColumnDefinition x:Name="GutterRight" Width="0"/>
        </Grid.ColumnDefinitions>

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="ErrorVisualStates">
                <VisualState x:Name="NoErrorLayout"/>
                <VisualState x:Name="ErrorLayout">
                    <VisualState.Setters>
                        <Setter Target="RolButton.IsEnabled" Value="False"/>
                        <Setter Target="RorButton.IsEnabled" Value="False"/>
                        <Setter Target="LshButton.IsEnabled" Value="False"/>
                        <Setter Target="RshButton.IsEnabled" Value="False"/>
                        <Setter Target="OrButton.IsEnabled" Value="False"/>
                        <Setter Target="XorButton.IsEnabled" Value="False"/>
                        <Setter Target="NotButton.IsEnabled" Value="False"/>
                        <Setter Target="AndButton.IsEnabled" Value="False"/>

                        <Setter Target="ShiftButton.IsEnabled" Value="False"/>
                        <Setter Target="ModButton.IsEnabled" Value="False"/>

                        <Setter Target="DivideButton.IsEnabled" Value="False"/>
                        <Setter Target="MultiplyButton.IsEnabled" Value="False"/>
                        <Setter Target="MinusButton.IsEnabled" Value="False"/>
                        <Setter Target="PlusButton.IsEnabled" Value="False"/>

                        <Setter Target="OpenParenthesisButton.IsEnabled" Value="False"/>
                        <Setter Target="CloseParenthesisButton.IsEnabled" Value="False"/>
                        <Setter Target="NegateButton.IsEnabled" Value="False"/>
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup>
                <VisualState x:Name="Portrait768x1366">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowHeight="1366" MinWindowWidth="768"/>
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="ClearEntryButton.FontSize" Value="{StaticResource CalcOperatorCaptionSize}"/>
                        <Setter Target="ClearButton.FontSize" Value="{StaticResource CalcOperatorCaptionSize}"/>
                        <Setter Target="BackSpaceButton.FontSize" Value="{StaticResource CalcOperatorCaptionSize}"/>
                        <Setter Target="DivideButton.FontSize" Value="{StaticResource CalcOperatorCaptionSize}"/>
                        <Setter Target="MultiplyButton.FontSize" Value="{StaticResource CalcOperatorCaptionSize}"/>
                        <Setter Target="MinusButton.FontSize" Value="{StaticResource CalcOperatorCaptionSize}"/>
                        <Setter Target="PlusButton.FontSize" Value="{StaticResource CalcOperatorCaptionSize}"/>
                        <Setter Target="EqualButton.FontSize" Value="{StaticResource CalcOperatorCaptionSize}"/>

                        <Setter Target="AButton.FontSize" Value="{StaticResource TitleFontSize}"/>
                        <Setter Target="BButton.FontSize" Value="{StaticResource TitleFontSize}"/>
                        <Setter Target="CButton.FontSize" Value="{StaticResource TitleFontSize}"/>
                        <Setter Target="DButton.FontSize" Value="{StaticResource TitleFontSize}"/>
                        <Setter Target="EButton.FontSize" Value="{StaticResource TitleFontSize}"/>
                        <Setter Target="FButton.FontSize" Value="{StaticResource TitleFontSize}"/>

                        <Setter Target="NumberPad.ButtonStyle" Value="{StaticResource NumericButtonStyle24}"/>
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="FullLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowHeight="768" MinWindowWidth="1024"/>
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="NumberPad.ButtonStyle" Value="{StaticResource NumericButtonStyle24}"/>
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="MinSizeLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowHeight="{StaticResource AppMinWindowHeight}" MinWindowWidth="{StaticResource AppMinWindowWidth}"/>
                    </VisualState.StateTriggers>
                </VisualState>
                <VisualState x:Name="DefaultLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowHeight="0" MinWindowWidth="0"/>
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="OpenParenthesisButton.FontSize" Value="12"/>
                        <Setter Target="OpenParenthesisButton.Padding" Value="0"/>
                        <Setter Target="CloseParenthesisButton.FontSize" Value="12"/>
                        <Setter Target="CloseParenthesisButton.Padding" Value="0"/>

                        <Setter Target="NumberPad.ButtonStyle" Value="{StaticResource NumericButtonStyle12}"/>
                        <Setter Target="AButton.Style" Value="{StaticResource NumericButtonStyle12}"/>
                        <Setter Target="BButton.Style" Value="{StaticResource NumericButtonStyle12}"/>
                        <Setter Target="CButton.Style" Value="{StaticResource NumericButtonStyle12}"/>
                        <Setter Target="DButton.Style" Value="{StaticResource NumericButtonStyle12}"/>
                        <Setter Target="EButton.Style" Value="{StaticResource NumericButtonStyle12}"/>
                        <Setter Target="FButton.Style" Value="{StaticResource NumericButtonStyle12}"/>

                        <Setter Target="ShiftButton.Style" Value="{StaticResource CaptionToggleButtonSmallStyle}"/>
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Grid x:Uid="ProgrammerOperators"
              Grid.Column="1"
              Grid.ColumnSpan="6"
              AutomationProperties.HeadingLevel="Level1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <controls:CalculatorButton x:Name="RolButton"
                                       x:Uid="rolButton"
                                       Grid.Column="0"
                                       Style="{StaticResource OperatorButtonStyle}"
                                       FontSize="12"
                                       x:DeferLoadStrategy="Lazy"
                                       AutomationProperties.AutomationId="rolButton"
                                       ButtonId="Rol"
                                       Content="RoL"
                                       Visibility="Collapsed"/>
            <controls:CalculatorButton x:Name="RorButton"
                                       x:Uid="rorButton"
                                       Grid.Column="1"
                                       Style="{StaticResource OperatorButtonStyle}"
                                       FontSize="12"
                                       x:DeferLoadStrategy="Lazy"
                                       AutomationProperties.AutomationId="rorButton"
                                       ButtonId="Ror"
                                       Content="RoR"
                                       Visibility="Collapsed"/>
            <controls:CalculatorButton x:Name="LshButton"
                                       x:Uid="lshButton"
                                       Grid.Column="0"
                                       Style="{StaticResource OperatorButtonStyle}"
                                       FontSize="12"
                                       AutomationProperties.AutomationId="lshButton"
                                       ButtonId="Lsh"
                                       Content="Lsh"/>
            <controls:CalculatorButton x:Name="RshButton"
                                       x:Uid="rshButton"
                                       Grid.Column="1"
                                       Style="{StaticResource OperatorButtonStyle}"
                                       FontSize="12"
                                       AutomationProperties.AutomationId="rshButton"
                                       ButtonId="Rsh"
                                       Content="Rsh"/>
            <controls:CalculatorButton x:Name="OrButton"
                                       x:Uid="orButton"
                                       Grid.Column="2"
                                       Style="{StaticResource OperatorButtonStyle}"
                                       FontSize="12"
                                       AutomationProperties.AutomationId="orButton"
                                       ButtonId="Or"
                                       Content="Or"/>
            <controls:CalculatorButton x:Name="XorButton"
                                       x:Uid="xorButton"
                                       Grid.Column="3"
                                       Style="{StaticResource OperatorButtonStyle}"
                                       FontSize="12"
                                       AutomationProperties.AutomationId="xorButton"
                                       ButtonId="Xor"
                                       Content="Xor"/>
            <controls:CalculatorButton x:Name="NotButton"
                                       x:Uid="notButton"
                                       Grid.Column="4"
                                       Style="{StaticResource OperatorButtonStyle}"
                                       FontSize="12"
                                       AutomationProperties.AutomationId="notButton"
                                       ButtonId="Not"
                                       Content="Not"/>
            <controls:CalculatorButton x:Name="AndButton"
                                       x:Uid="andButton"
                                       Grid.Column="5"
                                       Style="{StaticResource OperatorButtonStyle}"
                                       FontSize="12"
                                       AutomationProperties.AutomationId="andButton"
                                       ButtonId="And"
                                       Content="And"/>
        </Grid>

        <ToggleButton x:Name="ShiftButton"
                      x:Uid="shiftButton"
                      Grid.Row="1"
                      Grid.Column="1"
                      HorizontalAlignment="Stretch"
                      VerticalAlignment="Stretch"
                      Style="{StaticResource CaptionToggleButtonStyle}"
                      FontFamily="{StaticResource CalculatorFontFamily}"
                      FontSize="16"
                      AutomationProperties.AutomationId="shiftButton"
                      Checked="Shift_Clicked"
                      Content="&#xF897;"
                      Unchecked="Shift_Clicked"/>
        <controls:CalculatorButton x:Name="ModButton"
                                   x:Uid="modButton"
                                   Grid.Row="1"
                                   Grid.Column="2"
                                   Style="{StaticResource OperatorButtonStyle}"
                                   FontSize="12"
                                   AutomationProperties.AutomationId="modButton"
                                   ButtonId="Mod"
                                   Content="Mod"/>

        <Grid x:Uid="StandardOperators"
              Grid.Row="1"
              Grid.RowSpan="5"
              Grid.Column="6"
              AutomationProperties.HeadingLevel="Level1">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <controls:CalculatorButton x:Name="DivideButton"
                                       x:Uid="divideButton"
                                       Grid.Row="0"
                                       Style="{StaticResource AccentCalcButtonStyle}"
                                       FontSize="12"
                                       AutomationProperties.AutomationId="divideButton"
                                       ButtonId="Divide"
                                       Content="&#xE94A;"/>
            <controls:CalculatorButton x:Name="MultiplyButton"
                                       x:Uid="multiplyButton"
                                       Grid.Row="1"
                                       Style="{StaticResource AccentCalcButtonStyle}"
                                       FontSize="12"
                                       AutomationProperties.AutomationId="multiplyButton"
                                       ButtonId="Multiply"
                                       Content="&#xE947;"/>
            <controls:CalculatorButton x:Name="MinusButton"
                                       x:Uid="minusButton"
                                       Grid.Row="2"
                                       Style="{StaticResource AccentCalcButtonStyle}"
                                       FontSize="12"
                                       AutomationProperties.AutomationId="minusButton"
                                       ButtonId="Subtract"
                                       Content="&#xE949;"/>
            <controls:CalculatorButton x:Name="PlusButton"
                                       x:Uid="plusButton"
                                       Grid.Row="3"
                                       Style="{StaticResource AccentCalcButtonStyle}"
                                       FontSize="12"
                                       AutomationProperties.AutomationId="plusButton"
                                       ButtonId="Add"
                                       Content="&#xE948;"/>
            <controls:CalculatorButton x:Name="EqualButton"
                                       x:Uid="equalButton"
                                       Grid.Row="4"
                                       Style="{StaticResource AccentCalcButtonStyle}"
                                       FontSize="12"
                                       AutomationProperties.AutomationId="equalButton"
                                       ButtonId="Equals"
                                       Content="&#xE94E;"/>
        </Grid>

        <Grid x:Uid="DisplayControls"
              Grid.Row="1"
              Grid.Column="3"
              Grid.ColumnSpan="3"
              AutomationProperties.HeadingLevel="Level1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <controls:CalculatorButton x:Name="ClearEntryButton"
                                       x:Uid="clearEntryButton"
                                       Grid.Column="0"
                                       Style="{StaticResource OperatorButtonStyle}"
                                       FontSize="12"
                                       FontWeight="SemiBold"
                                       AutomationProperties.AutomationId="clearEntryButton"
                                       ButtonId="ClearEntry"
                                       Content="CE"/>
            <controls:CalculatorButton x:Name="ClearButton"
                                       x:Uid="clearButton"
                                       Grid.Column="1"
                                       Style="{StaticResource OperatorButtonStyle}"
                                       FontSize="12"
                                       FontWeight="SemiBold"
                                       AutomationProperties.AutomationId="clearButton"
                                       ButtonId="Clear"
                                       Content="C"/>
            <controls:CalculatorButton x:Name="BackSpaceButton"
                                       x:Uid="backSpaceButton"
                                       Grid.Column="2"
                                       Style="{StaticResource SymbolOperatorButtonStyle}"
                                       FontSize="12"
                                       AutomationProperties.AutomationId="backSpaceButton"
                                       ButtonId="Backspace"
                                       Content="&#xE94F;"/>
        </Grid>

        <Grid x:Uid="NumberPad"
              Grid.Row="2"
              Grid.RowSpan="4"
              Grid.Column="1"
              Grid.ColumnSpan="5"
              AutomationProperties.AutomationId="NumberPad"
              AutomationProperties.HeadingLevel="Level1">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <local:NumberPad x:Name="NumberPad"
                             Grid.RowSpan="4"
                             Grid.Column="2"
                             Grid.ColumnSpan="3"
                             ButtonStyle="{StaticResource NumericButtonStyle18}"/>

            <controls:CalculatorButton x:Name="AButton"
                                       x:Uid="aButton"
                                       Grid.Row="0"
                                       Grid.Column="0"
                                       Style="{StaticResource NumericButtonStyle12}"
                                       AutomationProperties.AutomationId="aButton"
                                       ButtonId="A"
                                       Content="A"
                                       IsEnabled="{x:Bind Model.AreHEXButtonsEnabled, Mode=OneWay}"/>
            <controls:CalculatorButton x:Name="BButton"
                                       x:Uid="bButton"
                                       Grid.Row="0"
                                       Grid.Column="1"
                                       Style="{StaticResource NumericButtonStyle12}"
                                       AutomationProperties.AutomationId="bButton"
                                       ButtonId="B"
                                       Content="B"
                                       IsEnabled="{x:Bind Model.AreHEXButtonsEnabled, Mode=OneWay}"/>
            <controls:CalculatorButton x:Name="CButton"
                                       x:Uid="cButton"
                                       Grid.Row="1"
                                       Grid.Column="0"
                                       Style="{StaticResource NumericButtonStyle12}"
                                       AutomationProperties.AutomationId="cButton"
                                       ButtonId="C"
                                       Content="C"
                                       IsEnabled="{x:Bind Model.AreHEXButtonsEnabled, Mode=OneWay}"/>
            <controls:CalculatorButton x:Name="DButton"
                                       x:Uid="dButton"
                                       Grid.Row="1"
                                       Grid.Column="1"
                                       Style="{StaticResource NumericButtonStyle12}"
                                       AutomationProperties.AutomationId="dButton"
                                       ButtonId="D"
                                       Content="D"
                                       IsEnabled="{x:Bind Model.AreHEXButtonsEnabled, Mode=OneWay}"/>
            <controls:CalculatorButton x:Name="EButton"
                                       x:Uid="eButton"
                                       Grid.Row="2"
                                       Grid.Column="0"
                                       Style="{StaticResource NumericButtonStyle12}"
                                       AutomationProperties.AutomationId="eButton"
                                       ButtonId="E"
                                       Content="E"
                                       IsEnabled="{x:Bind Model.AreHEXButtonsEnabled, Mode=OneWay}"/>
            <controls:CalculatorButton x:Name="FButton"
                                       x:Uid="fButton"
                                       Grid.Row="2"
                                       Grid.Column="1"
                                       Style="{StaticResource NumericButtonStyle12}"
                                       AutomationProperties.AutomationId="fButton"
                                       ButtonId="F"
                                       Content="F"
                                       IsEnabled="{x:Bind Model.AreHEXButtonsEnabled, Mode=OneWay}"/>
        </Grid>

        <controls:CalculatorButton x:Name="OpenParenthesisButton"
                                   x:Uid="openParenthesisButton"
                                   Grid.Row="5"
                                   Grid.Column="1"
                                   Style="{StaticResource ParenthesisCalcButtonStyle}"
                                   FontSize="18"
                                   AutomationProperties.AutomationId="openParenthesisButton"
                                   ButtonId="OpenParenthesis"
                                   Content="("
                                   GotFocus="OpenParenthesisButton_GotFocus"
                                   Tag="{x:Bind ParenthesisCountToString(Model.OpenParenthesisCount), Mode=OneWay}"/>
        <controls:CalculatorButton x:Name="CloseParenthesisButton"
                                   x:Uid="closeParenthesisButton"
                                   Grid.Row="5"
                                   Grid.Column="2"
                                   Style="{StaticResource OperatorButtonStyle}"
                                   FontSize="18"
                                   AutomationProperties.AutomationId="closeParenthesisButton"
                                   ButtonId="CloseParenthesis"
                                   Content=")"/>
        <controls:CalculatorButton x:Name="NegateButton"
                                   x:Uid="negateButton"
                                   Grid.Row="5"
                                   Grid.Column="3"
                                   Style="{StaticResource SymbolOperatorButtonStyle}"
                                   FontSize="12"
                                   AutomationProperties.AutomationId="negateButton"
                                   ButtonId="Negate"
                                   Content="&#xF898;"/>
    </Grid>
</UserControl>
