summaryrefslogtreecommitdiff
path: root/platform/winrt/gsview/MainWindow.xaml
blob: 10d126bb5e6fc67f2e5e04d439af023a5da92b98 (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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
<Window x:Class="gsview.MainWindow"
        xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="gsview" Height="850" Width="714" UseLayoutRounding="True" 
        KeyDown="OnKeyDownHandler" Closing="AppClosing">
    <!-- UseLayoutRounding needed to avoid funny interpolation effects on pages -->

    <Window.Resources>
        <DataTemplate x:Key="PageTemplate">
            <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="{Binding Height}" Width="{Binding Width}" Margin="0,0,0,0" 
                    MouseLeftButtonDown="PageMouseDown" MouseMove="PageMouseMove" MouseLeftButtonUp="PageLeftClickUp" ClipToBounds="True"
                    MouseRightButtonDown="ShowContextMenu">
                <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>
                
                <!-- Single selection rectangle.  Not a list -->
                <Rectangle Width="{Binding Path=SelWidth}" Height="{Binding Path=SelHeight}" Stroke="{Binding Path=SelColor}">
                    <Rectangle.RenderTransform>
                        <TranslateTransform X="{Binding Path=SelX}" Y="{Binding Path=SelY}"/>
                    </Rectangle.RenderTransform>
                </Rectangle>
                
                <ItemsControl ItemsSource="{Binding Path=TextBox}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <Canvas/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Rectangle Tag="{Binding Path=Index}" Width="{Binding Path=Width}" Height="{Binding Path=Height}" Fill="{Binding Path=Color}">
                                <Rectangle.RenderTransform>
                                    <TranslateTransform X="{Binding Path=X}" Y="{Binding Path=Y}"/>
                                </Rectangle.RenderTransform>
                            </Rectangle>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

                <ItemsControl ItemsSource="{Binding Path=SelectedLines}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <Canvas/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Rectangle Width="{Binding Path=Width}" Height="{Binding Path=Height}" Fill="{Binding Path=Color}">
                                <Rectangle.RenderTransform>
                                    <TranslateTransform X="{Binding Path=X}" Y="{Binding Path=Y}"/>
                                </Rectangle.RenderTransform>
                            </Rectangle>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

                <ItemsControl ItemsSource="{Binding Path=TextBlocks}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <Canvas/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Rectangle Width="{Binding Path=Width}" Height="{Binding Path=Height}" Fill="{Binding Path=Color}" MouseLeave="ExitTextBlock" MouseEnter="EnterTextBlock">
                                <Rectangle.RenderTransform>
                                    <TranslateTransform X="{Binding Path=X}" Y="{Binding Path=Y}"/>
                                </Rectangle.RenderTransform>
                            </Rectangle>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

                <ItemsControl ItemsSource="{Binding Path=LinkBox}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <Canvas/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Rectangle Tag="{Binding Path=Index}" Width="{Binding Path=Width}" Height="{Binding Path=Height}" Fill="{Binding Path=Color}" IsEnabled="True" MouseDown="LinkClick">
                                <Rectangle.RenderTransform>
                                    <TranslateTransform X="{Binding Path=X}" Y="{Binding Path=Y}"/>
                                </Rectangle.RenderTransform>
                            </Rectangle>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

            </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>

        <Style TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="Background" Value="Black" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <!-- Customize listview to turn off selection -->
    </Window.Resources>

    <!-- The following is needed to set up all the keyboard short cuts -->
    <Window.CommandBindings>
        <CommandBinding Command="Open" Executed="OpenFileCommand"></CommandBinding>
        <CommandBinding Command="SelectAll" Executed="SelectAllCommand"></CommandBinding>
        <CommandBinding Command="Copy" Executed="CopyCommand"></CommandBinding>
        <CommandBinding Command="Print" Executed="PrintCommand"></CommandBinding>
        <CommandBinding Command="Help" Executed="HelpCommand"></CommandBinding>
        <CommandBinding Command="Close" Executed="CloseCommand"></CommandBinding>
    </Window.CommandBindings>
    <Window.InputBindings>
        <KeyBinding Key="O" Modifiers="Control" Command="Open"></KeyBinding>
        <KeyBinding Key="A" Modifiers="Control" Command="SelectAll"></KeyBinding>
        <KeyBinding Key="C" Modifiers="Control" Command="Copy"></KeyBinding>
        <KeyBinding Key="P" Modifiers="Control" Command="Print"></KeyBinding>
        <KeyBinding Key="W" Modifiers="Control" Command="Close"></KeyBinding>
        <KeyBinding Key="F1" Command="Help"></KeyBinding>
    </Window.InputBindings>

    <!-- To do add in command short cuts and bindings -->
    <DockPanel LastChildFill="True">
        <!-- Menu item at top -->
        <Menu IsMainMenu="True" DockPanel.Dock="Top">
            <MenuItem Header="_File" x:Name="xaml_file">
                <MenuItem Header="_Open..." Command="Open" InputGestureText="Ctrl+O">
                    <MenuItem.Icon>
                        <Image Source="Resources/OpenFile.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Save As..." x:Name="xaml_saveas">
                    <MenuItem.Icon>
                        <Image Source="Resources/saveHS.png" />
                    </MenuItem.Icon>
                    <MenuItem Header="PDF" Click="SavePDF" x:Name="xaml_savepdf"/>
                    <MenuItem Header="Linearized PDF" Click="Linearize" x:Name="xaml_linearize_pdf"/>
                    <MenuItem Header="PDF-1.3" Click="SavePDF13" x:Name="xaml_savepdf13"/>
                    <MenuItem Header="PDF/A" x:Name="xaml_savepdfa">
                        <MenuItem Header="PDF/A-1 RGB" Click="SavePDFA1_RGB" x:Name="xaml_savepdfa1_rgb"/>
                        <MenuItem Header="PDF/A-1 CMYK" Click="SavePDFA1_CMYK" x:Name="xaml_savepdfa1_cmyk"/>
                        <MenuItem Header="PDF/A-2 RGB" Click="SavePDFA2_RGB" x:Name="xaml_savepdfa2_rgb"/>
                        <MenuItem Header="PDF/A-2 CMYK" Click="SavePDFA2_CMYK" x:Name="xaml_savepdfa2_cmyk"/>
                    </MenuItem>
                    <MenuItem Header="PDF/X-3 Gray" Click="SavePDFX3_Gray" x:Name="xaml_savepdfx3_gray"/>
                    <MenuItem Header="PDF/X-3 CMYK" Click="SavePDFX3_CMYK" x:Name="xaml_savepdfx3_cmyk"/>
                    <MenuItem Header="PCL-XL" Click="SavePCLXL" x:Name="xaml_savepclxl"/>
                    <MenuItem Header="XPS" Click="SaveXPS"/>
                    <MenuItem Header="TEXT" Click="SaveText"/>
                    <MenuItem Header="HTML" Click="SaveHTML"/>
                    <MenuItem Header="XML" Click="SaveXML"/>
                </MenuItem>
                <MenuItem Header="_Close" Command="Close" InputGestureText="Ctrl+W" x:Name="xaml_closefile">
                    <MenuItem.Icon>
                        <Image Source="Resources/Close.ico" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Info" Click="ShowInfo" x:Name="xaml_showinfo">
                    <MenuItem.Icon>
                        <Image Source="Resources/info.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Extract Selection..." x:Name="xaml_extractselection">
                    <MenuItem.Icon>
                        <Image Source="Resources/saveHS.png" />
                    </MenuItem.Icon>
                    <MenuItem Header="PDF" Click="ExtractPDF" x:Name="xaml_extractpdf"/>
                    <MenuItem Header="EPS" Click="ExtractEPS" x:Name="xaml_extracteps"/>
                    <MenuItem Header="PS" Click="ExtractPS" x:Name="xaml_extractps"/>
                </MenuItem>
                <MenuItem Header="Page Conversions..." Click="ConvertClick" x:Name="xaml_conversions">
                </MenuItem>
                <Separator />
                <MenuItem Header="Print..." Command="Print" InputGestureText="Ctrl+P" x:Name="xaml_print">
                    <MenuItem.Icon>
                        <Image Source="Resources/printer.ico" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Show Messages" Click="ShowGSMessage" x:Name="xaml_gsmessage">
                    <MenuItem.Icon>
                        <Image Source="Resources/Message.png" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="_Edit" x:Name="xaml_edit">
                <MenuItem Header="Extract PDF Pages" Click="ExtractPages" x:Name="xaml_Extract">
                        <MenuItem.Icon>
                            <Image Source="Resources/saveHS.png" />
                        </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Copy Page" Click="CopyPage" x:Name="xaml_copypage">
                    <MenuItem.Icon>
                        <Image Source="Resources/copy.ico" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Paste Page To" x:Name="xaml_pastpageto">
                    <MenuItem Header="BMP" Click="PastePage" Tag="BMP"/>
                    <MenuItem Header="GIF" Click="PastePage" Tag="GIF"/>
                    <MenuItem Header="JPEG" Click="PastePage" Tag="JPG"/>
                    <MenuItem Header="PNG" Click="PastePage" Tag="PNG"/>
                    <MenuItem Header="TIFF" Click="PastePage" Tag="TIF"/>
                    <MenuItem Header="WDP (HD Photo)" Click="PastePage" Tag="WDP"/>
                </MenuItem>
                <Separator />
                <MenuItem Header="Select Text All" Command="SelectAll" InputGestureText="Ctrl+A" x:Name="xaml_selectalltext" />
                <MenuItem Header="Deselect Text" x:Name="xaml_deselecttext" />
                <MenuItem Header="Copy Text" Command="Copy" InputGestureText="Ctrl+C" x:Name="xaml_copytext" />
            </MenuItem>
            <MenuItem Header="_View" x:Name="xaml_view">
                <MenuItem Header="Next Page" Click="OnForwardPageClick"/>
                <MenuItem Header="Previous Page" Click="OnBackPageClick"/>
                <MenuItem Header="_Find" Click="Search"/>
            </MenuItem>
            <MenuItem Header="_Options">
                <MenuItem Header="Output Intents" Click="OutputIntents" />
                <MenuItem Header="Zoom Control" IsCheckable="true" Checked="ShowFooter" Unchecked="HideFooter"/>
                <MenuItem Header="Show Annotations" IsCheckable="True" IsChecked ="True"  Checked="AnnotationOn" Unchecked="AnnotationOff"/>
                <MenuItem Header="AntiAlias" >
                    <MenuItem x:Name="xaml_AA_High" Header="High" IsCheckable="True" IsChecked="True" Checked="OnAAChecked" />
                    <MenuItem x:Name="xaml_AA_MedHigh" Header="Medium High" IsCheckable="True" IsChecked="False" Checked="OnAAChecked"/>
                    <MenuItem x:Name="xaml_AA_Med" Header="Medium" IsCheckable="True" IsChecked="False" Checked="OnAAChecked"/>
                    <MenuItem x:Name="xaml_AA_Low" Header="Low" IsCheckable="True" IsChecked="False" Checked="OnAAChecked" />
                    <MenuItem x:Name="xaml_AA_None" Header="None" IsCheckable="True" IsChecked="False" Checked="OnAAChecked" />
                </MenuItem>
                
            </MenuItem>

            <MenuItem Header="_Help">
                <MenuItem Header="GSView Help" Command="Help" InputGestureText="F1"/>
                <MenuItem Header="About" Click="OnAboutClick"/>
            </MenuItem>
        </Menu>

            <!-- List of icons for page navigation, print, etc -->
        <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Background="WhiteSmoke">
            <Button  x:Name="xaml_open" Width="20" Height="20" Click="OpenFile" Background="Transparent" BorderBrush="Transparent" Margin="10,0,0,0">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Width="20" Height="20">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Resources/folder_open.ico"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button x:Name="xaml_SavePDF" Width="20" Height="20" Click="SavePDF" Background="Transparent" BorderBrush="Transparent" Margin="10,0,0,0">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Width="20" Height="20">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Resources/FloppyDisk.ico"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button x:Name="xaml_Print" Margin="10 0 0 0" Width="20" Height="20" Click="Print" Background="Transparent" BorderBrush="Transparent">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Width="20" Height="20">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Resources/printer.ico"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Rectangle Width="2" Height="20" Margin="10 0 0 0">
                <Rectangle.Fill>
                    <SolidColorBrush Color="DarkGray">
                    </SolidColorBrush>
                </Rectangle.Fill>
            </Rectangle>
            <Button  Width="20" Height="20" x:Name="xaml_BackPage" Click="OnBackPageClick" Background="Transparent" BorderBrush="Transparent" Margin="10,0,5,0">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/Left.ico"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Width="20" Height="20" x:Name="xaml_ForwardPage" Click="OnForwardPageClick" Background="Transparent" BorderBrush="Transparent">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/Right.ico"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <TextBox x:Name="xaml_currPage" Grid.Row="0" Width="25" Height="20" VerticalScrollBarVisibility="Hidden" 
                     HorizontalScrollBarVisibility="Hidden"  TextAlignment="Center" Margin="10,2,0,2" PreviewKeyDown="PageEnterClicked"/>
            <TextBlock Margin="5,0,0,0" Height="20" Text="/ 0" x:Name="xaml_TotalPages">
                <TextBlock.FontSize>12</TextBlock.FontSize>
            </TextBlock>
            <Rectangle Width="2" Height="20" Margin="10 0 0 0">
                <Rectangle.Fill>
                    <SolidColorBrush Color="DarkGray">
                    </SolidColorBrush>
                </Rectangle.Fill>
            </Rectangle>

            <Button  Margin="10 0 0 0" Width="20" Height="20" Click="ZoomIn" Background="Transparent" BorderBrush="Transparent" x:Name="xaml_zoomIn">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/zoom_in.ico"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Margin="10 0 0 0" x:Name="xaml_zoomOut" Width="20" Height="20" Click="ZoomOut" Background="Transparent" BorderBrush="Transparent">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/zoom_out.ico"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <TextBox Grid.Row="0"  Grid.Column="2" Width="30" Height="20" VerticalScrollBarVisibility="Hidden" 
                     HorizontalScrollBarVisibility="Hidden"  TextAlignment="Left" x:Name="xaml_Zoomsize"
                     Text="{Binding Mode=TwoWay, ElementName=xaml_ZoomSlider,Path=Value, UpdateSourceTrigger=PropertyChanged}" Margin="10 0 0 0" 
                     PreviewKeyDown="ZoomEnterClicked"/>
            <TextBlock Margin="5,0,0,0" Height="20" Text="%">
                <TextBlock.FontSize>12</TextBlock.FontSize>
            </TextBlock>

            <Button  Margin="10 0 0 0" Width="20" Height="20" Click="ActualSize" Background="Transparent" BorderBrush="Transparent" x:Name="xaml_ActualSize">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Width="20" Height="20">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Resources/ActualSize48.png"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>

            <Button  Margin="10 0 0 0" Width="20" Height="20" Click="ContScrollFill" Background="Transparent" BorderBrush="Transparent" x:Name="xaml_ContScrollFill">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Width="20" Height="20">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Resources/ContScrollFill48.png"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>

            <Button  Margin="10 0 0 0" Width="20" Height="20" Click="ExpandFill" Background="Transparent" BorderBrush="Transparent" x:Name="xaml_ExpandFill">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Width="20" Height="20">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Resources/ExpandFill48.png"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>


            <Rectangle Width="2" Height="20" Margin="10 0 0 0">
                <Rectangle.Fill>
                    <SolidColorBrush Color="DarkGray">
                    </SolidColorBrush>
                </Rectangle.Fill>
            </Rectangle>
            <Button  Margin="10 0 0 0" x:Name="xaml_Thumbs" Width="20" Height="20" Click="ToggleThumbs" Background="Transparent" BorderBrush="Transparent">
                <Button.ToolTip>
                    <TextBlock Text="Thumbnails"/>
                </Button.ToolTip>
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/thumbnail.ico"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Margin="10 0 0 0" x:Name="xaml_Contents" Width="20" Height="20" Click="ToggleContents" Background="Transparent" BorderBrush="Transparent">
                <Button.ToolTip>
                    <TextBlock Text="Contents"/>
                </Button.ToolTip>
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Width="20" Height="20">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Resources/contents.ico"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Margin="10 0 0 0" x:Name="xaml_Search" Width="20" Height="20" Click="Search" Background="Transparent" BorderBrush="Transparent">
                <Button.ToolTip>
                    <TextBlock Text="Search"/>
                </Button.ToolTip>
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Width="20" Height="20">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Resources/search.png"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Margin="10 0 0 0" x:Name="xaml_Links" Width="20" Height="20" Click="LinksToggle" Background="Transparent" BorderBrush="Transparent">
                <Button.ToolTip>
                    <TextBlock Text="Hyperlinks"/>
                </Button.ToolTip>
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/hyperlink.png"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
        </StackPanel>

        <!-- Search control -->
        <Grid x:Name="xaml_SearchControl" Background="WhiteSmoke" DockPanel.Dock="Bottom" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Row="0" Grid.Column="0" Margin="5,5,0,5"><Bold>Search:</Bold></TextBlock>
            <TextBox x:Name="xaml_SearchText" Grid.Row="0"  Grid.Column="1" Width="100" Height="20" VerticalScrollBarVisibility="Hidden" 
                     HorizontalScrollBarVisibility="Hidden"  TextAlignment="Center" Margin="5,5,0,5"/>
            <Button Grid.Row="0" Grid.Column="2" Width="20" Height="20" Click="OnSearchBackClick" Background="Transparent" BorderBrush="Transparent" Margin="5,0,5,0">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/Left.ico"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button Grid.Row="0" Grid.Column="3" Width="20" Height="20" Click="OnSearchForwardClick" Background="Transparent" BorderBrush="Transparent">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/Right.ico"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
        </Grid>

        <!-- Footer control Currently just zoom slider in here but we may add more -->
        <Grid x:Name="xaml_FooterControl" Background="WhiteSmoke" DockPanel.Dock="Bottom" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Row="0" Grid.Column="0" Margin="5,0,0,0"><Bold>Zoom:</Bold></TextBlock>
            <Slider x:Name="xaml_ZoomSlider" Grid.Row="0" Grid.Column="1" Margin="10, 0, 0, 0" 
                Width="150" Orientation="Horizontal" HorizontalAlignment="Center" 
                Value="100" Minimum="25" Maximum="400" 
                SmallChange="1" LargeChange="1"
                TickPlacement="None" TickFrequency="1"  IsSnapToTickEnabled="True"/>
        </Grid>

        <!-- The progress bar that runs while the thumbnails 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_ThumbProgress" 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>Creating Thumbs</Bold></TextBlock>
           <!-- <Button  Grid.Row="0" Grid.Column="2" Width="50" Height="20" Name="xaml_CancelThumb" Click="CancelLoadClick" 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>
        
        <!-- The progress bar that runs during text search -->
        <Grid x:Name="xaml_SearchGrid" DockPanel.Dock="Bottom" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <ProgressBar x:Name="xaml_SearchProgress" 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>Searching</Bold></TextBlock>
            <Button  Grid.Row="0" Grid.Column="2" Width="50" Height="20" Name="xaml_CancelSearch" Click="CancelSearchClick" 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>

        <!-- The progress bar that runs during copy all text to clipboard -->
        <Grid x:Name="xaml_CopyTextGrid" DockPanel.Dock="Bottom" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <ProgressBar x:Name="xaml_CopyTextProgress" 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>
            <Button  Grid.Row="0" Grid.Column="2" Width="50" Height="20" Name="xaml_CancelCopyText" Click="CancelCopyText" 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>
        
        <!-- The progress bar that runs during printing -->
        <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>
            <!-- Asyc Cancel crashes in windows 8 for this xps creation -->
           <!-- <Button  Grid.Row="0" Grid.Column="2" Width="50" Height="20" Name="xaml_CancelPrint" Click="CancelPrintClick" 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>

        <!-- The progress bar that runs during MuPDF page by page conversion to file-->
        <Grid x:Name="xaml_MuPDFGrid" DockPanel.Dock="Bottom" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <ProgressBar x:Name="xaml_MuPDFProgress" 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>MuPDF Converting Document</Bold></TextBlock>
            <Button  Grid.Row="0" Grid.Column="2" Width="50" Height="20" Name="xaml_CancelMuPDF" Click="CancelMuPDFClick" 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>
        
        <!-- 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>

        <!-- Thumb viewer/selector -->
        <Grid x:Name="xaml_ThumbGrid" Width="100" 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>

        <!-- Contents viewer/selector.  -->
        <Grid x:Name="xaml_ContentGrid" Width="250" Background="DarkGray" DockPanel.Dock="Left" Visibility="Collapsed">
            <ListView x:Name="xaml_ContentList" HorizontalAlignment="Stretch" 
                      ScrollViewer.CanContentScroll="False" PreviewMouseLeftButtonUp="ContentSelected"
                      Background="DarkGray" >
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="5,5,0,0" HorizontalAlignment="Left">
                            <TextBlock TextWrapping="Wrap" Text="{Binding StringMargin}" FontFamily="Segoe UI" FontSize="11" />
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </Grid>

        <Grid x:Name="xaml_OpenProgressGrid" HorizontalAlignment="Stretch" Background="DarkGray" DockPanel.Dock="Bottom" Visibility="Collapsed">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBlock x:Name ="xaml_openfilestatus" Text="Opening File" Grid.Row="0" Grid.Column="0" Margin="0,0,0,10" HorizontalAlignment="Center"></TextBlock>
            <ProgressBar Grid.Row="1" Grid.Column="0" x:Name="xaml_OpenProgress" Minimum="0" 
                     Maximum="100" Height="20" Margin="100,0,100,200" HorizontalAlignment="Stretch" IsIndeterminate="True" />
        </Grid>

        <!-- The stock scroll bar that comes with the ListView scrollviewer does is not well behaved when
             the page sizes change.  So we have our own here that we will set up -->
        <ScrollBar x:Name="xaml_VerticalScroll" Orientation="Vertical" Grid.Row="0"  Grid.Column="1" DockPanel.Dock="Right"
           Width ="5" Height="Auto" Margin="0,0,0,0" Background="WhiteSmoke" Visibility="Collapsed" 
                   Scroll="VerticalScroll"/>

        <!-- Pages are last child fill.  This goes in the center of our 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.ScrollChanged="ListViewScrollChanged"
                      MouseDoubleClick="PageDoubleClick" IsHitTestVisible="True"
                      SelectionMode="Single" 
                      PreviewMouseLeftButtonDown="ListPreviewMouseLeftButtonDown"
                      PreviewMouseLeftButtonUp="ListPreviewLeftButtonUp"
                      MouseLeave="ListMouseLeave"
                      PreviewMouseMove="ListPreviewMouseMove"
                      ScrollViewer.HorizontalScrollBarVisibility="Auto"
                      ScrollViewer.VerticalScrollBarVisibility="Hidden"
                      ScrollViewer.IsDeferredScrollingEnabled ="False" DockPanel.Dock="Left" AllowDrop="True"
                      >
                <!-- This keeps the pages in the center of the panel -->

            <ListView.ItemContainerStyle>
                                
                    <Style TargetType="ListViewItem">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    <EventSetter Event="RequestBringIntoView" Handler="AvoidScrollIntoView"/>
                </Style>
                </ListView.ItemContainerStyle>
            </ListView>
        <!-- </Grid> --> 
    </DockPanel>
</Window>