summaryrefslogtreecommitdiff
path: root/platform/windows/gsview/PrintControl.xaml
blob: 8b9c30ae87216c5ee6dcfffdab845787c059f3d7 (plain)
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<Window x:Class="gsview.PrintControl"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="gsview print" Height="650" Width="653" 
        SizeToContent="WidthAndHeight" ResizeMode="NoResize">


    <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="Left" Background="WhiteSmoke" Visibility="Visible">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <GroupBox Grid.Column="0" Grid.Row="0" Header="Print Range" Height="150" 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="30" />
                        <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="2" Name="xaml_rbPages" VerticalAlignment="Center" GroupName="PageRange" Checked="PageRange">Pages</RadioButton>

                    <TextBox x:Name="xaml_pagerange" Grid.Column="1" Grid.Row="2" Width="100" Height="20" VerticalScrollBarVisibility="Hidden" HorizontalAlignment="Left"
                     HorizontalScrollBarVisibility="Hidden"  VerticalAlignment="Center" FontSize="12" FontFamily="Segoe UI" Margin="0,0,0,0" PreviewKeyDown="PageNumberEnter"/>

                    <TextBox x:Name="xaml_invalid" Grid.Column="1" Grid.Row="1" Width="Auto" Height="Auto" VerticalScrollBarVisibility="Hidden" HorizontalAlignment="Center" Background="WhiteSmoke" Visibility="Collapsed"
                     HorizontalScrollBarVisibility="Hidden" VerticalAlignment="Center"  Foreground="Red" Text="Invalid Range! (3-5, 7) e.g." FontSize="12" FontFamily="Segoe UI" Margin="0,0,0,0" PreviewKeyDown="PageNumberEnter"/>


                    <TextBox Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" Text="Subset:" FontSize="12" FontFamily="Segoe UI" Background="WhiteSmoke" BorderThickness="0"/>
                    <ComboBox Grid.Column="1" Grid.Row="3" x:Name="xaml_Subset" SelectionChanged="Subset_SelectionChanged" Width="140" Height="Auto" VerticalAlignment="Center" HorizontalAlignment="Left">
                        <ComboBoxItem Name="all" FontSize="11" FontFamily="Segoe UI">All pages in range</ComboBoxItem>
                        <ComboBoxItem Name="odd" FontSize="11" FontFamily="Segoe UI">Odd pages only</ComboBoxItem>
                        <ComboBoxItem Name="even" FontSize="11" FontFamily="Segoe UI">Even pages only</ComboBoxItem>
                    </ComboBox>
                </Grid>
            </GroupBox>

            <GroupBox Grid.Column="0" Grid.Row="1" Header="Page Handling" Height="90" Width="250" Margin="15,15,0,0" DockPanel.Dock="Left" HorizontalAlignment="Center" VerticalAlignment="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 Background="WhiteSmoke" Grid.Column="0" Grid.Row="2" Visibility="Visible" Margin="0, 50, 0, 0" HorizontalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Button Grid.Column="0" Grid.Row="0" Content="OK" FontSize="12" FontFamily="Segoe UI" HorizontalAlignment="Center" VerticalAlignment="Center" Width="74" Click="ClickOK" Margin="20,0,0,0"/>
                <Button Grid.Column="1" Grid.Row="0" Content="Cancel" FontSize="12" FontFamily="Segoe UI" HorizontalAlignment="Center" VerticalAlignment="Center" Width="74" Click="ClickCancel" Margin="40,0,0,0"/>
            </Grid>
        </Grid>


        <GroupBox Header="Preview" Height="450" Width="350" DockPanel.Dock="Right" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,15,15,0">
            <Grid Background="WhiteSmoke"  Visibility="Visible" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="40" />
                    <RowDefinition Height="40" />
                    <RowDefinition Height="40" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Canvas x:Name="xaml_TopArrowCanvas" Grid.Row="0" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="0,0,0,25" Height="0" Width="0" Visibility="Collapsed">
                    <Grid Background="WhiteSmoke" HorizontalAlignment="Center">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Line x:Name="xaml_topsize" Grid.Row="1" Y1="0" X1="0" X2="100" Y2="0" Stroke="Black" StrokeThickness="1"/>
                        <Line x:Name="xaml_topleftbottomarrow" Grid.Row="1" Y1="0" X1="0" X2="7" Y2="7" Stroke="Black" StrokeThickness="1" />
                        <Line x:Name="xaml_toplefttoparrow" Grid.Row="1" Y1="0" X1="0" X2="7" Y2="-7" Stroke="Black" StrokeThickness="1" />
                        <Line x:Name="xaml_toprighttoparrow" Grid.Row="1" Y1="-7" X1="93" X2="100" Y2="0" Stroke="Black" StrokeThickness="1"  />
                        <Line x:Name="xaml_toprightbottomarrow" Grid.Row="1" Y1="7" X1="93" X2="100" Y2="0" Stroke="Black" StrokeThickness="1"  />
                        <TextBlock x:Name="xaml_topsizevalue" Text="100" Grid.Row="0" HorizontalAlignment="Center"/>
                    </Grid>
                </Canvas>

                <Canvas x:Name="xaml_LeftArrowCanvas" Grid.Row="1" Grid.Column="0" Height="Auto" Width="40" VerticalAlignment="Top" HorizontalAlignment="Center" Visibility="Collapsed">
                    <Grid Background="WhiteSmoke" VerticalAlignment="Top" HorizontalAlignment="Center">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Line x:Name="xaml_leftsize" Grid.Column="1" Y1="0" X1="0" X2="0" Y2="100" Stroke="Black" StrokeThickness="1" />
                        <Line x:Name="xaml_lefttopleft" Grid.Column="1" Y1="0" X1="0" X2="-7" Y2="7" Stroke="Black" StrokeThickness="1" />
                        <Line x:Name="xaml_lefttopright" Grid.Column="1" Y1="0" X1="0" X2="7" Y2="7" Stroke="Black" StrokeThickness="1" />
                        <Line x:Name="xaml_leftbottomleft" Grid.Column="1" Y1="93" X1="-7" X2="0" Y2="100" Stroke="Black" StrokeThickness="1"  />
                        <Line x:Name="xaml_leftbottomright" Grid.Column="1" Y1="93" X1="7" X2="0" Y2="100" Stroke="Black" StrokeThickness="1"  />
                        <TextBlock x:Name="xaml_leftsizevalue" Text="100" Grid.Column="0" VerticalAlignment="Center" Margin="0,0,10,0"/>
                    </Grid>
                </Canvas>

                <!-- Draw the white paper full size white -->
                <Rectangle x:Name="xaml_PreviewPaper" Visibility="Collapsed" Fill="White" Grid.Column="1" Grid.Row="1" Height="0" Width="0" VerticalAlignment="Top" HorizontalAlignment="Left"/>

                <!-- Draw the whole image -->
                <Rectangle x:Name="xaml_PreviewImageRect" Visibility="Collapsed" Stroke="Red" Grid.Column="1" Grid.Row="1" Height="0" Width="0" VerticalAlignment="Top" HorizontalAlignment="Left">
                    <Rectangle.Fill>
                        <ImageBrush x:Name="xaml_ImagePreview">
                        </ImageBrush>
                    </Rectangle.Fill>
                </Rectangle>

                <!-- Draw the gray shade over it -->
                <Rectangle x:Name="xaml_PreviewGrayRect" Visibility="Collapsed" Stroke="Green" Fill="#7f7f7f7f" Grid.Column="1" Grid.Row="1" Height="0" Width="0" VerticalAlignment="Top" HorizontalAlignment="Left"/>

                <!-- Redraw with clipping -->
                <Rectangle x:Name="xaml_PreviewImageRectClip" Visibility="Collapsed" Stroke="Blue" Grid.Column="1" Grid.Row="1" Height="0" Width="0" VerticalAlignment="Top" HorizontalAlignment="Left">
                    <Rectangle.Fill>
                        <ImageBrush x:Name="xaml_ImagePreviewClip">
                        </ImageBrush>
                    </Rectangle.Fill>
                    <Rectangle.Clip>
                        <RectangleGeometry  x:Name="xaml_ImagePreviewClipGeom" Rect="0 0 50 100"/>
                    </Rectangle.Clip>
                </Rectangle>

                <!-- Draw the final full black bounding rect for the paper-->
                <Rectangle x:Name="xaml_PreviewPaperOuterRect" Stroke="Black" Fill="#00000000" Grid.Column="1" Grid.Row="1" Height="0" Width="0" VerticalAlignment="Top" HorizontalAlignment="Left"/>

                <Grid Grid.Column="1" Grid.Row="2" Height="Auto">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBox Visibility="Collapsed" x:Name="xaml_pagesize" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="12" FontFamily="Segoe UI" Background="WhiteSmoke" BorderThickness="0" Height="16" Width="Auto" />
                    <TextBox Visibility="Collapsed" x:Name="xaml_docsize" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="12" FontFamily="Segoe UI" Background="WhiteSmoke" BorderThickness="0" Height="16" Width="Auto" />
                </Grid>

                <TextBox x:Name="xaml_pagecount" Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right" Text="1/1" FontSize="12" FontFamily="Segoe UI" Background="WhiteSmoke" BorderThickness="0" Height="16" Margin="0,12" Width="Auto" />
                <Slider x:Name="xaml_pageslider" IsSnapToTickEnabled="True" Grid.Column="1" Grid.Row="3" Maximum="100" VerticalAlignment="Center" Margin="15,11,36,11" Height="18" PreviewMouseUp="PageSelect_DragCompleted"/>
                <TextBox Grid.Column="0" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Right" Text="Units:" FontSize="12" FontFamily="Segoe UI" Background="WhiteSmoke" BorderThickness="0" Height="16" Margin="0,12" Width="Auto" />
                <Grid Grid.Column="1" Grid.Row="4">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <RadioButton Grid.Column="0" Grid.Row="0" Name="xaml_inches" VerticalAlignment="Center" GroupName="units" Checked="Inches" Margin="5,0,0,0">inches</RadioButton>
                    <RadioButton Grid.Column="1" Grid.Row="0" Name="xaml_cm" VerticalAlignment="Center" GroupName="units" Checked="Centimeters" Margin="5,0,0,0">cm</RadioButton>
                </Grid>
            </Grid>
        </GroupBox>
    </DockPanel>
</Window>