summaryrefslogtreecommitdiff
path: root/winrt/mupdf_cpp/MainPage.xaml
blob: 3c59d615c0db32dcf21ce5935cbc41117f0a9bfa (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
<Page
    x:Class="mupdf_cpp.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:winapp"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.BottomAppBar>
        <AppBar>
            <Grid Margin="38,0,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Slider x:Name="xaml_PageSlider" Minimum="0"  Maximum="10" ValueChanged="Slider_ValueChanged" Grid.Column="0" Margin="10,0" VerticalAlignment="Center" />
                <Button x:Name="Find_File" Style="{StaticResource OpenFileAppBarButtonStyle}" Tag="OpenFile"  HorizontalAlignment="Right" Grid.Column="1" Click="Picker"/>
            </Grid>
        </AppBar>
    </Page.BottomAppBar>
    <Page.TopAppBar>
        <AppBar x:Name="TopAppBar1" AutomationProperties.Name="Top App Bar" Loaded="topAppBar_Loaded">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <StackPanel x:Name="LeftPanel" Orientation="Horizontal">
                </StackPanel>
                <StackPanel x:Name="RightPanel" Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button x:Name="Search" Style="{StaticResource SearchAppBarButtonStyle}" Tag="Search" Click="Searcher"/>
                    <Button x:Name="Contents" Style="{StaticResource ContentsBarButtonStyle}" Tag="Contents" Click="ContentDisplay"/>
                    <Button x:Name="Links" Style="{StaticResource LinksAppBarButtonStyle}" Tag="Links" Click="Linker"/>
                    <Button x:Name="Reflow" Style="{StaticResource ReflowAppBarButtonStyle}" Tag="Reflow" Click="Reflower"/>
                    <Button x:Name="Help" Style="{StaticResource HelpAppBarButtonStyle}" Tag="Help"/>
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.TopAppBar>

    <Grid x:Name="xaml_OutsideGrid">
        <Grid.Background>
            <LinearGradientBrush EndPoint="-0.074,-0.068" StartPoint="1.027,1.024">
                <GradientStop Color="Black"/>
                <GradientStop Color="White"/>
                <GradientStop Color="White" Offset="0.919"/>
                <GradientStop Color="#FFCDCDCD" Offset="0.741"/>
                <GradientStop Color="#FF909090" Offset="0.524"/>
                <GradientStop Color="#FF737373" Offset="0.421"/>
                <GradientStop Color="#FF2A2A2A" Offset="0.155"/>
                <GradientStop Color="#FF1A1A1A" Offset="0.097"/>
                <GradientStop Color="#FF040404" Offset="0.018"/>
                <GradientStop Color="#FFB3B3B3" Offset="0.651"/>
                <GradientStop Color="#FF989898" Offset="0.556"/>
                <GradientStop Color="#FF666666" Offset="0.375"/>
                <GradientStop Color="#FF4B4B4B" Offset="0.278"/>
                <GradientStop Color="#FF3A3A3A" Offset="0.215"/>
            </LinearGradientBrush>
        </Grid.Background>

        <Grid x:Name="xaml_MainGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SizeChanged="GridSizeChanged">
            <Canvas x:Name="xaml_zoomCanvas" HorizontalAlignment="Center" VerticalAlignment="Center" ManipulationMode="All" >
                <!-- Horizontal flip view -->
                <FlipView x:Name="xaml_horiz_flipView" SelectionChanged="FlipView_SelectionChanged" VerticalAlignment="Center"
                          HorizontalAlignment="Center">
                    <FlipView.ItemsPanel>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </FlipView.ItemsPanel>
                    <FlipView.ItemTemplate>
                        <DataTemplate>
                            <ScrollViewer
                            ZoomMode="Enabled"
                            ViewChanged="ScrollChanged"
                            HorizontalScrollMode="Auto"
                            VerticalScrollMode="Auto"
                            VerticalSnapPointsType="None"
                            HorizontalSnapPointsType="None"
                            HorizontalScrollBarVisibility="Auto"
                            VerticalScrollBarVisibility="Auto"
                            MinZoomFactor="0.25"
                            MaxZoomFactor="4">
                                <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="{Binding Height}" Width="{Binding Width}">
                                   <Image Source="{Binding Image}" Width="{Binding Width}" Height="{Binding Height}"
                                Stretch="Uniform" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0"/>
                                    <!-- After much work, figured out how to have a binding for the rectangles.  TextBox and LinkBox are
                                         a collection that is in the other main collection used for the scroll viewer.  It works
                                         nicely and cleanly once you figure out how to set up all the templates and the bindings -->
                                    <ItemsControl ItemsSource="{Binding Path=TextBox}">
                                        <ItemsControl.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <Canvas/>
                                            </ItemsPanelTemplate>
                                        </ItemsControl.ItemsPanel>
                                        <ItemsControl.ItemContainerStyle>
                                            <Style TargetType="ContentPresenter">
                                                <Setter Property="Canvas.Left" Value="{Binding Left}"/>
                                                <Setter Property="Canvas.Top" Value="{Binding Top}"/>
                                            </Style>
                                        </ItemsControl.ItemContainerStyle>
                                        <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=LinkBox}">
                                        <ItemsControl.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <Canvas/>
                                            </ItemsPanelTemplate>
                                        </ItemsControl.ItemsPanel>
                                        <ItemsControl.ItemContainerStyle>
                                            <Style TargetType="ContentPresenter">
                                                <Setter Property="Canvas.Left" Value="{Binding Left}"/>
                                                <Setter Property="Canvas.Top" Value="{Binding Top}"/>
                                            </Style>
                                        </ItemsControl.ItemContainerStyle>
                                        <ItemsControl.ItemTemplate>
                                            <DataTemplate>
                                                <Rectangle Tag="{Binding Path=Index}" Width="{Binding Path=Width}" Height="{Binding Path=Height}" Fill="{Binding Path=Color}" IsTapEnabled="True" Tapped="LinkTapped">
                                                    <Rectangle.RenderTransform>
                                                        <TranslateTransform X="{Binding Path=X}" Y="{Binding Path=Y}"/>
                                                    </Rectangle.RenderTransform>
                                                </Rectangle>
                                            </DataTemplate>
                                        </ItemsControl.ItemTemplate>
                                    </ItemsControl>

                                </Canvas>
                            </ScrollViewer>
                        </DataTemplate>
                    </FlipView.ItemTemplate>
                </FlipView>
                <!-- Vertical flip view -->
                <FlipView x:Name="xaml_vert_flipView" SelectionChanged="FlipView_SelectionChanged" VerticalAlignment="Center"
                          HorizontalAlignment="Center" IsEnabled="False" Opacity="0">
                    <FlipView.ItemsPanel>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel Orientation="Vertical"/>
                        </ItemsPanelTemplate>
                    </FlipView.ItemsPanel>
                    <FlipView.ItemTemplate>
                        <DataTemplate>
                        <ScrollViewer
                            ZoomMode="Enabled"
                            ViewChanged="ScrollChanged"
                            HorizontalScrollMode="Auto"
                            VerticalScrollMode="Auto"
                            VerticalSnapPointsType="None"
                            HorizontalSnapPointsType="None"
                            HorizontalScrollBarVisibility="Auto"
                            VerticalScrollBarVisibility="Auto"
                            MinZoomFactor="0.25"
                            MaxZoomFactor="4">
                                <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="{Binding Height}" Width="{Binding Width}">
                                    <Image Source="{Binding Image}" Width="{Binding Width}" Height="{Binding Height}"
                                Stretch="Uniform" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0"/>
                                    <ItemsControl ItemsSource="{Binding Path=TextBox}">
                                        <ItemsControl.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <Canvas/>
                                            </ItemsPanelTemplate>
                                        </ItemsControl.ItemsPanel>
                                        <ItemsControl.ItemContainerStyle>
                                            <Style TargetType="ContentPresenter">
                                                <Setter Property="Canvas.Left" Value="{Binding Left}"/>
                                                <Setter Property="Canvas.Top" Value="{Binding Top}"/>
                                            </Style>
                                        </ItemsControl.ItemContainerStyle>
                                        <ItemsControl.ItemTemplate>
                                            <DataTemplate>
                                                <Rectangle Width="{Binding Path=Width}" Height="{Binding Path=Height}" Fill="{Binding Path=Color}" IsTapEnabled="True" Tapped="LinkTapped">
                                                    <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.ItemContainerStyle>
                                            <Style TargetType="ContentPresenter">
                                                <Setter Property="Canvas.Left" Value="{Binding Left}"/>
                                                <Setter Property="Canvas.Top" Value="{Binding Top}"/>
                                            </Style>
                                        </ItemsControl.ItemContainerStyle>
                                        <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>
                                </Canvas>
                            </ScrollViewer>
                    </DataTemplate>
                    </FlipView.ItemTemplate>
                </FlipView>
            </Canvas>
            <ListView x:Name="xaml_ListView" Foreground="Black" HorizontalAlignment="Stretch"
                      VerticalAlignment="Stretch" Opacity="0" IsItemClickEnabled="True"
                      ItemClick="ContentSelected" SelectionMode="Single" IsEnabled="False">

                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="5,5,0,0" HorizontalAlignment="Left">
                            <TextBlock TextWrapping="Wrap" Text="{Binding StringMargin}" FontFamily="Segoe UI" FontSize="20" />
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>

                <ListView.Background>
                    <SolidColorBrush Color="LightGray"></SolidColorBrush>
                </ListView.Background>
            </ListView>
        </Grid>
        <WebView x:Name="xaml_WebView" HorizontalAlignment="Stretch" Width="Auto" Height="Auto"
                     VerticalAlignment="Stretch" Visibility="Collapsed"
                     ScrollViewer.HorizontalScrollBarVisibility="Visible"
                     ScrollViewer.VerticalScrollBarVisibility="Visible"
                     ScrollViewer.VerticalScrollMode="Enabled"
                     ScrollViewer.HorizontalScrollMode="Enabled"
                     ScrollViewer.ZoomMode="Enabled"/>

        <StackPanel x:Name="xaml_ProgressStack" Opacity="1" VerticalAlignment="Center" Visibility="Collapsed">
            <Border BorderThickness="5" BorderBrush="Black" Margin="300">
                <StackPanel Background="LightGray" >
                    <TextBlock HorizontalAlignment="Center" Margin="10"
        				Text="Text Search Progress" FontSize="20"/>
                    <ProgressBar x:Name="xaml_Progress" Margin="5" Height="15"
        				IsIndeterminate="False" Maximum="100" VerticalAlignment="Stretch" />
                    <Button HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10" Click="CancelSearch" Height="39">
                        <TextBlock HorizontalAlignment="Center" Text="Cancel"/>
                    </Button>
                </StackPanel>
            </Border>
        </StackPanel>

        <StackPanel x:Name="xaml_PasswordStack" Opacity="1" VerticalAlignment="Center" Visibility="Collapsed">
            <Border BorderThickness="5" BorderBrush="Black" Margin="300">
                <StackPanel Background="LightGray" >
                    <TextBlock HorizontalAlignment="Center" Margin="10"
        				Text="Password Required" FontSize="20"/>
                    <PasswordBox x:Name="xaml_password" Height="35" Width="300"/>
                    <Button HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10" Click="PasswordOK" Height="39">
                        <TextBlock HorizontalAlignment="Center" Text="OK"/>
                    </Button>
                </StackPanel>
            </Border>
        </StackPanel>







    </Grid>
</Page>