<Window
    x:Class="PowerOCR.OCROverlay"
    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:p="clr-namespace:PowerOCR.Properties"
    x:Name="TextExtractorWindow"
    Title="TextExtractor"
    AllowsTransparency="True"
    Background="Transparent"
    Loaded="Window_Loaded"
    ResizeMode="NoResize"
    ShowActivated="False"
    ShowInTaskbar="False"
    Topmost="True"
    Unloaded="Window_Unloaded"
    WindowStartupLocation="Manual"
    WindowState="Normal"
    WindowStyle="None"
    mc:Ignorable="d">

    <Grid>
        <Viewbox>
            <Image x:Name="BackgroundImage" Stretch="UniformToFill" />
        </Viewbox>
        <Canvas
            Name="RegionClickCanvas"
            Cursor="Cross"
            MouseDown="RegionClickCanvas_MouseDown"
            MouseMove="RegionClickCanvas_MouseMove"
            MouseUp="RegionClickCanvas_MouseUp">
            <Canvas.Clip>
                <CombinedGeometry GeometryCombineMode="Exclude">
                    <CombinedGeometry.Geometry1>
                        <RectangleGeometry x:Name="FullWindow" />
                    </CombinedGeometry.Geometry1>
                    <CombinedGeometry.Geometry2>
                        <RectangleGeometry x:Name="clippingGeometry" />
                    </CombinedGeometry.Geometry2>
                </CombinedGeometry>
            </Canvas.Clip>
            <Canvas.Background>
                <SolidColorBrush
                    x:Name="BackgroundBrush"
                    Opacity="0"
                    Color="Black" />
            </Canvas.Background>
            <Canvas.ContextMenu>
                <ContextMenu x:Name="CanvasContextMenu">
                    <MenuItem
                        Name="SingleLineMenuItem"
                        Click="SingleLineMenuItem_Click"
                        Header="{x:Static p:Resources.ResultTextSingleLine}"
                        IsCheckable="True" />
                    <MenuItem
                        Name="TableMenuItem"
                        Click="TableToggleButton_Click"
                        Header="{x:Static p:Resources.ResultTextTable}"
                        IsCheckable="True" />
                    <Separator />
                    <MenuItem
                        Name="SettingsMenuItem"
                        Click="SettingsMenuItem_Click"
                        Header="{x:Static p:Resources.Settings}" />
                    <Separator />
                    <MenuItem
                        Name="CancelMenuItem"
                        AutomationProperties.AutomationId="CancelMenuItem"
                        Click="CancelMenuItem_Click"
                        Header="{x:Static p:Resources.Cancel}" />
                </ContextMenu>
            </Canvas.ContextMenu>
        </Canvas>
        <Border
            x:Name="TopButtonsStackPanel"
            Margin="12"
            Padding="4,8,4,8"
            HorizontalAlignment="Center"
            VerticalAlignment="Top"
            d:Visibility="Visible"
            Background="{DynamicResource SolidBackgroundFillColorBaseBrush}"
            BorderBrush="{DynamicResource SurfaceStrokeColorDefaultBrush}"
            BorderThickness="1"
            CornerRadius="8"
            Visibility="Collapsed">
            <StackPanel
                HorizontalAlignment="Center"
                VerticalAlignment="Top"
                Orientation="Horizontal">
                <ComboBox
                    x:Name="LanguagesComboBox"
                    Margin="4,0"
                    AutomationProperties.AutomationId="OCROverlayLanguagesComboBox"
                    AutomationProperties.Name="{x:Static p:Resources.SelectedLang}"
                    SelectionChanged="LanguagesComboBox_SelectionChanged">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock
                                HorizontalAlignment="Left"
                                VerticalAlignment="Center"
                                Text="{Binding NativeName}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                <ToggleButton
                    x:Name="SingleLineToggleButton"
                    Width="32"
                    Height="32"
                    Margin="4,0"
                    Padding="0"
                    d:IsChecked="True"
                    AutomationProperties.Name="{x:Static p:Resources.ResultTextSingleLine}"
                    Click="SingleLineMenuItem_Click"
                    IsChecked="{Binding IsChecked, ElementName=SingleLineMenuItem, Mode=TwoWay}"
                    Style="{DynamicResource SubtleToggleButtonStyle}"
                    ToolTip="{x:Static p:Resources.ResultTextSingleLineShortcut}">
                    <TextBlock
                        FontFamily="{DynamicResource SymbolThemeFontFamily}"
                        FontSize="16"
                        Text="&#xF16E;" />
                </ToggleButton>
                <ToggleButton
                    x:Name="TableToggleButton"
                    Width="32"
                    Height="32"
                    Margin="4,0"
                    Padding="0"
                    d:IsChecked="True"
                    AutomationProperties.Name="{x:Static p:Resources.ResultTextTable}"
                    Click="TableToggleButton_Click"
                    IsChecked="{Binding IsChecked, ElementName=TableMenuItem, Mode=TwoWay}"
                    Style="{DynamicResource SubtleToggleButtonStyle}"
                    ToolTip="{x:Static p:Resources.ResultTextTableShortcut}">
                    <TextBlock
                        FontFamily="{DynamicResource SymbolThemeFontFamily}"
                        FontSize="16"
                        Text="&#xE80A;" />
                </ToggleButton>
                <Button
                    x:Name="SettingsButton"
                    Width="32"
                    Height="32"
                    Margin="4,0"
                    Padding="0"
                    AutomationProperties.Name="{x:Static p:Resources.Settings}"
                    Click="SettingsMenuItem_Click"
                    Style="{DynamicResource SubtleButtonStyle}"
                    ToolTip="{x:Static p:Resources.Settings}">
                    <TextBlock
                        FontFamily="{DynamicResource SymbolThemeFontFamily}"
                        FontSize="16"
                        Text="&#xE713;" />
                </Button>
                <Button
                    x:Name="CancelButton"
                    Width="32"
                    Height="32"
                    Margin="4,0"
                    Padding="0"
                    AutomationProperties.Name="{x:Static p:Resources.Cancel}"
                    Click="CancelMenuItem_Click"
                    Style="{DynamicResource SubtleButtonStyle}"
                    ToolTip="{x:Static p:Resources.CancelShortcut}">
                    <TextBlock
                        FontFamily="{DynamicResource SymbolThemeFontFamily}"
                        FontSize="16"
                        Text="&#xE711;" />
                </Button>
            </StackPanel>
        </Border>
    </Grid>
</Window>
