diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineExtensionBase.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineExtensionBase.cs
index eef5e6a063..623bf53f2b 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineExtensionBase.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineExtensionBase.cs
@@ -25,19 +25,11 @@ using ICSharpCode.WpfDesign;
using ICSharpCode.WpfDesign.Adorners;
using System.Windows;
using System.Windows.Controls;
-using System;
using System.Collections;
using System.ComponentModel;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
- ///
- /// Description of LineExtensionBase.
- ///
- class Bounds
- {
- public double X, Y, Left, Top;
- }
///
/// base class for the Line, Polyline and Polygon extension classes
///
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs
index 374c838ccf..161b9a3236 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs
@@ -32,8 +32,16 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// Description of LineHandlerExtension.
///
[ExtensionFor(typeof(Line), OverrideExtensions = new Type[] { typeof(ResizeThumbExtension), typeof(SelectedElementRectangleExtension), typeof(CanvasPositionExtension), typeof(QuickOperationMenuExtension), typeof(RotateThumbExtension), typeof(RenderTransformOriginExtension), typeof(InPlaceEditorExtension), typeof(SkewThumbExtension) })]
- internal class LineHandlerExtension : LineExtensionBase
+ public class LineHandlerExtension : LineExtensionBase
{
+ ///
+ /// Used instead of Rect to allow negative values on "Width" and "Height" (here called X and Y).
+ ///
+ class Bounds
+ {
+ public double X, Y, Left, Top;
+ }
+
//
private double CurrentX2;
private double CurrentY2;
@@ -60,7 +68,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
return designerThumb;
}
- protected Bounds CalculateDrawing(double x, double y, double left, double top, double xleft, double xtop)
+ Bounds CalculateDrawing(double x, double y, double left, double top, double xleft, double xtop)
{
Double theta = (180 / Math.PI) * Math.Atan2(y, x);
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs
index 5a24f6fb0f..3f32664c57 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs
@@ -41,7 +41,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// Description of PathHandlerExtension.
///
[ExtensionFor(typeof(Path))]
- internal class PathHandlerExtension : LineExtensionBase, IKeyDown, IKeyUp
+ public class PathHandlerExtension : LineExtensionBase, IKeyDown, IKeyUp
{
enum PathPartConvertType
{
@@ -159,7 +159,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
}
- private readonly Dictionary _selectedThumbs = new Dictionary();
+ private readonly Dictionary _selectedPoints = new Dictionary();
#pragma warning disable 0414 // For future use, disable Warning CS0414: The field is assigned but its value is never used
private bool _isDragging;
#pragma warning restore 0414
@@ -331,7 +331,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
if (rt is DesignerThumb)
(rt as DesignerThumb).IsPrimarySelection = true;
}
- _selectedThumbs.Clear();
+ _selectedPoints.Clear();
}
private void SelectThumb(PathThumb mprt)
@@ -340,7 +340,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var points = GetPoints();
Point p = points[mprt.Index].TranslatedPoint;
- _selectedThumbs.Add(mprt.Index, new Bounds { X = p.X, Y = p.Y });
+ _selectedPoints.Add(mprt.Index, p);
mprt.IsPrimarySelection = false;
}
@@ -356,13 +356,13 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
if (mprt != null)
{
//if not keyboard ctrl is pressed and selected point is not previously selected, clear selection
- if (!_selectedThumbs.ContainsKey(mprt.Index) & !Keyboard.IsKeyDown(Key.LeftCtrl) &
+ if (!_selectedPoints.ContainsKey(mprt.Index) & !Keyboard.IsKeyDown(Key.LeftCtrl) &
!Keyboard.IsKeyDown(Key.RightCtrl))
{
ResetThumbs();
}
//add selected thumb, if ctrl pressed this could be all points in poly
- if (!_selectedThumbs.ContainsKey(mprt.Index))
+ if (!_selectedPoints.ContainsKey(mprt.Index))
SelectThumb(mprt);
_isDragging = false;
@@ -423,7 +423,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
if (operation != null)
{
- foreach (int i in _selectedThumbs.Keys)
+ foreach (int i in _selectedPoints.Keys)
{
pathPoints[i].Commit();
}
@@ -728,12 +728,12 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var relativeTo = new Vector(operation.PlacedItems[0].Bounds.TopLeft.X, operation.PlacedItems[0].Bounds.TopLeft.Y);
//iterate all selected points
- foreach (int i in _selectedThumbs.Keys) {
+ foreach (int i in _selectedPoints.Keys) {
Point p = pathPoints[i].TranslatedPoint;
//x and y is calculated from the currentl point
- double x = _selectedThumbs[i].X + displacementX;
- double y = _selectedThumbs[i].Y + displacementY;
+ double x = _selectedPoints[i].X + displacementX;
+ double y = _selectedPoints[i].Y + displacementY;
p.X = x;
p.Y = y;
@@ -749,14 +749,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public bool InvokeDefaultAction
{
- get { return _selectedThumbs.Count == 0 || _selectedThumbs.Count == pathPoints.Count - 1; }
+ get { return _selectedPoints.Count == 0 || _selectedPoints.Count == pathPoints.Count - 1; }
}
int _movingDistanceX;
int _movingDistanceY;
public void KeyDownAction(object sender, KeyEventArgs e)
{
- if (_selectedThumbs.Count > 0) {
+ if (_selectedPoints.Count > 0) {
if (IsArrowKey(e.Key)) {
if (operation == null) {
SetOperation();
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs
index e4e4323273..0a8bd1ccdd 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs
@@ -27,7 +27,6 @@ using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows;
using System.Windows.Controls;
-using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@@ -40,9 +39,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
///
[ExtensionFor(typeof(Polyline))]
[ExtensionFor(typeof(Polygon))]
- internal class PolyLineHandlerExtension : LineExtensionBase, IKeyDown, IKeyUp
+ public class PolyLineHandlerExtension : LineExtensionBase, IKeyDown, IKeyUp
{
- private readonly Dictionary _selectedThumbs = new Dictionary();
+ private readonly Dictionary _selectedPoints = new Dictionary();
private bool _isDragging;
ZoomControl _zoom;
@@ -73,14 +72,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
if (rt is DesignerThumb)
(rt as DesignerThumb).IsPrimarySelection = true;
}
- _selectedThumbs.Clear();
+ _selectedPoints.Clear();
}
private void SelectThumb(MultiPointThumb mprt)
{
PointCollection points = GetPointCollection();
Point p = points[mprt.Index];
- _selectedThumbs.Add(mprt.Index, new Bounds { X = p.X, Y = p.Y });
+ _selectedPoints.Add(mprt.Index, p);
mprt.IsPrimarySelection = false;
}
@@ -119,13 +118,13 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
else
{
//if not keyboard ctrl is pressed and selected point is not previously selected, clear selection
- if (!_selectedThumbs.ContainsKey(mprt.Index) & !Keyboard.IsKeyDown(Key.LeftCtrl) &
+ if (!_selectedPoints.ContainsKey(mprt.Index) & !Keyboard.IsKeyDown(Key.LeftCtrl) &
!Keyboard.IsKeyDown(Key.RightCtrl))
{
ResetThumbs();
}
//add selected thumb, if ctrl pressed this could be all points in poly
- if (!_selectedThumbs.ContainsKey(mprt.Index))
+ if (!_selectedPoints.ContainsKey(mprt.Index))
SelectThumb(mprt);
_isDragging = false;
}
@@ -174,10 +173,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
points = pl.Points;
}
- foreach (int i in _selectedThumbs.Keys)
+ foreach (int i in _selectedPoints.Keys.ToList())
{
- _selectedThumbs[i].X = points[i].X;
- _selectedThumbs[i].Y = points[i].Y;
+ _selectedPoints[i] = points[i];
}
ExtendedItem.Properties.GetProperty(pl != null ? Polyline.PointsProperty : Polygon.PointsProperty).SetValue(points);
operation.Commit();
@@ -213,8 +211,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
Double theta;
//if one point selected snapping angle is calculated in relation to previous point
- if (_selectedThumbs.Count == 1 && mprt.Index > 0) {
- theta = (180 / Math.PI) * Math.Atan2(_selectedThumbs[mprt.Index].Y + dy - points[mprt.Index - 1].Y, _selectedThumbs[mprt.Index].X + dx - points[mprt.Index - 1].X);
+ if (_selectedPoints.Count == 1 && mprt.Index > 0) {
+ theta = (180 / Math.PI) * Math.Atan2(_selectedPoints[mprt.Index].Y + dy - points[mprt.Index - 1].Y, _selectedPoints[mprt.Index].X + dx - points[mprt.Index - 1].X);
} else { //if multiple points snapping angle is calculated in relation to mouse dragging angle
theta = (180 / Math.PI) * Math.Atan2(dy, dx);
}
@@ -228,7 +226,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
//if dragging occurs on a point and that point is the only selected, a new node will be added.
//_isCtrlDragging is needed since this method is called for every x pixel that the mouse moves
//so it could be many thousands of times during a single dragging
- if (!_isDragging && _selectedThumbs.Count == 1 && (Math.Abs(dx) > 0 || Math.Abs(dy) > 0))
+ if (!_isDragging && _selectedPoints.Count == 1 && (Math.Abs(dx) > 0 || Math.Abs(dy) > 0))
{
//duplicate point that is selected
@@ -333,29 +331,29 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
PointCollection MovePoints(PointCollection pc, double displacementX, double displacementY, double theta, int? snapangle)
{
//iterate all selected points
- foreach (int i in _selectedThumbs.Keys)
+ foreach (int i in _selectedPoints.Keys)
{
Point p = pc[i];
//x and y is calculated from the currentl point
- double x = _selectedThumbs[i].X + displacementX;
- double y = _selectedThumbs[i].Y + displacementY;
+ double x = _selectedPoints[i].X + displacementX;
+ double y = _selectedPoints[i].Y + displacementY;
//if snap is applied
if (snapangle != null)
{
- if (_selectedThumbs.Count > 0)
+ if (_selectedPoints.Count > 0)
{
//horizontal snap
if (Math.Abs(theta) < snapangle || 180 - Math.Abs(theta) < snapangle)
{
//if one point selected use point before as snap point, else snap to movement
- y = _selectedThumbs.Count == 1 ? pc[i - 1].Y : y - displacementY;
+ y = _selectedPoints.Count == 1 ? pc[i - 1].Y : y - displacementY;
}
else if (Math.Abs(90 - Math.Abs(theta)) < snapangle)//vertical snap
{
//if one point selected use point before as snap point, else snap to movement
- x = _selectedThumbs.Count == 1 ? pc[i - 1].X : x - displacementX;
+ x = _selectedPoints.Count == 1 ? pc[i - 1].X : x - displacementX;
}
}
}
@@ -371,7 +369,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public bool InvokeDefaultAction
{
- get { return _selectedThumbs.Count == 0 || _selectedThumbs.Count == GetPointCollection().Count - 1; }
+ get { return _selectedPoints.Count == 0 || _selectedPoints.Count == GetPointCollection().Count - 1; }
}
int _movingDistance;