Browse Source

A few Refactorings of classes

Path Extension -> Now the Segment Types can be switched
pull/633/head
jogibear9988 11 years ago
parent
commit
ea0b2abdd6
  1. 15
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  2. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/QuickOperationMenu.cs
  3. 56
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/DesignerThumb.cs
  4. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/MultiPointThumb.cs
  5. 52
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/PointThumb.cs
  6. 52
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/ResizeThumb.cs
  7. 12
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/RotateThumb.cs
  8. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs
  9. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineExtensionBase.cs
  10. 22
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs
  11. 221
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs
  12. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs
  13. 42
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs
  14. 34
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs
  15. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RotateThumbExtension.cs
  16. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

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

@ -46,11 +46,20 @@ @@ -46,11 +46,20 @@
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type Controls:ResizeThumb}">
<Style TargetType="{x:Type Controls:DesignerThumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:ResizeThumb}">
<ControlTemplate TargetType="{x:Type Controls:DesignerThumb}">
<Grid>
<Rectangle Name="thumbRectangle" SnapsToDevicePixels="True" Stroke="Black" Fill="White" RadiusX="1.414" RadiusY="1.414" />
<Menu Height="15" HorizontalAlignment="Left" Margin="0,-19,-19,0" VerticalAlignment="Top" Width="15" BorderThickness="0" Background="Transparent" Visibility="{Binding Path=OperationMenu, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:CollapsedWhenNull.Instance}}" >
<MenuItem Height="15" Width="15" Padding="0" Background="Transparent" BorderThickness="1" ItemsSource="{TemplateBinding OperationMenu}">
<MenuItem.Header>
<Path Data="M3.5,5.5 L11.5,5.5 L7.5,11 z" Fill="Black" Stroke="Gray" StrokeThickness="1" />
</MenuItem.Header>
</MenuItem>
</Menu>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsPrimarySelection" Value="False">
<Setter TargetName="thumbRectangle" Property="Stroke" Value="White" />
@ -59,7 +68,7 @@ @@ -59,7 +68,7 @@
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="thumbRectangle" Property="Fill" Value="Gray" />
</Trigger>
<Trigger Property="ResizeThumbVisible" Value="False">
<Trigger Property="ThumbVisible" Value="False">
<Setter TargetName="thumbRectangle" Property="Visibility" Value="Hidden" />
</Trigger>
</ControlTemplate.Triggers>

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/QuickOperationMenu.cs

@ -20,10 +20,8 @@ using System; @@ -20,10 +20,8 @@ using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.Converters;
using System.Globalization;
using System.Windows.Data;
using ICSharpCode.WpfDesign.Designer.UIExtensions;

56
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ResizeThumb.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/DesignerThumb.cs

@ -16,42 +16,42 @@ @@ -16,42 +16,42 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// A thumb where the look can depend on the IsPrimarySelection property.
/// </summary>
public class ResizeThumb : Thumb
public class DesignerThumb : Thumb
{
/// <summary>
/// Dependency property for <see cref="IsPrimarySelection"/>.
/// </summary>
public static readonly DependencyProperty IsPrimarySelectionProperty
= DependencyProperty.Register("IsPrimarySelection", typeof(bool), typeof(ResizeThumb));
= DependencyProperty.Register("IsPrimarySelection", typeof(bool), typeof(DesignerThumb));
/// <summary>
/// Dependency property for <see cref="IsPrimarySelection"/>.
/// </summary>
public static readonly DependencyProperty ResizeThumbVisibleProperty
= DependencyProperty.Register("ResizeThumbVisible", typeof(bool), typeof(ResizeThumb), new FrameworkPropertyMetadata(true));
public static readonly DependencyProperty ThumbVisibleProperty
= DependencyProperty.Register("ThumbVisible", typeof(bool), typeof(DesignerThumb), new FrameworkPropertyMetadata(true));
/// <summary>
/// Dependency property for <see cref="OperationMenu"/>.
/// </summary>
public static readonly DependencyProperty OperationMenuProperty =
DependencyProperty.Register("OperationMenu", typeof(MenuItem[]), typeof(DesignerThumb), new PropertyMetadata(null));
internal PlacementAlignment Alignment;
static ResizeThumb()
static DesignerThumb()
{
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
//This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(typeof(ResizeThumb), new FrameworkPropertyMetadata(typeof(ResizeThumb)));
DefaultStyleKeyProperty.OverrideMetadata(typeof(DesignerThumb), new FrameworkPropertyMetadata(typeof(DesignerThumb)));
}
/// <summary>
@ -65,36 +65,18 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -65,36 +65,18 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <summary>
/// Gets/Sets if the resize thumb is visible.
/// </summary>
public bool ResizeThumbVisible {
get { return (bool)GetValue(ResizeThumbVisibleProperty); }
set { SetValue(ResizeThumbVisibleProperty, value); }
}
public bool ThumbVisible {
get { return (bool)GetValue(ThumbVisibleProperty); }
set { SetValue(ThumbVisibleProperty, value); }
}
/// <summary>
/// Resize thumb that automatically disappears if the adornered element is too small.
/// Gets/Sets the OperationMenu.
/// </summary>
sealed class ResizeThumbImpl : ResizeThumb
{
bool checkWidth, checkHeight;
internal ResizeThumbImpl(bool checkWidth, bool checkHeight)
public MenuItem[] OperationMenu
{
Debug.Assert((checkWidth && checkHeight) == false);
this.checkWidth = checkWidth;
this.checkHeight = checkHeight;
}
protected override Size ArrangeOverride(Size arrangeBounds)
{
AdornerPanel parent = this.Parent as AdornerPanel;
if (parent != null && parent.AdornedElement != null) {
if (checkWidth)
this.ResizeThumbVisible = PlacementOperation.GetRealElementSize(parent.AdornedElement).Width > 14;
else if (checkHeight)
this.ResizeThumbVisible = PlacementOperation.GetRealElementSize(parent.AdornedElement).Height > 14;
}
return base.ArrangeOverride(arrangeBounds);
get { return (MenuItem[])GetValue(OperationMenuProperty); }
set { SetValue(OperationMenuProperty, value); }
}
}
}

13
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/MultiPointResizeThumb.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/MultiPointThumb.cs

@ -16,18 +16,19 @@ @@ -16,18 +16,19 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Designer.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Description of MultiPointResizeThumb.
/// Description of MultiPointThumb.
/// </summary>
sealed class MultiPointResizeThumb: ResizeThumb
internal sealed class MultiPointThumb : DesignerThumb
{
private int _index;
public int Index
{
get { return _index; }
@ -41,11 +42,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -41,11 +42,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
private AdornerPlacement _adornerPlacement;
public AdornerPlacement AdornerPlacement
{
get { return _adornerPlacement; }
set { _adornerPlacement = value; }
}
}
}

52
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/PointThumb.cs

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Windows;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Description of MultiPointThumb.
/// </summary>
internal class PointThumb : DesignerThumb
{
public PointThumb(Point point)
{
this.AdornerPlacement = new PointPlacementSupport(point);
}
public AdornerPlacement AdornerPlacement { get; private set; }
public class PointPlacementSupport : AdornerPlacement
{
private Point p;
public PointPlacementSupport(Point point)
{
this.p = point;
}
public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
{
double thumbsize = 7;
adorner.Arrange(new Rect(p.X - thumbsize / 2, p.Y - thumbsize / 2, thumbsize, thumbsize));
}
}
}
}

52
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/ResizeThumb.cs

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Diagnostics;
using System.Windows;
using ICSharpCode.WpfDesign.Adorners;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Resize thumb that automatically disappears if the adornered element is too small.
/// </summary>
sealed class ResizeThumb : DesignerThumb
{
bool checkWidth, checkHeight;
internal ResizeThumb(bool checkWidth, bool checkHeight)
{
Debug.Assert((checkWidth && checkHeight) == false);
this.checkWidth = checkWidth;
this.checkHeight = checkHeight;
}
protected override Size ArrangeOverride(Size arrangeBounds)
{
AdornerPanel parent = this.Parent as AdornerPanel;
if (parent != null && parent.AdornedElement != null)
{
if (checkWidth)
this.ThumbVisible = PlacementOperation.GetRealElementSize(parent.AdornedElement).Width > 14;
else if (checkHeight)
this.ThumbVisible = PlacementOperation.GetRealElementSize(parent.AdornedElement).Height > 14;
}
return base.ArrangeOverride(arrangeBounds);
}
}
}

12
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/RotateThumb.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/RotateThumb.cs

@ -17,20 +17,12 @@ @@ -17,20 +17,12 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class RotateThumb : ResizeThumb
public class RotateThumb : DesignerThumb
{
static RotateThumb()
{
@ -39,7 +31,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -39,7 +31,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
public RotateThumb()
{
this.ResizeThumbVisible = true;
this.ThumbVisible = true;
}
}
}

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs

@ -131,6 +131,26 @@ namespace ICSharpCode.WpfDesign.Designer.Converters @@ -131,6 +131,26 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
}
}
public class CollapsedWhenNull : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly CollapsedWhenNull Instance = new CollapsedWhenNull();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
{
return Visibility.Visible;
}
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class FalseWhenNull : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineExtensionBase.cs

@ -98,7 +98,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -98,7 +98,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
protected void UpdateAdornerVisibility()
{
FrameworkElement fe = this.ExtendedItem.View as FrameworkElement;
foreach (ResizeThumb r in resizeThumbs)
foreach (DesignerThumb r in resizeThumbs)
{
bool isVisible = resizeBehavior != null &&
resizeBehavior.CanPlace(extendedItemArray, PlacementType.Resize, r.Alignment);
@ -110,11 +110,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -110,11 +110,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// 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="designerThumb"></param>
/// <param name="alignment"></param>
/// <param name="index">if using a polygon or multipoint adorner this is the index of the point in the Points array</param>
/// <returns></returns>
protected PointTrackerPlacementSupport Place(ref ResizeThumb resizeThumb, PlacementAlignment alignment, int index = -1)
protected PointTrackerPlacementSupport Place(ref DesignerThumb designerThumb, PlacementAlignment alignment, int index = -1)
{
PointTrackerPlacementSupport placement = new PointTrackerPlacementSupport(ExtendedItem.View as Shape, alignment, index);
return placement;

22
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs

@ -44,19 +44,19 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -44,19 +44,19 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public DragListener DragListener {get; private set;}
protected ResizeThumb CreateThumb(PlacementAlignment alignment, Cursor cursor)
protected DesignerThumb CreateThumb(PlacementAlignment alignment, Cursor cursor)
{
ResizeThumb resizeThumb = new ResizeThumb { Alignment = alignment, Cursor = cursor, IsPrimarySelection = true};
AdornerPanel.SetPlacement(resizeThumb, Place(ref resizeThumb, alignment));
DesignerThumb designerThumb = new DesignerThumb { Alignment = alignment, Cursor = cursor, IsPrimarySelection = true};
AdornerPanel.SetPlacement(designerThumb, Place(ref designerThumb, alignment));
adornerPanel.Children.Add(resizeThumb);
adornerPanel.Children.Add(designerThumb);
DragListener = new DragListener(resizeThumb);
DragListener = new DragListener(designerThumb);
DragListener.Started += drag_Started;
DragListener.Changed += drag_Changed;
DragListener.Completed += drag_Completed;
return resizeThumb;
return designerThumb;
}
protected Bounds CalculateDrawing(double x, double y, double left, double top, double xleft, double xtop)
@ -118,14 +118,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -118,14 +118,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
_isResizing = true;
(drag.Target as ResizeThumb).IsPrimarySelection = false;
(drag.Target as DesignerThumb).IsPrimarySelection = false;
}
protected virtual void drag_Changed(DragListener drag)
{
Line al = ExtendedItem.View as Line;
var alignment = (drag.Target as ResizeThumb).Alignment;
var alignment = (drag.Target as DesignerThumb).Alignment;
var info = operation.PlacedItems[0];
double dx = 0;
double dy = 0;
@ -175,7 +175,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -175,7 +175,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
operation.CurrentContainerBehavior.SetPosition(info);
}
(drag.Target as ResizeThumb).InvalidateArrange();
(drag.Target as DesignerThumb).InvalidateArrange();
ResetWidthHeightProperties();
}
@ -202,7 +202,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -202,7 +202,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
_isResizing = false;
(drag.Target as ResizeThumb).IsPrimarySelection = true;
(drag.Target as DesignerThumb).IsPrimarySelection = true;
HideSizeAndShowHandles();
}
@ -213,7 +213,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -213,7 +213,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
base.OnInitialized();
resizeThumbs = new ResizeThumb[]
resizeThumbs = new DesignerThumb[]
{
CreateThumb(PlacementAlignment.TopLeft, Cursors.Cross),
CreateThumb(PlacementAlignment.BottomRight, Cursors.Cross)

221
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs

@ -28,10 +28,14 @@ using System.Windows.Shapes; @@ -28,10 +28,14 @@ using System.Windows.Shapes;
using System.Windows;
using System.Windows.Controls;
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows.Data;
using ICSharpCode.SharpDevelop.Widgets;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using DragListener = ICSharpCode.WpfDesign.Designer.Controls.DragListener;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
@ -41,42 +45,158 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -41,42 +45,158 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
[ExtensionFor(typeof(Path))]
internal class PathHandlerExtension : LineExtensionBase, IKeyDown, IKeyUp
{
enum PathPartConvertType
{
ToLineSegment,
ToBezierSegment,
ToQuadricBezierSegment,
}
protected class PathPoint
{
public PathPoint(Point point, Object @object, Object parentObject, Action<Point> setLambda)
{
this._point = point;
this._setLambda = setLambda;
this.Object = @object;
this.ParentObject = parentObject;
}
private Point _point;
Action<Point> _setLambda;
public Point Point
{
get { return _point; }
set { _setLambda(value); }
}
public Point ReferencePoint { get; private set; }
public object Object { get; private set; }
public object ParentObject { get; private set; }
public int PolyLineIndex { get; set; }
}
protected class PathThumb : PointThumb
{
public PathThumb(Point point, int index, PathPoint pathpoint) : base(point)
{
this.Index = index;
this.PathPoint = pathpoint;
}
public int Index { get; set; }
public PathPoint PathPoint { get; set; }
}
private readonly Dictionary<int, Bounds> _selectedThumbs = new Dictionary<int, Bounds>();
private bool _isDragging;
ZoomControl _zoom;
private MenuItem[] segmentContextMenu = null;
public PathHandlerExtension()
{
var mnu1 = new MenuItem() { Header = "to Line Segment" };
mnu1.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.ToLineSegment);
var mnu2 = new MenuItem() {Header = "to Bezier Segment"};
mnu2.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.ToBezierSegment);
var mnu3 = new MenuItem() {Header = "to Quadric Bezier Segment"};
mnu3.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.ToQuadricBezierSegment);
segmentContextMenu = new[] {mnu1, mnu2, mnu3};
}
#region thumb methods
protected ResizeThumb CreateThumb(PlacementAlignment alignment, Cursor cursor, int index)
protected DesignerThumb CreateThumb(PlacementAlignment alignment, Cursor cursor, int index, PathPoint pathpoint)
{
ResizeThumb resizeThumb = new MultiPointResizeThumb { Index = index, Alignment = alignment, Cursor = cursor, IsPrimarySelection = true };
AdornerPlacement ap = Place(ref resizeThumb, alignment, index);
(resizeThumb as MultiPointResizeThumb).AdornerPlacement = ap;
var point = pathpoint.Point;
var transform = ((Shape)this.ExtendedItem.View).RenderedGeometry.Transform;
point = transform.Transform(point);
var designerThumb = new PathThumb(point, index, pathpoint) {Cursor = cursor};
AdornerPanel.SetPlacement(resizeThumb, ap);
adornerPanel.Children.Add(resizeThumb);
if (pathpoint.Object is LineSegment || pathpoint.Object is PolyLineSegment || pathpoint.Object is BezierSegment || pathpoint.Object is QuadraticBezierSegment) {
designerThumb.OperationMenu = segmentContextMenu;
}
DragListener drag = new DragListener(resizeThumb);
AdornerPanel.SetPlacement(designerThumb, designerThumb.AdornerPlacement);
adornerPanel.Children.Add(designerThumb);
WeakEventManager<ResizeThumb, MouseButtonEventArgs>.AddHandler(resizeThumb, "PreviewMouseLeftButtonDown", ResizeThumbOnMouseLeftButtonUp);
DragListener drag = new DragListener(designerThumb);
WeakEventManager<DesignerThumb, MouseButtonEventArgs>.AddHandler(designerThumb, "PreviewMouseLeftButtonDown", ResizeThumbOnMouseLeftButtonUp);
drag.MouseDown += drag_MouseDown;
drag.Started += drag_Started;
drag.Changed += drag_Changed;
drag.Completed += drag_Completed;
return resizeThumb;
return designerThumb;
}
private static void ConvertPart(PathThumb senderThumb, PathPartConvertType convertType)
{
if (senderThumb.PathPoint.ParentObject is PathFigure)
{
var pathFigure = senderThumb.PathPoint.ParentObject as PathFigure;
var pathSegment = senderThumb.PathPoint.Object as PathSegment;
var idx = pathFigure.Segments.IndexOf(pathSegment);
var point = senderThumb.PathPoint.Point;
if (pathSegment is PolyLineSegment)
{
var poly = pathSegment as PolyLineSegment;
var lst = poly.Points.Take(senderThumb.PathPoint.PolyLineIndex);
var lst2 = poly.Points.Skip(senderThumb.PathPoint.PolyLineIndex + 1);
pathFigure.Segments.RemoveAt(idx);
var p1 = new PolyLineSegment();
p1.Points.AddRange(lst);
pathFigure.Segments.Insert(idx, p1);
pathFigure.Segments.Insert(idx+1, new LineSegment());
var p2 = new PolyLineSegment();
p2.Points.AddRange(lst2);
pathFigure.Segments.Insert(idx+2, p2);
idx++;
}
pathFigure.Segments.RemoveAt(idx);
PathSegment newSegment = null;
switch (convertType)
{
case PathPartConvertType.ToBezierSegment:
newSegment = new BezierSegment() { Point1 = point - new Vector(40, 40), Point2 = point + new Vector(-40, 40), Point3 = point };
break;
case PathPartConvertType.ToQuadricBezierSegment:
newSegment = new QuadraticBezierSegment() { Point1 = point - new Vector(40, 40), Point2 = point };
break;
default:
newSegment = new LineSegment() { Point = point };
break;
}
pathFigure.Segments.Insert(idx, newSegment);
}
}
private void ResetThumbs()
{
foreach (FrameworkElement rt in adornerPanel.Children)
{
if (rt is ResizeThumb)
(rt as ResizeThumb).IsPrimarySelection = true;
if (rt is DesignerThumb)
(rt as DesignerThumb).IsPrimarySelection = true;
}
_selectedThumbs.Clear();
}
private void SelectThumb(MultiPointResizeThumb mprt)
private void SelectThumb(PathThumb mprt)
{
var points = GetPoints();
Point p = points[mprt.Index].Point;
@ -92,7 +212,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -92,7 +212,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
private void ResizeThumbOnMouseLeftButtonUp(object sender, MouseButtonEventArgs mouseButtonEventArgs)
{
//get current thumb
MultiPointResizeThumb mprt = sender as MultiPointResizeThumb;
var mprt = sender as PathThumb;
if (mprt != null)
{
//shift+ctrl will remove selected point
@ -104,7 +224,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -104,7 +224,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var points = GetPoints();
//iterate thumbs to lower index of remaining thumbs
foreach (MultiPointResizeThumb m in adornerPanel.Children)
foreach (PathThumb m in adornerPanel.Children)
{
if (m.Index > mprt.Index)
m.Index--;
@ -141,7 +261,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -141,7 +261,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
protected void drag_Started(DragListener drag)
{
//get current thumb
MultiPointResizeThumb mprt = (drag.Target as MultiPointResizeThumb);
var mprt = (drag.Target as PathThumb);
if (mprt != null)
{
SetOperation();
@ -214,7 +334,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -214,7 +334,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
var points = GetPoints();
MultiPointResizeThumb mprt = drag.Target as MultiPointResizeThumb;
var mprt = drag.Target as PathThumb;
if (mprt != null)
{
double dx = 0;
@ -258,9 +378,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -258,9 +378,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
// //set index of all points that had a higher index than selected to +1
// foreach (FrameworkElement rt in adornerPanel.Children)
// {
// if (rt is MultiPointResizeThumb)
// if (rt is MultiPathThumb)
// {
// MultiPointResizeThumb t = rt as MultiPointResizeThumb;
// MultiPathThumb t = rt as MultiPathThumb;
// if (t.Index > mprt.Index)
// t.Index++;
// }
@ -290,12 +410,12 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -290,12 +410,12 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
ChangeOperation(points);
(drag.Target as ResizeThumb).InvalidateArrange();
(drag.Target as DesignerThumb).InvalidateArrange();
}
protected void drag_Completed(DragListener drag)
{
MultiPointResizeThumb mprt = drag.Target as MultiPointResizeThumb;
var mprt = drag.Target as PathThumb;
if (mprt != null)
{
if (operation != null && drag.IsCanceled)
@ -318,10 +438,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -318,10 +438,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var points = GetPoints();
resizeThumbs = new List<ResizeThumb>();
resizeThumbs = new List<DesignerThumb>();
for (int i = 0; i < points.Count; i++)
{
CreateThumb(PlacementAlignment.BottomRight, Cursors.Cross, i);
CreateThumb(PlacementAlignment.BottomRight, Cursors.Cross, i, points[i]);
}
Invalidate();
@ -342,7 +462,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -342,7 +462,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
return GetPoints(this.ExtendedItem.View as Path);
}
public static List<PathPoint> GetPoints(Path path)
static List<PathPoint> GetPoints(Path path)
{
var retVal = new List<PathPoint>();
AddGeometryPoints(retVal, path.Data);
@ -360,63 +480,46 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -360,63 +480,46 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var g = geometry as PathGeometry;
if (geometry!=null) {
foreach(var figure in g.Figures) {
list.Add(new PathPoint(figure.StartPoint, figure, (p) => figure.StartPoint = p));
list.Add(new PathPoint(figure.StartPoint, figure, null, (p) => figure.StartPoint = p));
foreach (var s in figure.Segments) {
if (s is LineSegment)
list.Add(new PathPoint(((LineSegment)s).Point, s, (p) => ((LineSegment)s).Point = p));
list.Add(new PathPoint(((LineSegment)s).Point, s, figure, (p) => ((LineSegment)s).Point = p));
else if (s is PolyLineSegment) {
var poly = s as PolyLineSegment;
for(int n=0; n<poly.Points.Count; n++) {
list.Add(new PathPoint(poly.Points[n], s, (p) => poly.Points[n] = p));
for(int n=0; n<poly.Points.Count; n++)
{
var closure_n = n;
list.Add(new PathPoint(poly.Points[closure_n], s, figure, (p) => poly.Points[closure_n] = p) { PolyLineIndex = closure_n });
}
}
else if (s is BezierSegment) {
list.Add(new PathPoint(((BezierSegment)s).Point1, s, (p) => ((BezierSegment)s).Point1 = p));
list.Add(new PathPoint(((BezierSegment)s).Point2, s, (p) => ((BezierSegment)s).Point2 = p));
list.Add(new PathPoint(((BezierSegment)s).Point3, s, (p) => ((BezierSegment)s).Point3 = p));
list.Add(new PathPoint(((BezierSegment)s).Point1, s, figure, (p) => ((BezierSegment)s).Point1 = p));
list.Add(new PathPoint(((BezierSegment)s).Point2, s, figure, (p) => ((BezierSegment)s).Point2 = p));
list.Add(new PathPoint(((BezierSegment)s).Point3, s, figure, (p) => ((BezierSegment)s).Point3 = p));
}
else if (s is QuadraticBezierSegment) {
list.Add(new PathPoint(((QuadraticBezierSegment)s).Point1, s, (p) => ((QuadraticBezierSegment)s).Point1 = p));
list.Add(new PathPoint(((QuadraticBezierSegment)s).Point2, s, (p) => ((QuadraticBezierSegment)s).Point2 = p));
list.Add(new PathPoint(((QuadraticBezierSegment)s).Point1, s, figure, (p) => ((QuadraticBezierSegment)s).Point1 = p));
list.Add(new PathPoint(((QuadraticBezierSegment)s).Point2, s, figure, (p) => ((QuadraticBezierSegment)s).Point2 = p));
}
else if (s is ArcSegment)
list.Add(new PathPoint(((ArcSegment)s).Point, s, (p) => ((ArcSegment)s).Point = p));
list.Add(new PathPoint(((ArcSegment)s).Point, s, figure, (p) => ((ArcSegment)s).Point = p));
}
}
}
} else if (geometry is RectangleGeometry) {
var g = geometry as RectangleGeometry;
list.Add(new PathPoint(g.Rect.TopLeft, geometry, null)); //(p) => g.Rect.Left = p.X));
list.Add(new PathPoint(g.Rect.TopRight, geometry, null)); //(p) => g.Rect.Width = p.X));
list.Add(new PathPoint(g.Rect.BottomLeft, geometry, null)); //(p) => g.Rect.Top = p.Y));
list.Add(new PathPoint(g.Rect.BottomRight, geometry, null)); //(p) => g.Rect.Height = p.Y));
list.Add(new PathPoint(g.Rect.TopLeft, geometry, null, null)); //(p) => g.Rect.Left = p.X));
list.Add(new PathPoint(g.Rect.TopRight, geometry, null, null)); //(p) => g.Rect.Width = p.X));
list.Add(new PathPoint(g.Rect.BottomLeft, geometry, null, null)); //(p) => g.Rect.Top = p.Y));
list.Add(new PathPoint(g.Rect.BottomRight, geometry, null, null)); //(p) => g.Rect.Height = p.Y));
} else if (geometry is EllipseGeometry) {
var g = geometry as EllipseGeometry;
list.Add(new PathPoint(g.Center, geometry, (p) => g.Center = p));
list.Add(new PathPoint(g.Center, geometry, null, (p) => g.Center = p));
} else if (geometry is LineGeometry) {
var g = geometry as LineGeometry;
list.Add(new PathPoint(g.StartPoint, geometry, (p) => g.StartPoint = p));
list.Add(new PathPoint(g.EndPoint, geometry, (p) => g.EndPoint = p));
}
}
public class PathPoint {
public PathPoint(Point point, Object @object, Action<Point> setLambda)
{
this._point = point;
this._setLambda = setLambda;
this.Object = @object;
list.Add(new PathPoint(g.StartPoint, geometry, null, (p) => g.StartPoint = p));
list.Add(new PathPoint(g.EndPoint, geometry, null, (p) => g.EndPoint = p));
}
private Point _point;
Action<Point> _setLambda;
public Point Point {
get{return _point;}
set{_setLambda(value);}
}
public Point ReferencePoint {get; private set;}
public object Object {get; private set;}
}
List<PathPoint> MovePoints(List<PathPoint> pc, double displacementX, double displacementY, double theta, int? snapangle)

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs

@ -71,10 +71,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -71,10 +71,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
} else if (shape is Polyline) {
var pg = shape as Polyline;
p = pg.Points[Index];
} else if (shape is Path) {
var path = shape as Path;
var points = PathHandlerExtension.GetPoints(path);
p = points[Index].Point;
}
var transform = shape.RenderedGeometry.Transform;
@ -82,7 +78,5 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -82,7 +78,5 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
adorner.Arrange(new Rect(p.X - thumbsize / 2, p.Y - thumbsize / 2, thumbsize, thumbsize)); //thumbsize, thumbsize)));
}
}
}

42
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs

@ -47,36 +47,36 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -47,36 +47,36 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
ZoomControl _zoom;
#region thumb methods
protected ResizeThumb CreateThumb(PlacementAlignment alignment, Cursor cursor, int index)
protected DesignerThumb CreateThumb(PlacementAlignment alignment, Cursor cursor, int index)
{
ResizeThumb resizeThumb = new MultiPointResizeThumb { Index = index, Alignment = alignment, Cursor = cursor, IsPrimarySelection = true };
AdornerPlacement ap = Place(ref resizeThumb, alignment, index);
(resizeThumb as MultiPointResizeThumb).AdornerPlacement = ap;
DesignerThumb designerThumb = new MultiPointThumb { Index = index, Alignment = alignment, Cursor = cursor, IsPrimarySelection = true };
AdornerPlacement ap = Place(ref designerThumb, alignment, index);
(designerThumb as MultiPointThumb).AdornerPlacement = ap;
AdornerPanel.SetPlacement(resizeThumb, ap);
adornerPanel.Children.Add(resizeThumb);
AdornerPanel.SetPlacement(designerThumb, ap);
adornerPanel.Children.Add(designerThumb);
DragListener drag = new DragListener(resizeThumb);
DragListener drag = new DragListener(designerThumb);
WeakEventManager<ResizeThumb, MouseButtonEventArgs>.AddHandler(resizeThumb, "PreviewMouseLeftButtonDown", ResizeThumbOnMouseLeftButtonUp);
WeakEventManager<DesignerThumb, MouseButtonEventArgs>.AddHandler(designerThumb, "PreviewMouseLeftButtonDown", ResizeThumbOnMouseLeftButtonUp);
drag.Started += drag_Started;
drag.Changed += drag_Changed;
drag.Completed += drag_Completed;
return resizeThumb;
return designerThumb;
}
private void ResetThumbs()
{
foreach (FrameworkElement rt in adornerPanel.Children)
{
if (rt is ResizeThumb)
(rt as ResizeThumb).IsPrimarySelection = true;
if (rt is DesignerThumb)
(rt as DesignerThumb).IsPrimarySelection = true;
}
_selectedThumbs.Clear();
}
private void SelectThumb(MultiPointResizeThumb mprt)
private void SelectThumb(MultiPointThumb mprt)
{
PointCollection points = GetPointCollection();
Point p = points[mprt.Index];
@ -92,7 +92,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -92,7 +92,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
private void ResizeThumbOnMouseLeftButtonUp(object sender, MouseButtonEventArgs mouseButtonEventArgs)
{
//get current thumb
MultiPointResizeThumb mprt = sender as MultiPointResizeThumb;
MultiPointThumb mprt = sender as MultiPointThumb;
if (mprt != null)
{
//shift+ctrl will remove selected point
@ -104,7 +104,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -104,7 +104,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
PointCollection points = GetPointCollection();
//iterate thumbs to lower index of remaining thumbs
foreach (MultiPointResizeThumb m in adornerPanel.Children)
foreach (MultiPointThumb m in adornerPanel.Children)
{
if (m.Index > mprt.Index)
m.Index--;
@ -136,7 +136,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -136,7 +136,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
protected void drag_Started(DragListener drag)
{
//get current thumb
MultiPointResizeThumb mprt = (drag.Target as MultiPointResizeThumb);
MultiPointThumb mprt = (drag.Target as MultiPointThumb);
if (mprt != null)
{
SetOperation();
@ -199,7 +199,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -199,7 +199,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
PointCollection points = GetPointCollection();
MultiPointResizeThumb mprt = drag.Target as MultiPointResizeThumb;
MultiPointThumb mprt = drag.Target as MultiPointThumb;
if (mprt != null)
{
double dx = 0;
@ -243,9 +243,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -243,9 +243,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
//set index of all points that had a higher index than selected to +1
foreach (FrameworkElement rt in adornerPanel.Children)
{
if (rt is MultiPointResizeThumb)
if (rt is MultiPointThumb)
{
MultiPointResizeThumb t = rt as MultiPointResizeThumb;
MultiPointThumb t = rt as MultiPointThumb;
if (t.Index > mprt.Index)
t.Index++;
}
@ -275,12 +275,12 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -275,12 +275,12 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
(drag.Target as ResizeThumb).InvalidateArrange();
(drag.Target as DesignerThumb).InvalidateArrange();
}
protected void drag_Completed(DragListener drag)
{
MultiPointResizeThumb mprt = drag.Target as MultiPointResizeThumb;
MultiPointThumb mprt = drag.Target as MultiPointThumb;
if (mprt != null)
{
if (operation != null && drag.IsCanceled)
@ -303,7 +303,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -303,7 +303,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
PointCollection points = GetPointCollection();
resizeThumbs = new List<ResizeThumb>();
resizeThumbs = new List<DesignerThumb>();
for (int i = 0; i < points.Count; i++)
{
CreateThumb(PlacementAlignment.BottomRight, Cursors.Cross, i);

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

@ -38,7 +38,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -38,7 +38,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public sealed class ResizeThumbExtension : SelectionAdornerProvider
{
readonly AdornerPanel adornerPanel;
readonly ResizeThumb[] resizeThumbs;
readonly DesignerThumb[] _designerThumbs;
/// <summary>An array containing this.ExtendedItem as only element</summary>
readonly DesignItem[] extendedItemArray = new DesignItem[1];
IPlacementBehavior resizeBehavior;
@ -60,7 +60,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -60,7 +60,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
adornerPanel.Order = AdornerOrder.Foreground;
this.Adorners.Add(adornerPanel);
resizeThumbs = new ResizeThumb[] {
_designerThumbs = new DesignerThumb[] {
CreateThumb(PlacementAlignment.TopLeft, Cursors.SizeNWSE),
CreateThumb(PlacementAlignment.Top, Cursors.SizeNS),
CreateThumb(PlacementAlignment.TopRight, Cursors.SizeNESW),
@ -72,29 +72,29 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -72,29 +72,29 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
};
}
ResizeThumb CreateThumb(PlacementAlignment alignment, Cursor cursor)
DesignerThumb CreateThumb(PlacementAlignment alignment, Cursor cursor)
{
ResizeThumb resizeThumb = new ResizeThumbImpl( cursor == Cursors.SizeNS, cursor == Cursors.SizeWE );
resizeThumb.Cursor = cursor;
resizeThumb.Alignment = alignment;
AdornerPanel.SetPlacement(resizeThumb, Place(ref resizeThumb, alignment));
adornerPanel.Children.Add(resizeThumb);
DesignerThumb designerThumb = new ResizeThumb( cursor == Cursors.SizeNS, cursor == Cursors.SizeWE );
designerThumb.Cursor = cursor;
designerThumb.Alignment = alignment;
AdornerPanel.SetPlacement(designerThumb, Place(ref designerThumb, alignment));
adornerPanel.Children.Add(designerThumb);
DragListener drag = new DragListener(resizeThumb);
DragListener drag = new DragListener(designerThumb);
drag.Started += new DragHandler(drag_Started);
drag.Changed += new DragHandler(drag_Changed);
drag.Completed += new DragHandler(drag_Completed);
return resizeThumb;
return designerThumb;
}
/// <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="designerThumb"></param>
/// <param name="alignment"></param>
/// <returns></returns>
private RelativePlacement Place(ref ResizeThumb resizeThumb,PlacementAlignment alignment)
private RelativePlacement Place(ref DesignerThumb designerThumb,PlacementAlignment alignment)
{
RelativePlacement placement = new RelativePlacement(alignment.Horizontal,alignment.Vertical);
@ -102,14 +102,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -102,14 +102,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
placement.WidthRelativeToContentWidth = 1;
placement.HeightOffset = 6;
resizeThumb.Opacity = 0;
designerThumb.Opacity = 0;
return placement;
}
if (alignment.Vertical == VerticalAlignment.Center)
{
placement.HeightRelativeToContentHeight = 1;
placement.WidthOffset = 6;
resizeThumb.Opacity = 0;
designerThumb.Opacity = 0;
return placement;
}
@ -148,7 +148,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -148,7 +148,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
double dx = 0;
double dy = 0;
var alignment = (drag.Target as ResizeThumb).Alignment;
var alignment = (drag.Target as DesignerThumb).Alignment;
var delta = drag.Delta;
@ -259,7 +259,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -259,7 +259,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
void OnPrimarySelectionChanged(object sender, EventArgs e)
{
bool isPrimarySelection = this.Services.Selection.PrimarySelection == this.ExtendedItem;
foreach (ResizeThumb g in adornerPanel.Children) {
foreach (DesignerThumb g in adornerPanel.Children) {
g.IsPrimarySelection = isPrimarySelection;
}
}
@ -267,7 +267,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -267,7 +267,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
void UpdateAdornerVisibility()
{
FrameworkElement fe = this.ExtendedItem.View as FrameworkElement;
foreach (ResizeThumb r in resizeThumbs) {
foreach (DesignerThumb r in _designerThumbs) {
bool isVisible = resizeBehavior != null && resizeBehavior.CanPlace(extendedItemArray, PlacementType.Resize, r.Alignment);
r.Visibility = isVisible ? Visibility.Visible : Visibility.Hidden;
}

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RotateThumbExtension.cs

@ -52,9 +52,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -52,9 +52,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
thumb = CreateRotateThumb();
}
ResizeThumb CreateRotateThumb()
DesignerThumb CreateRotateThumb()
{
ResizeThumb rotateThumb = new RotateThumb();
DesignerThumb rotateThumb = new RotateThumb();
rotateThumb.Cursor = Cursors.Hand;
rotateThumb.Cursor = ZoomControl.GetCursor("Images/rotate.cur");
rotateThumb.Alignment = PlacementAlignment.Top;

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

@ -85,6 +85,8 @@ @@ -85,6 +85,8 @@
</Compile>
<Compile Include="ArrangeDirection.cs" />
<Compile Include="Controls\RenderTransformOriginThumb.cs" />
<Compile Include="Controls\Thumbs\PointThumb.cs" />
<Compile Include="Controls\Thumbs\ResizeThumb.cs" />
<Compile Include="Extensions\BorderForImageControl.cs" />
<Compile Include="Extensions\DrawLineExtension.cs" />
<Compile Include="Extensions\DrawPathExtension.cs" />
@ -96,7 +98,7 @@ @@ -96,7 +98,7 @@
<Compile Include="Extensions\DefaultCommandsContextMenuExtension.cs" />
<Compile Include="Extensions\LineExtensionBase.cs" />
<Compile Include="Extensions\LineHandlerExtension.cs" />
<Compile Include="Extensions\MultiPointResizeThumb.cs" />
<Compile Include="Controls\Thumbs\MultiPointThumb.cs" />
<Compile Include="Extensions\PartialPanelSelectionHandler.cs" />
<Compile Include="Extensions\EditStyleContextMenu.xaml.cs">
<DependentUpon>EditStyleContextMenu.xaml</DependentUpon>
@ -179,10 +181,10 @@ @@ -179,10 +181,10 @@
<Compile Include="Controls\PageClone.cs" />
<Compile Include="Controls\PanelMoveAdorner.cs" />
<Compile Include="Controls\QuickOperationMenu.cs" />
<Compile Include="Controls\RotateThumb.cs" />
<Compile Include="Controls\Thumbs\RotateThumb.cs" />
<Compile Include="Controls\SelectionFrame.cs" />
<Compile Include="Controls\ErrorBalloon.cs" />
<Compile Include="Controls\ResizeThumb.cs" />
<Compile Include="Controls\Thumbs\DesignerThumb.cs" />
<Compile Include="CallExtension.cs" />
<Compile Include="Controls\DragListener.cs" />
<Compile Include="Controls\SizeDisplay.cs" />

Loading…
Cancel
Save