Browse Source

- Readjust styles

- Add offset in placement of the margin handles.
- Fix several bugs in MarginHandle and add unit tests.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/wpfdesigner@6226 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Kumar Devvrat 16 years ago
parent
commit
65b8191069
  1. 92
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  2. 122
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/MarginHandle.cs
  3. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForInvisibleControl.cs
  4. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SelectedElementRectangleExtension.cs
  5. 103
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/MarginHandleTests.cs
  6. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTestHelper.cs
  7. 12
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/PlacementTests.cs
  8. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj

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

@ -1,11 +1,15 @@ @@ -1,11 +1,15 @@
<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">
<!--
This file contains the default styles used by the Controls in ICSharpCode.WpfDesign.Designer.Controls
-->
<Converters:LevelConverter x:Key="FormatDoubleConverter" />
<ControlConvertors:HandleLengthWithOffset x:Key="HandleLengthWithOffset"/>
<SolidColorBrush Color="#FF474747" x:Key="HandleBrush"/>
<Style TargetType="{x:Type Controls:PanelMoveAdorner}">
<Setter Property="Template">
<Setter.Value>
@ -329,19 +333,20 @@ @@ -329,19 +333,20 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:MarginHandle}">
<Grid Height="8" Width="{Binding Path=HandleLength, RelativeSource={RelativeSource Mode=TemplatedParent}}" SnapsToDevicePixels="True">
<Grid Height="10" Width="{Binding Path=HandleLength, Converter={x:Static ControlConvertors:HandleLengthWithOffset.Instance}, RelativeSource={RelativeSource Mode=TemplatedParent}}" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Path Name="startArrow"
Fill="#FF333333"
Fill="{StaticResource HandleBrush}"
Stretch="Fill"
Stroke="{TemplateBinding Panel.Background}"
StrokeThickness="0.5"
Margin="0,1,0,1"
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">
<Grid Height="10" Grid.Column="1" Name="lineArrow">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition MaxWidth="20" MinWidth="10" />
@ -349,11 +354,11 @@ @@ -349,11 +354,11 @@
<ColumnDefinition Width="8" />
</Grid.ColumnDefinitions>
<Path Name="line1"
Stretch="Fill"
Stroke="#FF333333"
Stretch="Fill"
Stroke="{StaticResource HandleBrush}"
StrokeThickness="1.5"
Margin="0 0 0 0"
Data="M0,0 L1,0" Grid.Column="0"/>
Data="M0,-0.75 L1,-0.75" Grid.Column="0"/>
<TextBlock Grid.Column="1"
Text="{Binding Path=HandleLength, Mode=OneWay, Converter={x:Static Converters:FormatDoubleConverter.Instance }, RelativeSource={RelativeSource Mode=TemplatedParent}}"
FontSize="9"
@ -367,12 +372,13 @@ @@ -367,12 +372,13 @@
</TextBlock>
<Path Name="line2"
Stretch="Fill"
Stroke="#FF333333"
Stroke="{StaticResource HandleBrush}"
StrokeThickness="1.5"
Margin="0 0 0 0"
Data="M0,0 L1,0" Grid.Column="2"/>
Data="M0,-0.75 L1,-0.75" Grid.Column="2"/>
<Path Name="arrow2"
Fill="#FF333333"
Margin="0,1,0,1"
Fill="{StaticResource HandleBrush}"
Stretch="Fill"
Stroke="{TemplateBinding Panel.Background}"
StrokeThickness="0.5"
@ -398,72 +404,76 @@ @@ -398,72 +404,76 @@
Height="7"
Width="7"
StrokeThickness="1"
Stroke="#FF333333"/>
Stroke="{StaticResource HandleBrush}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:HeightDisplay}">
<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"
<Grid Width="22" >
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition MaxHeight="20" MinHeight="5" />
<RowDefinition Height="5" />
</Grid.RowDefinitions>
<Path SnapsToDevicePixels="True"
Grid.Row="0"
Stroke="#AC0000"
StrokeThickness="1.0"
Data="M0,0 L1,0 M0.75,0 L0.75,1"
Stretch="Fill" />
<TextBlock Text="{Binding Path=ActualHeight, Converter={x:Static Converters:FormatDoubleConverter.Instance}}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="8,0,0,1"
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.Row="1">
<TextBlock.LayoutTransform>
<RotateTransform Angle="270" CenterX="0.5" CenterY="0.5"/>
</TextBlock.LayoutTransform></TextBlock>
<Path SnapsToDevicePixels="True"
Grid.Row="2"
Stroke="#AC0000"
StrokeThickness="1.0"
Data="M0.75,0 L0.75,3 M0,3 L1,3 "
Stretch="Fill" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</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 Height="22" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition MaxWidth="20" MinWidth="5" />
<ColumnDefinition Width="4" />
<ColumnDefinition Width="5" />
</Grid.ColumnDefinitions>
<Path Grid.Column="0"
Stroke="Red"
Stroke="#AC0000"
StrokeThickness="1"
Data="M0,0 L0,1 M0,0.5 L1,0.5"
Stretch="Fill" />
Data="M0,0 L0,1 M0,0.75 L1,0.75"
Stretch="Fill"
SnapsToDevicePixels="True"/>
<TextBlock Text="{Binding Path=ActualWidth, Converter={x:Static Converters:FormatDoubleConverter.Instance}}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="0,8,0,0"
Padding="1,1,1,1"
FontSize="10"
Grid.Column="1"/>
<Path Grid.Column="2"
Stroke="Red"
Stroke="#AC0000"
StrokeThickness="1"
Data="M0,0.5 L3,0.5 M3,0 L3,1 "
Stretch="Fill" />
Data="M0,0.75 L3,0.75 M3,0 L3,1 "
Stretch="Fill"
SnapsToDevicePixels="True"/>
</Grid>
</ControlTemplate>
</Setter.Value>

122
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/MarginHandle.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Globalization;
using System.ComponentModel;
using System.Diagnostics;
using System.Collections.Generic;
@ -23,12 +24,17 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -23,12 +24,17 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <summary>
/// Adorner that displays the margin of a control in a Grid.
/// </summary>
class MarginHandle : Control
public class MarginHandle : Control
{
static MarginHandle()
/// <summary>
/// Places the Handle with a certain offset so the Handle does not interfere with selection outline.
/// </summary>
public static double HandleLengthOffset;
static MarginHandle()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(MarginHandle), new FrameworkPropertyMetadata(typeof(MarginHandle)));
HandleLengthOffset=2;
}
/// <summary>
@ -53,7 +59,11 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -53,7 +59,11 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <summary> This grid contains the handle line and the endarrow.</summary>
Grid lineArrow;
MarginStub marginStub;
/// <summary>
/// Gets the Stub for this handle
/// </summary>
public MarginStub Stub {get; private set;}
/// <summary>
/// Gets/Sets the angle by which handle rotates.
@ -104,8 +114,13 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -104,8 +114,13 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
Angle = (double)orientation;
grid=(Grid)adornedControlItem.Parent.Component;
adornedControl=(FrameworkElement)adornedControlItem.Component;
marginStub = new MarginStub(this);
Stub = new MarginStub(this);
ShouldBeVisible=true;
BindAndPlaceHandle();
adornedControlItem.PropertyChanged += OnPropertyChanged;
OnPropertyChanged(this.adornedControlItem, new PropertyChangedEventArgs("HorizontalAlignment"));
OnPropertyChanged(this.adornedControlItem, new PropertyChangedEventArgs("VerticalAlignment"));
}
/// <summary>
@ -115,8 +130,8 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -115,8 +130,8 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
{
if (!adornerPanel.Children.Contains(this))
adornerPanel.Children.Add(this);
if (!adornerPanel.Children.Contains(marginStub))
adornerPanel.Children.Add(marginStub);
if (!adornerPanel.Children.Contains(Stub))
adornerPanel.Children.Add(Stub);
RelativePlacement placement=new RelativePlacement();
Binding binding = new Binding();
binding.Source = adornedControl;
@ -125,18 +140,22 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -125,18 +140,22 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
case HandleOrientation.Left:
binding.Path = new PropertyPath("Margin.Left");
placement = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Center);
placement.XOffset=-HandleLengthOffset;
break;
case HandleOrientation.Top:
binding.Path = new PropertyPath("Margin.Top");
placement = new RelativePlacement(HorizontalAlignment.Center, VerticalAlignment.Top);
placement.YOffset=-HandleLengthOffset;
break;
case HandleOrientation.Right:
binding.Path = new PropertyPath("Margin.Right");
placement = new RelativePlacement(HorizontalAlignment.Right, VerticalAlignment.Center);
placement.XOffset=HandleLengthOffset;
break;
case HandleOrientation.Bottom:
binding.Path = new PropertyPath("Margin.Bottom");
placement = new RelativePlacement(HorizontalAlignment.Center, VerticalAlignment.Bottom);
placement.YOffset=HandleLengthOffset;
break;
}
@ -144,7 +163,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -144,7 +163,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
SetBinding(HandleLengthProperty, binding);
AdornerPanel.SetPlacement(this, placement);
AdornerPanel.SetPlacement(marginStub, placement);
AdornerPanel.SetPlacement(Stub, placement);
DecideVisiblity(this.HandleLength);
}
@ -155,20 +174,53 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -155,20 +174,53 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <param name="handleLength"></param>
public void DecideVisiblity(double handleLength)
{
if(!DisplayOnlyStub){
if(ShouldBeVisible){
marginStub.Visibility = handleLength == 0.0 ? Visibility.Visible : Visibility.Hidden;
this.Visibility = handleLength != 0.0 ? Visibility.Visible : Visibility.Hidden;
if (this.lineArrow != null){
lineArrow.Visibility = handleLength < 23 ? Visibility.Hidden : Visibility.Visible;
}
}
}
else {
DisplayOnlyStub=false;
DecideVisiblity(this.HandleLength);
}
}
if (ShouldBeVisible)
{
if (!DisplayOnlyStub)
{
this.Visibility = handleLength != 0.0 ? Visibility.Visible : Visibility.Hidden;
if (this.lineArrow != null)
{
lineArrow.Visibility = handleLength < 23 ? Visibility.Hidden : Visibility.Visible;
}
Stub.Visibility = this.Visibility == Visibility.Visible ? Visibility.Hidden : Visibility.Visible;
}
else
{
this.Visibility = Visibility.Hidden;
Stub.Visibility = Visibility.Visible;
}
}
else {
this.Visibility = Visibility.Hidden;
Stub.Visibility = Visibility.Hidden;
}
}
void OnPropertyChanged(object sender,PropertyChangedEventArgs e)
{
if(e.PropertyName=="HorizontalAlignment" && (orientation==HandleOrientation.Left || orientation==HandleOrientation.Right)) {
var ha = (HorizontalAlignment) adornedControlItem.Properties[FrameworkElement.HorizontalAlignmentProperty].ValueOnInstance;
if(ha==HorizontalAlignment.Stretch) {
DisplayOnlyStub = false;
}else if(ha==HorizontalAlignment.Center) {
DisplayOnlyStub = true;
} else
DisplayOnlyStub = ha.ToString() != orientation.ToString();
}
if(e.PropertyName=="VerticalAlignment" && (orientation==HandleOrientation.Top || orientation==HandleOrientation.Bottom)) {
var va = (VerticalAlignment)adornedControlItem.Properties[FrameworkElement.VerticalAlignmentProperty].ValueOnInstance;
if(va==VerticalAlignment.Stretch) {
DisplayOnlyStub = false;
} else if(va==VerticalAlignment.Center) {
DisplayOnlyStub = true;
} else
DisplayOnlyStub = va.ToString() != orientation.ToString();
}
DecideVisiblity(this.HandleLength);
}
public override void OnApplyTemplate()
{
@ -183,7 +235,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -183,7 +235,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <summary>
/// Display a stub indicating that the margin is not set.
/// </summary>
class MarginStub : Control
public class MarginStub : Control
{
MarginHandle marginHandle;
static MarginStub()
@ -230,3 +282,27 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -230,3 +282,27 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
}
}
namespace ICSharpCode.WpfDesign.Designer.Controls.Converters
{
/// <summary>
/// Offset the Handle Length with MarginHandle.HandleLengthOffset
/// </summary>
public class HandleLengthWithOffset : IValueConverter
{
public static HandleLengthWithOffset Instance = new HandleLengthWithOffset();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if(value is double) {
return Math.Max((double)value - MarginHandle.HandleLengthOffset,0);
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForInvisibleControl.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -28,7 +28,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var adornerPanel = new AdornerPanel();
var border = new Border();
border.BorderThickness = new Thickness(1);
border.BorderBrush = Brushes.DimGray;
border.BorderBrush = new SolidColorBrush(Color.FromRgb(0xCC, 0xCC, 0xCC));
border.IsHitTestVisible = false;
AdornerPanel.SetPlacement(border, AdornerPlacement.FillContent);
adornerPanel.Children.Add(border);

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SelectedElementRectangleExtension.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -28,7 +28,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
Rectangle selectionRect = new Rectangle();
selectionRect.SnapsToDevicePixels = true;
selectionRect.Stroke = new SolidColorBrush(Color.FromRgb(51, 51, 51));
selectionRect.Stroke = new SolidColorBrush(Color.FromRgb(0x47, 0x47, 0x47));
selectionRect.StrokeThickness = 1.5;
selectionRect.IsHitTestVisible = false;

103
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/MarginHandleTests.cs

@ -0,0 +1,103 @@ @@ -0,0 +1,103 @@
// <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.Windows;
using System.Windows.Controls;
using NUnit.Framework;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
namespace ICSharpCode.WpfDesign.Tests.Designer
{
[TestFixture]
public class MarginHandleTests : ModelTestHelper
{
private DesignItem _button;
[TestFixtureSetUp]
public void Intialize()
{
_button = CreateGridContext("<Button Margin=\"21,21,21,21\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Top\"/>");
var gridItem = _button.Parent;
gridItem.Properties[FrameworkElement.HeightProperty].SetValue("200");
gridItem.Properties[FrameworkElement.WidthProperty].SetValue("200");
}
[Test]
public void HandleLength()
{
Intialize();
var handle = new MarginHandle(_button, new AdornerPanel(), HandleOrientation.Left);
Assert.AreEqual(21, handle.HandleLength);
Assert.IsTrue(handle.Visibility == Visibility.Visible, "Handle is not visible");
Assert.IsTrue(handle.Stub.Visibility == Visibility.Hidden, "Stub is Visible");
}
[Test]
public void MoveTest()
{
Intialize();
var handle = new MarginHandle(_button, new AdornerPanel(), HandleOrientation.Left);
var grid = _button.Parent.View;
grid.Measure(grid.DesiredSize);
grid.Arrange(new Rect(grid.DesiredSize));
grid.UpdateLayout();
PlacementTests.Move(new Vector(20, 20), _button);
Assert.AreEqual(41,handle.HandleLength);
Assert.IsTrue(handle.Visibility == Visibility.Visible, "Handle is not visible");
Assert.IsTrue(handle.Stub.Visibility == Visibility.Hidden, "Stub is Visible");
}
[Test]
[TestCase(20,20)]
[TestCase(20,400)]
[TestCase(400,20)]
public void ResizeTest(double width,double height)
{
var handle = new MarginHandle(_button, new AdornerPanel(), HandleOrientation.Left);
var grid = _button.Parent.View;
grid.Measure(grid.DesiredSize);
grid.Arrange(new Rect(grid.DesiredSize));
grid.UpdateLayout();
PlacementTests.Resize(new Rect(20, 20, width, height), _button);
Assert.AreEqual(20, handle.HandleLength);
Assert.IsTrue(handle.Visibility == Visibility.Visible, "Handle is not visible");
Assert.IsTrue(handle.Stub.Visibility == Visibility.Hidden, "Stub is Visible");
}
[Test]
public void ChangeHorizontalAlignment()
{
var leftHandle = new MarginHandle(_button, new AdornerPanel(), HandleOrientation.Left);
var rightHandle = new MarginHandle(_button, new AdornerPanel(), HandleOrientation.Right);
_button.Properties[FrameworkElement.HorizontalAlignmentProperty].SetValue(HorizontalAlignment.Right);
Assert.IsFalse(leftHandle.Visibility == Visibility.Visible, "Left Handle is visible");
Assert.IsFalse(leftHandle.Stub.Visibility == Visibility.Hidden, "Left Stub is not Visible");
Assert.IsTrue(rightHandle.Visibility == Visibility.Visible, "Right Handle is not visible");
Assert.IsTrue(rightHandle.Stub.Visibility == Visibility.Hidden, "Right Stub is Visible");
}
[Test]
public void ChangeVerticalAlignment()
{
var topHandle = new MarginHandle(_button, new AdornerPanel(), HandleOrientation.Top);
var bottomHandle = new MarginHandle(_button, new AdornerPanel(), HandleOrientation.Bottom);
_button.Properties[FrameworkElement.VerticalAlignmentProperty].SetValue(VerticalAlignment.Bottom);
Assert.IsFalse(topHandle.Visibility == Visibility.Visible, "Top Handle is visible");
Assert.IsFalse(topHandle.Stub.Visibility == Visibility.Hidden, "Top Stub is not Visible");
Assert.IsTrue(bottomHandle.Visibility == Visibility.Visible, "Bottom Handle is not visible");
Assert.IsTrue(bottomHandle.Stub.Visibility == Visibility.Hidden, "Bottom Stub is Visible");
}
}
}

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTestHelper.cs

@ -77,6 +77,15 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -77,6 +77,15 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
Assert.AreEqual(expectedXaml, actualXaml);
}
protected DesignItem CreateGridContext(string xaml)
{
XamlDesignContext context = CreateContext(@"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >
" + xaml + "</Grid>");
var grid = (Grid)context.RootItem.Component;
var gridChild = context.Services.Component.GetDesignItem(grid.Children[0]);
return gridChild;
}
static string ItemIdentity(DesignItem item)
{
return item.ComponentType.Name + " (" + item.GetHashCode() + ")";

12
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/PlacementTests.cs

@ -17,7 +17,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -17,7 +17,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
[TestFixture]
public class PlacementTests : ModelTestHelper
{
void Move(Vector v, params DesignItem[] items)
internal static void Move(Vector v, params DesignItem[] items)
{
PlacementOperation operation = PlacementOperation.Start(items, PlacementType.Move);
foreach (PlacementInformation info in operation.PlacedItems) {
@ -30,6 +30,16 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -30,6 +30,16 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
operation.Commit();
}
internal static void Resize(Rect rect,params DesignItem[] items)
{
PlacementOperation operation = PlacementOperation.Start(items, PlacementType.Resize);
foreach(var info in operation.PlacedItems) {
info.Bounds = rect;
operation.CurrentContainerBehavior.SetPosition(info);
}
operation.Commit();
}
[Test]
[Ignore] //Currently bounds calculated using visuals
public void MoveFixedWidthButton()

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj

@ -55,6 +55,7 @@ @@ -55,6 +55,7 @@
<Link>GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Designer\MarginHandleTests.cs" />
<Compile Include="Designer\ModelTestHelper.cs" />
<Compile Include="Designer\ModelTests.cs" />
<Compile Include="Designer\PlacementTests.cs" />

Loading…
Cancel
Save