public object Clone() { DDNode ret = new DDNode(); CloneTo(ret); return(ret); }
protected virtual void CloneTo(DDNode target) { if (this.Point != null) { target.Point = new DDPoint(this.Point); } else { target.Point = null; } if (this.Point != null) { target.Control1 = new DDPoint(this.Control1); } else { target.Control1 = null; } if (this.Control2 != null) { target.Control2 = new DDPoint(this.Control2); } else { target.Control2 = null; } target.IsStroked = IsStroked; target.Control1ManuallySet = Control1ManuallySet; target.Control2ManuallySet = Control2ManuallySet; }
private static void AnyPropertyChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs args) { DDNode p = (sender as DDNode); p.OnNodeChanged(); p.OnPropertyChanged(args.Property.Name); }
protected override void CloneTo(DDNode target) { base.CloneTo(target); if (target is DDNodeWithHandles) { DDNodeWithHandles localTarget = target as DDNodeWithHandles; localTarget.ShowPointHandle = ShowPointHandle; localTarget.ShowControlHandles = ShowControlHandles; } }
void ParentObjectOtherNodesChanged(object sender, EventArgs e) { _nodeBefore = null; _nodeAfter = null; }
public override bool SetFromCLR(Shape source) { if (!base.SetFromCLR(source)) { return(false); } if (!(source is Path)) { return(false); } Path path = source as Path; if (!(path.Data is PathGeometry)) { return(false); } PathGeometry g = path.Data as PathGeometry; if (g.Figures.Count == 0) { return(false); } IsFilled = g.Figures[0].IsFilled; Vector offset = new Vector(X, Y); List <BezierSegment> segmentList = new List <BezierSegment>(); for (int i = 0; i < g.Figures[0].Segments.Count; i++) { if (g.Figures[0].Segments[i] is BezierSegment) { BezierSegment seg = (g.Figures[0].Segments[i] as BezierSegment).Clone(); seg.Point1 += offset; seg.Point2 += offset; seg.Point3 += offset; segmentList.Add(seg); } else if (g.Figures[0].Segments[i] is PolyBezierSegment) { PolyBezierSegment pbs = g.Figures[0].Segments[i] as PolyBezierSegment; for (int j = 2; j < pbs.Points.Count; j += 3) { segmentList.Add(new BezierSegment( pbs.Points[j - 2] + offset, pbs.Points[j - 1] + offset, pbs.Points[j] + offset, pbs.IsStroked)); } } } DDNode nodeBefore = null; Point? savedFirstControl = null; foreach (BezierSegment segment in segmentList) { DDNodeWithHandles node = new DDNodeWithHandles(); node.Point = new DDPoint(segment.Point3); if (segment.Point2 != segment.Point3) { node.Control1 = new DDPoint(segment.Point2); } else { node.Control1 = null; } if (nodeBefore != null) { if ((nodeBefore.Point != null) && (segment.Point1 != nodeBefore.Point.Point)) { nodeBefore.Control2 = new DDPoint(segment.Point1); } else { nodeBefore.Control2 = null; } } else { savedFirstControl = segment.Point1; } node.IsCurved = true; node.IsStroked = segment.IsStroked; nodeBefore = node; Nodes.Add(node); } if ((Nodes.Last != null) && (savedFirstControl.HasValue)) { if (savedFirstControl.Value != Nodes.Last.Point) { Nodes.Last.Control2 = new DDPoint(savedFirstControl.Value); } else { Nodes.Last.Control2 = null; } } this.ClearValue(FrameworkElement.WidthProperty); this.ClearValue(FrameworkElement.HeightProperty); return(true); }