Browse Source

Add size display for primary selection.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/wpfdesigner@5883 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Kumar Devvrat 16 years ago
parent
commit
4ee75a37cd
  1. 83
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  2. 38
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SizeDisplay.cs
  3. 48
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SizeDisplayExtension.cs
  4. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

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

@ -329,16 +329,16 @@ @@ -329,16 +329,16 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:MarginHandle}">
<Grid Height="8" Width="{Binding Path=HandleLength, RelativeSource={RelativeSource Mode=TemplatedParent}}">
<Grid Height="8" Width="{Binding Path=HandleLength, RelativeSource={RelativeSource Mode=TemplatedParent}}" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Path Name="startArrow"
Fill="#FF333333"
Stretch="Fill"
Stroke="{TemplateBinding Panel.Background}"
StrokeThickness="0.5"
Fill="#FF333333"
Stretch="Fill"
Stroke="{TemplateBinding Panel.Background}"
StrokeThickness="0.5"
Data="M0,0 L0,1 1,0.5 z" Grid.Column="0" />
<!-- Wrap the handle-line and endArrow in this grid. It's visiblity is subjected to HandleLength -->
<Grid Height="8" Grid.Column="1" Name="lineArrow">
@ -349,9 +349,9 @@ @@ -349,9 +349,9 @@
<ColumnDefinition Width="8" />
</Grid.ColumnDefinitions>
<Path Name="line1"
Stretch="Fill"
Stretch="Fill"
Stroke="#FF333333"
StrokeThickness="1.5"
StrokeThickness="1.5"
Margin="0 0 0 0"
Data="M0,0 L1,0" Grid.Column="0"/>
<TextBlock Grid.Column="1"
@ -368,7 +368,7 @@ @@ -368,7 +368,7 @@
<Path Name="line2"
Stretch="Fill"
Stroke="#FF333333"
StrokeThickness="1.5"
StrokeThickness="1.5"
Margin="0 0 0 0"
Data="M0,0 L1,0" Grid.Column="2"/>
<Path Name="arrow2"
@ -392,7 +392,7 @@ @@ -392,7 +392,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:MarginStub}">
<Grid>
<Grid SnapsToDevicePixels="True">
<Ellipse
Fill="{TemplateBinding Panel.Background}"
Height="7"
@ -404,4 +404,69 @@ @@ -404,4 +404,69 @@
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:HeightDisplay}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:HeightDisplay}">
<Grid Height="8" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4" />
<ColumnDefinition MaxWidth="20" MinWidth="5" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Path Grid.Column="0"
Stroke="Red"
StrokeThickness="1"
Data="M0,0 L0,1 M0,0.5 L1,0.5"
Stretch="Fill" />
<TextBlock Text="{Binding Path=Height}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Padding="1,1,1,1"
FontSize="10"
Grid.Column="1"/>
<Path Grid.Column="2"
Stroke="Red"
StrokeThickness="1"
Data="M0,0.5 L3,0.5 M3,0 L3,1 "
Stretch="Fill" />
<Grid.LayoutTransform>
<RotateTransform Angle="270"/>
</Grid.LayoutTransform>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:WidthDisplay}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:WidthDisplay}">
<Grid Height="8" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition MaxWidth="20" MinWidth="5" />
<ColumnDefinition Width="4" />
</Grid.ColumnDefinitions>
<Path Grid.Column="0"
Stroke="Red"
StrokeThickness="1"
Data="M0,0 L0,1 M0,0.5 L1,0.5"
Stretch="Fill" />
<TextBlock Text="{Binding Path=Width}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Padding="1,1,1,1"
FontSize="10"
Grid.Column="1"/>
<Path Grid.Column="2"
Stroke="Red"
StrokeThickness="1"
Data="M0,0.5 L3,0.5 M3,0 L3,1 "
Stretch="Fill" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

38
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SizeDisplay.cs

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Kumar Devvrat"/>
// <version>$Revision: $</version>
// </file>
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Display height of the element.
/// </summary>
class HeightDisplay : Control
{
static HeightDisplay()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(HeightDisplay), new FrameworkPropertyMetadata(typeof(HeightDisplay)));
}
}
/// <summary>
/// Display width of the element.
/// </summary>
class WidthDisplay : Control
{
static WidthDisplay()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(WidthDisplay), new FrameworkPropertyMetadata(typeof(WidthDisplay)));
}
}
}

48
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SizeDisplayExtension.cs

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Kumar Devvrat"/>
// <version>$Revision: $</version>
// </file>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.ComponentModel;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer.Controls;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
/// <summary>
/// Display Height/Width on the primary selection
/// </summary>
[ExtensionFor(typeof(UIElement))]
class SizeDisplayExtension : PrimarySelectionAdornerProvider
{
HeightDisplay heightDisplay;
WidthDisplay widthDisplay;
protected override void OnInitialized()
{
base.OnInitialized();
if (this.ExtendedItem != null)
{
RelativePlacement placementHeight = new RelativePlacement(HorizontalAlignment.Right, VerticalAlignment.Stretch);
placementHeight.XOffset = 10;
heightDisplay = new HeightDisplay();
heightDisplay.DataContext = this.ExtendedItem.Component;
RelativePlacement placementWidth = new RelativePlacement(HorizontalAlignment.Stretch, VerticalAlignment.Bottom);
placementWidth.YOffset = 10;
widthDisplay = new WidthDisplay();
widthDisplay.DataContext = this.ExtendedItem.Component;
this.AddAdorners(placementHeight, heightDisplay);
this.AddAdorners(placementWidth, widthDisplay);
}
}
}
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

@ -99,6 +99,7 @@ @@ -99,6 +99,7 @@
<Compile Include="Controls\ResizeThumb.cs" />
<Compile Include="CallExtension.cs" />
<Compile Include="Controls\DragListener.cs" />
<Compile Include="Controls\SizeDisplay.cs" />
<Compile Include="Controls\WindowClone.cs" />
<Compile Include="Controls\ZoomControl.cs" />
<Compile Include="Converters.cs" />
@ -119,6 +120,7 @@ @@ -119,6 +120,7 @@
<Compile Include="Extensions\GridAdornerProvider.cs" />
<Compile Include="Extensions\GridPlacementSupport.cs" />
<Compile Include="Extensions\MarginHandleExtension.cs" />
<Compile Include="Extensions\SizeDisplayExtension.cs" />
<Compile Include="Extensions\SnaplinePlacementBehavior.cs">
<SubType>Code</SubType>
</Compile>

Loading…
Cancel
Save