Browse Source

Extend Zoom Control so that it can Display Additional Controls.

Used later for Enabling Grid/Snapline Placement support
pull/52/head
jkuehner 12 years ago
parent
commit
afc881c8b0
  1. 34
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  2. 12
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomControl.cs

34
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls" xmlns:ControlConvertors="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls.Converters" xmlns:Converters="clr-namespace:ICSharpCode.WpfDesign.Designer.Converters">
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls" xmlns:ControlConvertors="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls.Converters" xmlns:Converters="clr-namespace:ICSharpCode.WpfDesign.Designer.Converters" xmlns:Widgets="http://icsharpcode.net/sharpdevelop/widgets">
<!--
This file contains the default styles used by the Controls in ICSharpCode.WpfDesign.Designer.Controls
-->
@ -351,4 +351,36 @@ @@ -351,4 +351,36 @@
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:ZoomControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:ZoomControl}">
<Grid Background="{TemplateBinding Panel.Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Widgets:SelfCollapsingPanel Grid.Column="0" Grid.Row="1" CollapseOrientation="Horizontal" CanCollapse="{Binding Path=ComputedZoomButtonCollapsed, Mode=OneWay, RelativeSource={RelativeSource Mode=TemplatedParent}}">
<Widgets:ZoomButtons x:Name="zoomButtons" Value="{Binding Path=CurrentZoom, RelativeSource={RelativeSource Mode=TemplatedParent}}" Minimum="{TemplateBinding MinimumZoom}" Maximum="{TemplateBinding MaximumZoom}" />
</Widgets:SelfCollapsingPanel>
<Rectangle Grid.Column="2" Grid.Row="1" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
<ScrollContentPresenter Name="PART_Presenter" Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="0" Margin="{TemplateBinding Control.Padding}" Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}">
<ScrollContentPresenter.LayoutTransform>
<ScaleTransform ScaleX="{Binding Path=CurrentZoom, RelativeSource={RelativeSource Mode=TemplatedParent}}" ScaleY="{Binding Path=CurrentZoom, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</ScrollContentPresenter.LayoutTransform>
</ScrollContentPresenter>
<ContentControl Grid.Column="1" Grid.Row="1" Content="{TemplateBinding AdditionalControls}" />
<ScrollBar Name="PART_VerticalScrollBar" Grid.Column="3" Grid.Row="0" Minimum="0" Maximum="{TemplateBinding ScrollableHeight}" ViewportSize="{TemplateBinding ViewportHeight}" Value="{TemplateBinding VerticalOffset}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" />
<ScrollBar Name="PART_HorizontalScrollBar" Orientation="Horizontal" Grid.Column="2" Grid.Row="1" Minimum="0" Maximum="{TemplateBinding ScrollableWidth}" ViewportSize="{TemplateBinding ViewportWidth}" Value="{TemplateBinding HorizontalOffset}" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

12
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomControl.cs

@ -18,9 +18,19 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -18,9 +18,19 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
{
PanToolCursor = GetCursor("Images/PanToolCursor.cur");
PanToolCursorMouseDown = GetCursor("Images/PanToolCursorMouseDown.cur");
DefaultStyleKeyProperty.OverrideMetadata(typeof(ZoomControl), new FrameworkPropertyMetadata(typeof(ZoomControl)));
}
public object AdditionalControls
{
get { return (object)GetValue(AdditionalControlsProperty); }
set { SetValue(AdditionalControlsProperty, value); }
}
static Cursor GetCursor(string path)
public static readonly DependencyProperty AdditionalControlsProperty =
DependencyProperty.Register("AdditionalControls", typeof(object), typeof(ZoomControl), new PropertyMetadata(null));
internal static Cursor GetCursor(string path)
{
var a = Assembly.GetExecutingAssembly();
var m = new ResourceManager(a.GetName().Name + ".g", a);

Loading…
Cancel
Save