<!--
   Copyright (C) 2020-2023 Artifex Software, Inc.
   All Rights Reserved.

   This software is provided AS-IS with no warranty, either express or
   implied.

   This software is distributed under license and may not be copied,
   modified or distributed except as expressly authorized under the terms
   of the license contained in the file LICENSE in this distribution.

   Refer to licensing information at http://www.artifex.com or contact
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
   CA 94129, USA, for further information.
-->

<Window x:Class="ghostnet_wpf_example.Print"
        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:ghostnet_wpf_example"
        mc:Ignorable="d"
        Title="Ghostnet XPS Print" Height="325" Width="550"
        SizeToContent="WidthAndHeight" ResizeMode="NoResize" 
        FontFamily="Segou UI" FontSize="12">
    
    
    <Window.Resources>
        <Style x:Key="MySimpleScrollBar" TargetType="{x:Type ScrollBar}">
            <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
            <Setter Property="Width" Value="Auto"/>
            <Setter Property="MinHeight" Value="30"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ScrollBar}">
                        <Border BorderThickness="1" BorderBrush="Gray">
                            <Grid Margin="2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <TextBox VerticalAlignment="Center" FontSize="12" MinWidth="25" Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}}"/>
                                <Grid Grid.Column="1" x:Name="GridRoot" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Background="{TemplateBinding Background}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition MaxHeight="18"/>
                                        <RowDefinition Height="0.00001*"/>
                                        <RowDefinition MaxHeight="18"/>
                                    </Grid.RowDefinitions>
                                    <RepeatButton x:Name="DecreaseRepeat" Command="ScrollBar.LineDownCommand" Focusable="False">
                                        <Grid>
                                            <Path x:Name="DecreaseArrow" Stroke="{TemplateBinding Foreground}" StrokeThickness="1" Data="M 0 4 L 8 4 L 4 0 Z"/>
                                        </Grid>
                                    </RepeatButton>
                                    <RepeatButton Grid.Row="2" x:Name="IncreaseRepeat" Command="ScrollBar.LineUpCommand" Focusable="False">
                                        <Grid>
                                            <Path x:Name="IncreaseArrow" Stroke="{TemplateBinding Foreground}" StrokeThickness="1" Data="M 0 0 L 4 4 L 8 0 Z"/>
                                        </Grid>
                                    </RepeatButton>
                                </Grid>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>

    <DockPanel Background="WhiteSmoke" LastChildFill="False" Margin="0,0,0,0">
        <GroupBox Header="Printer" Height="100" Width="500" DockPanel.Dock="Top" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="15,15,0,0">
            <Grid Background="WhiteSmoke"  Visibility="Visible" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid Grid.Column="0" Grid.Row="0" Background="WhiteSmoke">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30" />
                        <RowDefinition Height="30" />
                    </Grid.RowDefinitions>
                    <TextBox Grid.Column="0" Grid.Row="0" Text="Name:" FontSize="12" FontFamily="Segoe UI" Background="WhiteSmoke" BorderThickness="0" VerticalAlignment="Center"/>
                    <TextBox Grid.Column="0" Grid.Row="1" Text="Status:" FontSize="12" FontFamily="Segoe UI" Background="WhiteSmoke" BorderThickness="0" VerticalAlignment="Center"/>
                </Grid>
                <Grid Grid.Column="1" Grid.Row="0" Background="WhiteSmoke">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30" />
                        <RowDefinition Height="30" />
                    </Grid.RowDefinitions>
                    <ComboBox Grid.Column="0" Grid.Row="0" x:Name="xaml_selPrinter" SelectionChanged="selPrinterChanged" Width="225" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Center" >
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock FontSize="11" FontFamily="Segoe UI" Text="{Binding Name}" />
                                </StackPanel>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                    <TextBox Grid.Column="0" Grid.Row="1" x:Name="xaml_Status" FontSize="12" FontFamily="Segoe UI" Text="" Margin="105,92,497,301" Background="WhiteSmoke" BorderThickness="0"/>
                </Grid>
                <Grid Grid.Column="2" Grid.Row="0" Background="WhiteSmoke">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30" />
                    </Grid.RowDefinitions>
                    <Button Grid.Column="0" Grid.Row="0" Content="Properties" FontSize="12" FontFamily="Segoe UI" HorizontalAlignment="Center" Margin="0, 0, 30, 0" VerticalAlignment="Center" Width="75" Click="ShowProperties"/>
                </Grid>
            </Grid>
        </GroupBox>
        <Grid DockPanel.Dock="Top" Background="WhiteSmoke" Visibility="Visible">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <GroupBox Grid.Column="0" Grid.Row="0" Header="Print Range" Height="130" Width="250" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="15,15,0,0">
                <Grid Background="WhiteSmoke"  Visibility="Visible" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30" />
                        <RowDefinition Height="30" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="30" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="90" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <RadioButton Grid.Column="0" Grid.Row="0" Name="xaml_rbAll" VerticalAlignment="Center" GroupName="PageRange" Checked="AllPages">All</RadioButton>
                    <RadioButton Grid.Column="0" Grid.Row="1" Name="xaml_rbCurrent" VerticalAlignment="Center" GroupName="PageRange" Checked="CurrentPage">Current page</RadioButton>
                    <RadioButton Grid.Column="0" Grid.Row="3" Name="xaml_rbPages" VerticalAlignment="Center" GroupName="PageRange" Checked="PageRange">Pages</RadioButton>

                    <TextBox Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Text="From" FontSize="12" FontFamily="Segoe UI" Background="WhiteSmoke" BorderThickness="0" />
                    <TextBox Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Text="To" FontSize="12" Margin="70,0,0,0" FontFamily="Segoe UI" Background="WhiteSmoke" BorderThickness="0" />
                    <TextBox x:Name="xaml_pagestart" Grid.Column="1" Grid.Row="3" Width="50" Height="20" VerticalScrollBarVisibility="Hidden" HorizontalAlignment="Left"
                     HorizontalScrollBarVisibility="Hidden"  VerticalAlignment="Center" FontSize="12" FontFamily="Segoe UI" Margin="0,0,0,0" PreviewTextInput="PreviewTextInputFrom"
                             TextChanged="FromChanged"/>
                    <TextBox x:Name="xaml_pageend" Grid.Column="1" Grid.Row="3" Width="50" Height="20" VerticalScrollBarVisibility="Hidden" HorizontalAlignment="Left"
                     HorizontalScrollBarVisibility="Hidden"  VerticalAlignment="Center" FontSize="12" FontFamily="Segoe UI" Margin="70,0,0,0" PreviewTextInput="PreviewTextInputTo" 
                            TextChanged="ToChanged"/>
                </Grid>
            </GroupBox>

            <GroupBox Grid.Column="1" Grid.Row="0" Header="Page Handling" Height="90" Width="250" Margin="0,-25,0,0" DockPanel.Dock="Right" HorizontalAlignment="Center" >
                <Grid Background="WhiteSmoke" Visibility="Visible" Height="103" VerticalAlignment="Top">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="90" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBox Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" Text="Copies:" FontSize="12" FontFamily="Segoe UI" Background="WhiteSmoke" BorderThickness="0" />
                    <ScrollBar Grid.Column="1" Grid.Row="0" x:Name="xaml_Copies" HorizontalAlignment="Left" Style="{DynamicResource MySimpleScrollBar}" VerticalAlignment="Top" Value="1" Maximum="999" SmallChange="1" Height="15" ValueChanged="xaml_Copies_ValueChanged"/>
                    <CheckBox x:Name="xaml_autofit" Grid.Column="0" Grid.Row="2" Content="Auto-Fit" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Checked="AutoFit_Checked" Unchecked="AutoFit_Unchecked" Grid.ColumnSpan="2"/>
                </Grid>
            </GroupBox>
        </Grid>

        <Button Content="OK" FontSize="12" FontFamily="Segoe UI" HorizontalAlignment="Center" VerticalAlignment="Top" Width="74" Click="ClickOK" Margin="300,-30,0,0"/>
        <Button Content="Cancel" FontSize="12" FontFamily="Segoe UI" HorizontalAlignment="Center" VerticalAlignment="Top" Width="74" Click="ClickCancel" Margin="40,-30,0,0"/>


    </DockPanel>
</Window>
