Browse Source

Draw Path when Transformed

pull/633/head
jogibear9988 11 years ago
parent
commit
79e726fb05
  1. 15
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DrawPathExtension.cs
  2. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs

15
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DrawPathExtension.cs

@ -76,7 +76,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
//geometryDesignItem.Properties[PathGeometry.FiguresProperty].CollectionElements.Add(figureDesignItem); //geometryDesignItem.Properties[PathGeometry.FiguresProperty].CollectionElements.Add(figureDesignItem);
figureDesignItem.Properties[PathFigure.StartPointProperty].SetValue(new Point(0,0)); figureDesignItem.Properties[PathFigure.StartPointProperty].SetValue(new Point(0,0));
new DrawPathMouseGesture(figure, createdItem, clickedOn.View, changeGroup).Start(panel, (MouseButtonEventArgs) e); new DrawPathMouseGesture(figure, createdItem, clickedOn.View, changeGroup, this.ExtendedItem.GetCompleteAppliedTransformationToView()).Start(panel, (MouseButtonEventArgs) e);
} }
#endregion #endregion
@ -88,13 +88,16 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
private Point sP; private Point sP;
private PathFigure figure; private PathFigure figure;
private DesignItem geometry; private DesignItem geometry;
private Matrix matrix;
public DrawPathMouseGesture(PathFigure figure, DesignItem newLine, IInputElement relativeTo, ChangeGroup changeGroup) public DrawPathMouseGesture(PathFigure figure, DesignItem newLine, IInputElement relativeTo, ChangeGroup changeGroup, Transform transform)
{ {
this.newLine = newLine; this.newLine = newLine;
this.positionRelativeTo = relativeTo; this.positionRelativeTo = relativeTo;
this.changeGroup = changeGroup; this.changeGroup = changeGroup;
this.figure = figure; this.figure = figure;
this.matrix = transform.Value;
matrix.Invert();
sP = Mouse.GetPosition(null); sP = Mouse.GetPosition(null);
@ -109,8 +112,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
protected override void OnMouseMove(object sender, MouseEventArgs e) protected override void OnMouseMove(object sender, MouseEventArgs e)
{ {
var delta = e.GetPosition(null) - sP; var delta = matrix.Transform(e.GetPosition(null) - sP);
var point = new Point(delta.X, delta.Y); var point = new Point(Math.Round(delta.X, 0), Math.Round(delta.Y, 0));
var segment = figure.Segments.LastOrDefault() as LineSegment; var segment = figure.Segments.LastOrDefault() as LineSegment;
if (Mouse.LeftButton == MouseButtonState.Pressed) if (Mouse.LeftButton == MouseButtonState.Pressed)
@ -128,8 +131,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
protected override void OnMouseUp(object sender, MouseButtonEventArgs e) protected override void OnMouseUp(object sender, MouseButtonEventArgs e)
{ {
var delta = e.GetPosition(null) - sP; var delta = matrix.Transform(e.GetPosition(null) - sP);
var point = new Point(delta.X, delta.Y); var point = new Point(Math.Round(delta.X, 0), Math.Round(delta.Y,0));
figure.Segments.Add(new LineSegment(point, false)); figure.Segments.Add(new LineSegment(point, false));
geometry.Properties[PathGeometry.FiguresProperty].SetValue(figure.ToString()); geometry.Properties[PathGeometry.FiguresProperty].SetValue(figure.ToString());

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

@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Windows;
using ICSharpCode.WpfDesign.Extensions; using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls; using ICSharpCode.WpfDesign.Designer.Controls;
@ -173,6 +174,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
info.Bounds = result.Round(); info.Bounds = result.Round();
operation.CurrentContainerBehavior.BeforeSetPosition(operation); operation.CurrentContainerBehavior.BeforeSetPosition(operation);
operation.CurrentContainerBehavior.SetPosition(info); operation.CurrentContainerBehavior.SetPosition(info);
// var p = operation.CurrentContainerBehavior.PlacePoint(new Point(position.X, position.Y));
// ExtendedItem.Properties.GetProperty(Line.X2Property).SetValue(p.X);
// ExtendedItem.Properties.GetProperty(Line.Y2Property).SetValue(p.Y);
} }
(drag.Target as DesignerThumb).InvalidateArrange(); (drag.Target as DesignerThumb).InvalidateArrange();

Loading…
Cancel
Save