1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
|
<!--
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.MainWindow"
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" UseLayoutRounding="True"
Title="GhostNet WPF example" Height="880" Width="870">
<!-- UseLayoutRounding needed to avoid funny interpolation effects on pages -->
<Window.Resources>
<ItemsPanelTemplate x:Key="MenuItemPanelTemplateNoIcon">
<StackPanel Margin="-20,0,0,0" Background="WhiteSmoke"/>
</ItemsPanelTemplate>
<DataTemplate x:Key="PageTemplate">
<Canvas Tag="{Binding PageName}" HorizontalAlignment="Center" VerticalAlignment="Top" Height="{Binding Height}" Width="{Binding Width}" Margin="0,0,0,0" ClipToBounds="True">
<Image Width="{Binding Width}" Height="{Binding Height}" Stretch="Fill" HorizontalAlignment="Center" Source="{Binding BitMap}">
<Image.BitmapEffect>
<DropShadowBitmapEffect Color="Black" Direction="-50" ShadowDepth="40" Softness=".7" />
</Image.BitmapEffect>
</Image>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="ThumbTemplate">
<Image Width="{Binding Width}" Height="{Binding Height}" Stretch="Fill" HorizontalAlignment="Center" Source="{Binding BitMap}" Margin="24,24,0,0">
<Image.BitmapEffect>
<DropShadowBitmapEffect Color="Black" Direction="-50"
ShadowDepth="5" Softness=".7" />
</Image.BitmapEffect>
</Image>
</DataTemplate>
</Window.Resources>
<!-- The following is needed to set up all the keyboard short cuts -->
<Window.CommandBindings>
<CommandBinding Command="Open" Executed="OpenFileCommand"></CommandBinding>
<CommandBinding Command="Close" Executed="CloseCommand"></CommandBinding>
<CommandBinding Command="Print" Executed="PrintCommand"></CommandBinding>
</Window.CommandBindings>
<Window.InputBindings>
<KeyBinding Key="O" Modifiers="Control" Command="Open"></KeyBinding>
<KeyBinding Key="W" Modifiers="Control" Command="Close"></KeyBinding>
<KeyBinding Key="P" Modifiers="Control" Command="Print"></KeyBinding>
</Window.InputBindings>
<DockPanel LastChildFill="True">
<Menu IsMainMenu="True" DockPanel.Dock="Top" Background="WhiteSmoke" FocusManager.IsFocusScope="False">
<MenuItem Header="_File" x:Name="xaml_file" VerticalAlignment="Center">
<MenuItem VerticalAlignment="Center" Padding="5" InputGestureText="Ctrl+O" Command="Open" >
<MenuItem.Header>
<TextBlock Margin="5,0,0,0" VerticalAlignment="Center" Text="Open..." ></TextBlock>
</MenuItem.Header>
</MenuItem>
<MenuItem Padding="5" Command="Close" InputGestureText="Ctrl+W" x:Name="xaml_closefile" VerticalAlignment="Center">
<MenuItem.Header>
<TextBlock Margin="5,0,0,0" Text="Close" VerticalAlignment="Center"></TextBlock>
</MenuItem.Header>
</MenuItem>
<MenuItem Padding="5" Command="Print" InputGestureText="Ctrl+W" x:Name="xaml_printfile" VerticalAlignment="Center">
<MenuItem.Header>
<TextBlock Margin="5,0,0,0" Text="Print" VerticalAlignment="Center"></TextBlock>
</MenuItem.Header>
</MenuItem>
<MenuItem Padding="5" Click="ShowGSMessage" x:Name="xaml_gsmessage" VerticalAlignment="Center" >
<MenuItem.Header>
<TextBlock Margin="5,0,0,0" Text="Show Messages" VerticalAlignment="Center"></TextBlock>
</MenuItem.Header>
</MenuItem>
</MenuItem>
<MenuItem Header="About" Click="OnAboutClick"/>
</Menu>
<WrapPanel Orientation="Horizontal" DockPanel.Dock="Top" Background="WhiteSmoke">
<TextBox x:Name="xaml_currPage" Grid.Row="0" Width="40" Height="20" VerticalScrollBarVisibility="Hidden" Padding="0"
HorizontalScrollBarVisibility="Hidden" TextAlignment="Center" Margin="20,2,0,2" PreviewKeyDown="PageEnterClicked" VerticalAlignment="Center"/>
<TextBlock Margin="2,0,0,0" Height="20" Text="/ 0" x:Name="xaml_TotalPages" Padding="0" VerticalAlignment="Center" Focusable="False">
<TextBlock.FontSize>12</TextBlock.FontSize>
</TextBlock>
<Button Margin="20 0 2 0" Width="20" Height="20" Click="ZoomIn" Background="Transparent" BorderBrush="DarkBlue" x:Name="xaml_zoomIn" Focusable="False">
<TextBlock Margin="0,0,0,0" Height="20" Text="+" FontWeight="Bold">
<TextBlock.FontSize>12</TextBlock.FontSize>
</TextBlock>
</Button>
<Button Margin="0 0 2 0" x:Name="xaml_zoomOut" Width="20" Height="20" Click="ZoomOut" Background="Transparent" BorderBrush="DarkBlue">
<TextBlock Margin="0,0,0,0" Height="20" Text="–" FontWeight="Bold">
<TextBlock.FontSize>12</TextBlock.FontSize>
</TextBlock>
</Button>
<TextBox Grid.Row="0" Grid.Column="2" Margin="0 0 0 0" Width="30" Height="20" VerticalScrollBarVisibility="Hidden"
HorizontalScrollBarVisibility="Hidden" TextAlignment="Left" x:Name="xaml_Zoomsize"
PreviewKeyDown="ZoomEnterClicked" TextChanged="ZoomTextChanged" VerticalAlignment="Center" Padding="0"/>
<TextBlock Margin="2,0,0,0" Height="20" Text="%">
<TextBlock.FontSize>12</TextBlock.FontSize>
</TextBlock>
<TextBlock Margin="20,0,0,0" Height="20" Text="Enable Antialias:">
<TextBlock.FontSize>12</TextBlock.FontSize>
</TextBlock>
<CheckBox x:Name="xaml_aa" Margin="2,2,0,0" Unchecked="AA_uncheck" Checked="AA_check" IsChecked="True"></CheckBox>
</WrapPanel>
<!-- The progress bar that runs during GS distilling -->
<Grid x:Name="xaml_DistillGrid" DockPanel.Dock="Bottom" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ProgressBar x:Name="xaml_DistillProgress" Grid.Row="0" Grid.Column="0" Margin="3" Minimum="0"
Maximum="100" Height="20" HorizontalAlignment="Stretch"/>
<TextBlock x:Name="xaml_DistillName" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="5, 0, 5, 0"><Bold>Distilling</Bold></TextBlock>
<Button Grid.Row="0" Grid.Column="2" Width="50" Height="20" Name="xaml_CancelDistill" Click="CancelDistillClick" Background="Transparent" BorderBrush="Transparent" Margin="5,0,5,0">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Rectangle Height="Auto" RadiusX="5" RadiusY="5">
<Rectangle.Fill >
<SolidColorBrush Color="LightSlateGray"></SolidColorBrush>
</Rectangle.Fill>
</Rectangle>
<ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Button.Template>
<TextBlock><Bold>Cancel</Bold></TextBlock>
</Button>
</Grid>
<Grid x:Name="xaml_PrintGrid" DockPanel.Dock="Bottom" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ProgressBar x:Name="xaml_PrintProgress" Grid.Row="0" Grid.Column="0" Margin="3" Minimum="0"
Maximum="100" Height="20" HorizontalAlignment="Stretch" />
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="5, 0, 5, 0"><Bold>Printing</Bold></TextBlock>
</Grid>
<!-- The progress bar that runs while the pages are rendered -->
<Grid x:Name="xaml_ProgressGrid" DockPanel.Dock="Bottom" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ProgressBar x:Name="xaml_RenderProgress" Grid.Row="0" Grid.Column="0" Margin="3" Minimum="0"
Maximum="100" Height="20" HorizontalAlignment="Stretch" />
<TextBlock x:Name="xaml_RenderProgressText" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="5, 0, 5, 0"><Bold>Creating Thumbs</Bold></TextBlock>
</Grid>
<!-- Thumb viewer/selector -->
<Grid x:Name="xaml_ThumbGrid" Width="150" Background="DarkGray" DockPanel.Dock="Left" Visibility="Collapsed">
<ListView x:Name="xaml_ThumbList" HorizontalAlignment="Stretch"
ItemTemplate="{StaticResource ThumbTemplate}"
ScrollViewer.CanContentScroll="False"
Background="DarkGray"
PreviewMouseLeftButtonUp="ThumbSelected">
</ListView>
</Grid>
<!-- Pages are last child fill. This goes in the center of dock panel ScrollViewer.CanContentScroll False allows continuous scrolling-->
<!-- <Grid x:Name="xaml_PageGrid" HorizontalAlignment="Stretch" Background="DarkGray" DockPanel.Dock="Left" AllowDrop="True"> -->
<ListView x:Name="xaml_PageList" HorizontalAlignment="Stretch"
ItemTemplate="{StaticResource PageTemplate}"
ScrollViewer.CanContentScroll="False"
Background="DarkGray"
ScrollViewer.IsDeferredScrollingEnabled="False"
IsHitTestVisible="True"
SelectionMode="Single"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.ScrollChanged="PageScrollChanged"
DockPanel.Dock="Left" AllowDrop="True"
>
<!-- This keeps the pages in the center of the panel -->
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Margin" Value="10"/>
<!-- This should be changed with PAGE_MARGIN -->
<Setter Property="Padding" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<!-- This overrides the blue back ground color of the current selection or mouse over -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Border x:Name="border" Background="Transparent">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled" />
</VisualStateGroup>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected" />
<VisualState x:Name="Selected">
</VisualState>
<VisualState x:Name="SelectedUnfocused">
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</DockPanel>
</Window>
|