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

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

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

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

@ -213,12 +213,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
Double theta; Double theta;
//if one point selected snapping angle is calculated in relation to previous point //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); 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); theta = (180 / Math.PI) * Math.Atan2(dy, dx);
} }
@ -307,7 +304,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
PointCollection points = GetPointCollection(); PointCollection points = GetPointCollection();
resizeThumbs = new List<ResizeThumb>(); 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); 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
double dy = 0; double dy = 0;
var alignment = (drag.Target as ResizeThumb).Alignment; var alignment = (drag.Target as ResizeThumb).Alignment;
if (alignment.Horizontal == HorizontalAlignment.Left) dx = -drag.Delta.X; var delta = drag.Delta;
if (alignment.Horizontal == HorizontalAlignment.Right) dx = drag.Delta.X;
if (alignment.Vertical == VerticalAlignment.Top) dy = -drag.Delta.Y; var transform = this.ExtendedItem.View.RenderTransform;
if (alignment.Vertical == VerticalAlignment.Bottom) dy = drag.Delta.Y; 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; var designPanel = ExtendedItem.Services.DesignPanel as DesignPanel;

Loading…
Cancel
Save