private ControlPoint CreateControlPoints(bool editMode, out ControlPoint lastEndPoint, PathSegment psRet) { ControlPoint cpRet = null; lastEndPoint = null; if (editMode) { ControlPoint lastCP = null; ControlPoint bezierTmpCP = null; PathGeom.DoForAllPointDPs(new DependencyPropertyCallback((DependencyObject obj, DependencyProperty dp) => { var cp = new ControlPoint(Drawing, this, obj, dp, 0, true, true); cp.Tag = obj; Drawing.AddControlPoint(cp); if (dp.OwnerType == typeof(BezierSegment)) { if (dp.Name == "Point1") // control point 1 { lastCP.SubPoint = cp; cp.ConnectedTo = lastCP; cp.IsSelectable = false; } else if (dp.Name == "Point2") // control point 2 { cp.IsSelectable = false; bezierTmpCP = cp; } else if (dp.Name == "Point3") // end point { cp.SubPoint = bezierTmpCP; bezierTmpCP.ConnectedTo = cp; lastCP = cp; } } else if (dp.OwnerType == typeof(QuadraticBezierSegment)) { if (dp.Name == "Point1") // control point 2 { cp.IsSelectable = false; bezierTmpCP = cp; } else if (dp.Name == "Point2") // end point { cp.SubPoint = bezierTmpCP; bezierTmpCP.ConnectedTo = cp; lastCP = cp; } } else { lastCP = cp; } if (obj == psRet) { cpRet = lastCP; } })); lastEndPoint = lastCP; } return(cpRet); }