Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/WpfTestSvgSample/DrawingPage.xaml @ 12762

Last change on this file since 12762 was 12762, checked in by aballeit, 9 years ago

#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)

File size: 5.0 KB
Line 
1<Page x:Class="WpfTestSvgSample.DrawingPage"
2    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4    xmlns:svg="http://sharpvectors.codeplex.com/runtime/"
5    xmlns:local="clr-namespace:WpfTestSvgSample;assembly="   
6    Title="DrawingPage" Background="White"
7    FocusManager.FocusedElement="{Binding ElementName=canvasScroller}">
8    <Page.Resources>
9        <!-- UI commands. -->
10        <RoutedUICommand x:Key="Commands.ZoomOut" />
11        <RoutedUICommand x:Key="Commands.ZoomIn" />
12        <RoutedUICommand x:Key="Commands.Fill" />
13
14        <!-- This converts from a scale value to a percentage value.
15        It is used to convert the value of 'ContentScale' to the percentage zoom level that is displayed in the UI. -->
16        <local:ScaleToPercentConverter x:Key="scaleToPercentConverter"/>
17    </Page.Resources>
18
19    <Page.InputBindings>
20        <!-- Bind keys to commands. -->
21        <KeyBinding Key="Minus" Command="{StaticResource Commands.ZoomOut}"/>
22        <KeyBinding Key="Plus" Command="{StaticResource Commands.ZoomIn}"/>
23    </Page.InputBindings>
24
25    <Page.CommandBindings>
26        <!-- Bind commands to event handlers. -->
27        <CommandBinding Command="{StaticResource Commands.ZoomOut}"
28            Executed="OnZoomOut"/>
29        <CommandBinding Command="{StaticResource Commands.ZoomIn}"
30            Executed="OnZoomIn"/>
31        <CommandBinding Command="{StaticResource Commands.Fill}"
32            Executed="OnZoomFit"/>
33    </Page.CommandBindings> 
34
35    <DockPanel LastChildFill="True">
36        <ToolBar DockPanel.Dock="Top" Height="32">
37            <ToolBar.Resources>
38                <Style TargetType="{x:Type Image}">
39                    <Style.Triggers>
40                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
41                            <Setter Property="Opacity" Value="0.30" />
42                        </DataTrigger>
43                    </Style.Triggers>
44                </Style>
45            </ToolBar.Resources>
46            <Button Click="OnZoomIn" Height="24" Width="24" ToolTip="Zoom In">
47                <Image Source="Images/ZoomIn.png" Height="16"/>
48            </Button>   
49            <Button Click="OnResetZoom" Height="24" Width="24" ToolTip="Reset Zoom">
50                <Image Source="Images/ZoomReset.png" Height="16"/>
51            </Button>   
52            <Button Click="OnZoomOut" Height="24" Width="24" ToolTip="Zoom Out">
53                <Image Source="Images/ZoomOut.png" Height="16"/>
54            </Button>   
55            <Separator/>
56
57            <!-- This is the label that shows what the current zoom level
58            is while zooming in and out. -->
59            <TextBlock MinWidth="24" VerticalAlignment="Center"
60                HorizontalAlignment="Right" TextAlignment="Right"
61                Text="{Binding ElementName=zoomPanControl, Path=ContentScale, Converter={StaticResource scaleToPercentConverter}}"/>
62            <TextBlock VerticalAlignment="Center" Text="%"/>
63
64            <!-- Slider to change the current zoom level. -->
65            <Slider Name="zoomSlider" Width="250" Padding="0" Minimum="10" LargeChange="20"
66                TickFrequency="10" Maximum="500" SmallChange="10" TickPlacement="TopLeft"
67                Value="{Binding ElementName=zoomPanControl, Path=ContentScale, Converter={StaticResource scaleToPercentConverter}}"/>
68            <!-- The fill button.  Causes the content to be scaled so that it fits in the viewport.-->
69            <Button Height="24" Width="24" Click="OnZoomFitClick" Content="Fit"/>
70
71            <Separator/>
72            <ToggleButton Name="tbbPanning" Click="OnPanClick" Height="24" Width="24" ToolTip="Toggle Panning">
73                <Image Source="Images/Panning.png" Height="16"/>
74            </ToggleButton>
75        </ToolBar>
76
77        <!-- Wrap the ZoomAndPanControl in a ScrollViewer.
78        When the scaled content that is displayed in ZoomAndPanControl is larger than the viewport onto the content
79        ScrollViewer's scrollbars can be used to manipulate the offset of the viewport. -->
80        <ScrollViewer x:Name="canvasScroller" CanContentScroll="True" Padding="4"
81            VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible" AllowDrop="True">
82
83            <!-- This is the control that handles zooming and panning. -->
84            <svg:ZoomPanControl x:Name="zoomPanControl" Background="LightGray"
85                MouseDown="OnZoomPanMouseDown" MouseUp="OnZoomPanMouseUp"
86                MouseMove="OnZoomPanMouseMove" MouseWheel="OnZoomPanMouseWheel">
87
88                <!-- This Canvas is the content that is displayed by the ZoomPanControl.
89                Width and Height determine the size of the content. -->
90                <svg:SvgDrawingCanvas x:Name="svgViewer" Background="White"/>
91
92            </svg:ZoomPanControl>
93
94        </ScrollViewer>
95    </DockPanel>
96</Page>
Note: See TracBrowser for help on using the repository browser.