<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"
    xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
    Title="TextExtractor"
    ui:Design.Background="Transparent"
    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">

    <Window.Resources>
        <Style BasedOn="{StaticResource DefaultToggleButtonStyle}" TargetType="{x:Type ToggleButton}">
            <Setter Property="Margin" Value="4,0" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="Width" Value="32" />
            <Setter Property="Height" Value="32" />
            <Setter Property="Background" Value="Transparent" />
        </Style>

        <Style BasedOn="{StaticResource DefaultButtonStyle}" TargetType="{x:Type Button}">
            <Setter Property="Margin" Value="4,0" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="Width" Value="32" />
            <Setter Property="Height" Value="32" />
            <Setter Property="Background" Value="Transparent" />
        </Style>
    </Window.Resources>

    <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"
                        Click="CancelMenuItem_Click"
                        Header="{x:Static p:Resources.Cancel}" />
                </ContextMenu>
            </Canvas.ContextMenu>
        </Canvas>
        <Border
            x:Name="TopButtonsStackPanel"
            Margin="12"
            Padding="4,8,12,8"
            HorizontalAlignment="Center"
            VerticalAlignment="Top"
            d:Visibility="Visible"
            Background="{DynamicResource ApplicationBackgroundBrush}"
            CornerRadius="8"
            Visibility="Collapsed">
            <Border.Effect>
                <DropShadowEffect
                    BlurRadius="32"
                    Opacity="0.28"
                    RenderingBias="Performance"
                    ShadowDepth="1" />
            </Border.Effect>

            <StackPanel
                HorizontalAlignment="Center"
                VerticalAlignment="Top"
                Orientation="Horizontal">
                <ComboBox
                    x:Name="LanguagesComboBox"
                    Height="32"
                    Margin="4,0"
                    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"
                    d:IsChecked="True"
                    AutomationProperties.Name="{x:Static p:Resources.ResultTextSingleLine}"
                    Click="SingleLineMenuItem_Click"
                    IsChecked="{Binding IsChecked, ElementName=SingleLineMenuItem, Mode=TwoWay}"
                    ToolTip="{x:Static p:Resources.ResultTextSingleLineShortcut}">
                    <ui:SymbolIcon FontSize="18" Symbol="SubtractSquare24" />
                </ToggleButton>
                <ToggleButton
                    x:Name="TableToggleButton"
                    d:IsChecked="True"
                    AutomationProperties.Name="{x:Static p:Resources.ResultTextTable}"
                    Click="TableToggleButton_Click"
                    IsChecked="{Binding IsChecked, ElementName=TableMenuItem, Mode=TwoWay}"
                    ToolTip="{x:Static p:Resources.ResultTextTableShortcut}">
                    <ui:SymbolIcon FontSize="18" Symbol="Table24" />
                </ToggleButton>
                <Button
                    x:Name="SettingsButton"
                    AutomationProperties.Name="{x:Static p:Resources.Settings}"
                    Click="SettingsMenuItem_Click"
                    ToolTip="{x:Static p:Resources.Settings}">
                    <ui:SymbolIcon FontSize="18" Symbol="Settings24" />
                </Button>
                <Button
                    x:Name="CancelButton"
                    Click="CancelMenuItem_Click"
                    ToolTip="{x:Static p:Resources.CancelShortcut}">
                    <ui:SymbolIcon FontSize="18" Symbol="Dismiss24" />
                </Button>
            </StackPanel>
        </Border>
    </Grid>
</Window>
