Browse Source

PolyLine/gon Handler fixes, Path Handler worked on

pull/637/head
jkuehner 11 years ago
parent
commit
1a6cdeca93
  1. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DragListener.cs
  2. 33
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs
  3. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs
  4. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs
  5. 14
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DragListener.cs

@ -81,6 +81,8 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -81,6 +81,8 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
DeltaDelta = new Vector();
IsDown = true;
IsCanceled = false;
if (MouseDown != null)
MouseDown(this);
}
void Target_MouseMove(object sender, MouseEventArgs e)
@ -125,6 +127,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -125,6 +127,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
}
}
public event DragHandler MouseDown;
public event DragHandler Started;
public event DragHandler Changed;
public event DragHandler Completed;

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

@ -59,6 +59,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -59,6 +59,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
WeakEventManager<ResizeThumb, MouseButtonEventArgs>.AddHandler(resizeThumb, "PreviewMouseLeftButtonDown", ResizeThumbOnMouseLeftButtonUp);
drag.MouseDown += drag_MouseDown;
drag.Started += drag_Started;
drag.Changed += drag_Changed;
drag.Completed += drag_Completed;
@ -131,6 +132,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -131,6 +132,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
}
protected void drag_MouseDown(DragListener drag)
{
}
// TODO : Remove all hide/show extensions from here.
protected void drag_Started(DragListener drag)
{
@ -222,12 +228,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -222,12 +228,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
Double theta;
//if one point selected snapping angle is calculated in relation to previous point
if (_selectedThumbs.Count == 1)
{
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);
}
else//if multiple points snapping angle is calculated in relation to mouse dragging angle
{
} else { //if multiple points snapping angle is calculated in relation to mouse dragging angle
theta = (180 / Math.PI) * Math.Atan2(dy, dx);
}
@ -316,7 +319,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -316,7 +319,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var points = GetPoints();
resizeThumbs = new List<ResizeThumb>();
for (int i = 1; i < points.Count; i++)
for (int i = 0; i < points.Count; i++)
{
CreateThumb(PlacementAlignment.BottomRight, Cursors.Cross, i);
}
@ -347,17 +350,23 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -347,17 +350,23 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
if (geometry!=null) {
var figure = geometry.Figures[0] as PathFigure;
if (figure != null) {
retVal.Add(figure.StartPoint);
foreach (var s in figure.Segments) {
if (s is LineSegment)
retVal.Add(((LineSegment)s).Point);
else if (s is PolyLineSegment)
retVal.AddRange(((PolyLineSegment)s).Points);
// else if (s is BezierSegment)
// retVal.Add(((BezierSegment)s).Point3);
// else if (s is QuadraticBezierSegment)
// retVal.Add(((QuadraticBezierSegment)s).Point2);
// else if (s is ArcSegment)
// retVal.Add(((ArcSegment)s).Point);
else if (s is BezierSegment) {
retVal.Add(((BezierSegment)s).Point1);
retVal.Add(((BezierSegment)s).Point2);
retVal.Add(((BezierSegment)s).Point3);
}
else if (s is QuadraticBezierSegment) {
retVal.Add(((QuadraticBezierSegment)s).Point1);
retVal.Add(((QuadraticBezierSegment)s).Point2);
}
else if (s is ArcSegment)
retVal.Add(((ArcSegment)s).Point);
}
}
}

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

@ -72,13 +72,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -72,13 +72,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var pg = shape as Polyline;
p = pg.Points[Index];
} else if (shape is Path) {
if (Index > 0)
{
var path = shape as Path;
var points = PathHandlerExtension.GetPoints(path);
p = points[Index];
}
}
var transform = shape.RenderedGeometry.Transform;
p = transform.Transform(p);

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

@ -213,12 +213,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -213,12 +213,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
Double theta;
//if one point selected snapping angle is calculated in relation to previous point
if (_selectedThumbs.Count == 1)
{
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);
}
else//if multiple points snapping angle is calculated in relation to mouse dragging angle
{
} else { //if multiple points snapping angle is calculated in relation to mouse dragging angle
theta = (180 / Math.PI) * Math.Atan2(dy, dx);
}
@ -307,7 +304,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -307,7 +304,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
PointCollection points = GetPointCollection();
resizeThumbs = new List<ResizeThumb>();
for (int i = 1; i < points.Count; i++)
for (int i = 0; i < points.Count; i++)
{
CreateThumb(PlacementAlignment.BottomRight, Cursors.Cross, i);
}

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

@ -150,10 +150,16 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -150,10 +150,16 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
double dy = 0;
var alignment = (drag.Target as ResizeThumb).Alignment;
if (alignment.Horizontal == HorizontalAlignment.Left) dx = -drag.Delta.X;
if (alignment.Horizontal == HorizontalAlignment.Right) dx = drag.Delta.X;
if (alignment.Vertical == VerticalAlignment.Top) dy = -drag.Delta.Y;
if (alignment.Vertical == VerticalAlignment.Bottom) dy = drag.Delta.Y;
var delta = drag.Delta;
var transform = this.ExtendedItem.View.RenderTransform;
if (transform != null)
delta = (Vector)transform.Inverse.Transform((Point)delta);
if (alignment.Horizontal == HorizontalAlignment.Left) dx = -delta.X;
if (alignment.Horizontal == HorizontalAlignment.Right) dx = delta.X;
if (alignment.Vertical == VerticalAlignment.Top) dy = -delta.Y;
if (alignment.Vertical == VerticalAlignment.Bottom) dy = delta.Y;
var designPanel = ExtendedItem.Services.DesignPanel as DesignPanel;

Loading…
Cancel
Save