diff options
author | Michael Vrhel <michael.vrhel@artifex.com> | 2014-04-06 21:07:12 -0700 |
---|---|---|
committer | Michael Vrhel <michael.vrhel@artifex.com> | 2014-09-09 16:39:34 -0700 |
commit | 75679d3ed3896ac44d6e804345404bc19a8b98c7 (patch) | |
tree | 5fa559fe1a93681aa17c0eeed18346f5aac7e1cb /platform/winrt/gsview/MainWindow.xaml | |
parent | 7de76c620cbb8f5c03386c23966bd0d62be0d357 (diff) | |
download | mupdf-75679d3ed3896ac44d6e804345404bc19a8b98c7.tar.xz |
Code toward getting text selection across pages working.
Diffstat (limited to 'platform/winrt/gsview/MainWindow.xaml')
-rw-r--r-- | platform/winrt/gsview/MainWindow.xaml | 107 |
1 files changed, 62 insertions, 45 deletions
diff --git a/platform/winrt/gsview/MainWindow.xaml b/platform/winrt/gsview/MainWindow.xaml index 1f150e0c..2ce168b2 100644 --- a/platform/winrt/gsview/MainWindow.xaml +++ b/platform/winrt/gsview/MainWindow.xaml @@ -1,30 +1,34 @@ <Window x:Class="gsview.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - Title="gsview" Height="800" Width="650" UseLayoutRounding="True"> + Title="gsview" Height="800" Width="650" UseLayoutRounding="True" > <!-- UseLayoutRouding 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="24,24,0,0"> + <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="{Binding Height}" Width="{Binding Width}" Margin="24,24,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.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}"> @@ -36,18 +40,52 @@ </ItemsControl.ItemTemplate> </ItemsControl> - <ItemsControl ItemsSource="{Binding Path=LinkBox}"> + <ItemsControl ItemsSource="{Binding Path=SelectedLines}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> - <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> + + <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.ItemContainerStyle> <Style TargetType="ContentPresenter"> <Setter Property="Canvas.Left" Value="{Binding Left}"/> <Setter Property="Canvas.Top" Value="{Binding Top}"/> </Style> - </ItemsControl.ItemContainerStyle> + </ItemsControl.ItemContainerStyle> --> <ItemsControl.ItemTemplate> <DataTemplate> <Rectangle Tag="{Binding Path=Index}" Width="{Binding Path=Width}" Height="{Binding Path=Height}" Fill="{Binding Path=Color}" IsEnabled="True" MouseDown="LinkClick"> @@ -57,9 +95,9 @@ </Rectangle> </DataTemplate> </ItemsControl.ItemTemplate> - </ItemsControl> + </ItemsControl> </Canvas> - </DataTemplate> + </DataTemplate> <DataTemplate x:Key="ThumbTemplate"> <Image Width="{Binding Width}" Height="{Binding Height}" Stretch="Fill" HorizontalAlignment="Center" Source="{Binding BitMap}" Margin="24,24,0,0"> @@ -83,36 +121,7 @@ </Setter.Value> </Setter> </Style> - <!-- Customize listview to turn off selection --> - <Style TargetType="{x:Type ListViewItem}"> - <Setter Property="Template"> - <Setter.Value> - <ControlTemplate TargetType="{x:Type ListViewItem}"> - <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true"> - <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> - </Border> - <ControlTemplate.Triggers> - <Trigger Property="IsSelected" Value="true"> - <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/> - <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/> - </Trigger> - <MultiTrigger> - <MultiTrigger.Conditions> - <Condition Property="IsSelected" Value="true"/> - <Condition Property="Selector.IsSelectionActive" Value="false"/> - </MultiTrigger.Conditions> - <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/> - <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}}"/> - </MultiTrigger> - <Trigger Property="IsEnabled" Value="false"> - <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> - </Trigger> - </ControlTemplate.Triggers> - </ControlTemplate> - </Setter.Value> - </Setter> - </Style> </Window.Resources> <!-- To do add in command short cuts and bindings --> @@ -620,15 +629,23 @@ <Grid x:Name="xaml_PageGrid" HorizontalAlignment="Stretch" Background="DarkGray" DockPanel.Dock="Left"> <ListView x:Name="xaml_PageList" HorizontalAlignment="Stretch" ItemTemplate="{StaticResource PageTemplate}" - ScrollViewer.CanContentScroll="False" - Background="DarkGray" ScrollViewer.PanningMode="Both" + ScrollViewer.CanContentScroll="False" + Background="DarkGray" ScrollViewer.PanningMode="None" ScrollViewer.ScrollChanged="ListViewScrollChanged" - MouseDoubleClick="PageDoubleClick" + MouseDoubleClick="PageDoubleClick" IsHitTestVisible="True" + SelectionMode="Single" + PreviewMouseLeftButtonDown="ListPreviewMouseLeftButtonDown" + PreviewMouseLeftButtonUp="ListPreviewLeftButtonUp" + MouseLeave="ListMouseLeave" + PreviewMouseMove="ListPreviewMouseMove" + ScrollViewer.HorizontalScrollBarVisibility="Auto" + ScrollViewer.VerticalScrollBarVisibility="Auto" > <!-- 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> |