Browse Source

Add resize ability across the full border and give solid outline around selected elements

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/wpfdesigner@5871 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Kumar Devvrat 16 years ago
parent
commit
d52f29092b
  1. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  2. 33
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs
  3. 30
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SelectedElementRectangleExtension.cs

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

@ -30,9 +30,7 @@
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:ResizeThumb}"> <ControlTemplate TargetType="{x:Type Controls:ResizeThumb}">
<Rectangle Name="thumbRectangle" <Rectangle Name="thumbRectangle"
Width="7"
Height="7"
SnapsToDevicePixels="True" SnapsToDevicePixels="True"
Stroke="Black" Stroke="Black"
Fill="White" Fill="White"

33
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs

@ -55,7 +55,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
ResizeThumb resizeThumb = new ResizeThumbImpl( cursor == Cursors.SizeNS, cursor == Cursors.SizeWE ); ResizeThumb resizeThumb = new ResizeThumbImpl( cursor == Cursors.SizeNS, cursor == Cursors.SizeWE );
resizeThumb.Cursor = cursor; resizeThumb.Cursor = cursor;
resizeThumb.Alignment = alignment; resizeThumb.Alignment = alignment;
AdornerPanel.SetPlacement(resizeThumb, new RelativePlacement(alignment.Horizontal, alignment.Vertical)); AdornerPanel.SetPlacement(resizeThumb, Place(ref resizeThumb, alignment));
adornerPanel.Children.Add(resizeThumb); adornerPanel.Children.Add(resizeThumb);
DragListener drag = new DragListener(resizeThumb); DragListener drag = new DragListener(resizeThumb);
@ -64,6 +64,37 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
drag.Completed += new DragHandler(drag_Completed); drag.Completed += new DragHandler(drag_Completed);
return resizeThumb; return resizeThumb;
} }
/// <summary>
/// Places resize thumbs at their respective positions
/// and streches out thumbs which are at the center of outline to extend resizability across the whole outline
/// </summary>
/// <param name="resizeThumb"></param>
/// <param name="alignment"></param>
/// <returns></returns>
private RelativePlacement Place(ref ResizeThumb resizeThumb,PlacementAlignment alignment)
{
RelativePlacement placement = new RelativePlacement(alignment.Horizontal,alignment.Vertical);
if (alignment.Horizontal == HorizontalAlignment.Center)
{
placement.WidthRelativeToContentWidth = 1;
placement.HeightOffset = 6;
resizeThumb.Opacity = 0;
return placement;
}
if (alignment.Vertical == VerticalAlignment.Center)
{
placement.HeightRelativeToContentHeight = 1;
placement.WidthOffset = 6;
resizeThumb.Opacity = 0;
return placement;
}
placement.WidthOffset = 6;
placement.HeightOffset = 6;
return placement;
}
Size oldSize; Size oldSize;

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

@ -27,24 +27,18 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public SelectedElementRectangleExtension() public SelectedElementRectangleExtension()
{ {
Rectangle selectionRect = new Rectangle(); Rectangle selectionRect = new Rectangle();
selectionRect.SnapsToDevicePixels = true; selectionRect.SnapsToDevicePixels = true;
selectionRect.Stroke = Brushes.White; selectionRect.Stroke = new SolidColorBrush(Color.FromRgb(51, 51, 51));
selectionRect.IsHitTestVisible = false; selectionRect.StrokeThickness = 1.5;
selectionRect.IsHitTestVisible = false;
Rectangle dottedRect = new Rectangle();
dottedRect.SnapsToDevicePixels = true; RelativePlacement placement = new RelativePlacement(HorizontalAlignment.Stretch, VerticalAlignment.Stretch);
dottedRect.Stroke = Brushes.Black; placement.XOffset = -1;
dottedRect.StrokeDashCap = PenLineCap.Square; placement.YOffset = -1;
dottedRect.StrokeDashArray = new DoubleCollection(new double[] { 0, 2 }); placement.WidthOffset = 2;
dottedRect.IsHitTestVisible = false; placement.HeightOffset = 2;
RelativePlacement placement = new RelativePlacement(HorizontalAlignment.Stretch, VerticalAlignment.Stretch); this.AddAdorners(placement, selectionRect);
placement.XOffset = -1;
placement.YOffset = -1;
placement.WidthOffset = 2;
placement.HeightOffset = 2;
this.AddAdorners(placement, selectionRect, dottedRect);
} }
} }
} }

Loading…
Cancel
Save