/// <summary> /// 在本次编辑栈内,应用拷贝状态的更改; /// </summary> /// <param name="thisMouseDownPosition">本次鼠标按下的位置</param> private void ApplyCurrentPositionState(Vector2D thisMouseDownPosition) { if (MousePositionTracker.LastMouseDownPosition == null) { return; } if (MousePositionTracker.CurrentHoverPosition == null) { return; } RollBackToLastMouseDownPosition(); var axis = Line2D.Create(thisMouseDownPosition, MousePositionTracker.LastMouseDownPosition); _mirrorEditDrawObjectCells.ForEach(p => { p.DrawObjectMirrorTool.Mirror(p.MirroredDrawObject, axis); }); //本次拷贝的绘制对象入栈; var newMirroredDrawObjects = _mirrorEditDrawObjectCells. Select(p => p.MirroredDrawObject.Clone()).ToArray(); _createdDrawObjects.AddRange(newMirroredDrawObjects); //将本次加入的绘制对象加入栈内; _undoMirroredDrawObjectsStack.Push(newMirroredDrawObjects); //发生了新的动作时,应清空重做栈; _redoMirroredDrawObjectsStack.Clear(); //清空"抓起"的对象; _mirrorEditDrawObjectCells.Clear(); }
/// <summary> /// 指定开始点,对当前线段进行普通的排序 /// </summary> /// <param name="lines"></param> /// <param name="point"></param> /// <param name="sortedLines"></param> private void SortByPoint(List <Line2D> lines, Vector2D spoint, ref List <Line2D> sortedLines) { //确定的线 Line2D confirmLine = null; //查找的线段 Line2D searchLine = lines.Find(x => x.Start.IsAlmostEqualTo(spoint)); if (searchLine != null) { confirmLine = searchLine; } else { searchLine = lines.Find(x => x.End.IsAlmostEqualTo(spoint)); //反转当前直线, confirmLine = Line2D.Create(searchLine.End, searchLine.Start); } if (confirmLine != null) { sortedLines.Add(confirmLine); lines.Remove(searchLine); if (lines.Count > 0) { SortByPoint(lines, confirmLine.End, ref sortedLines); } } }
/// <summary> /// 获取最靠近原点的墙体 /// </summary> /// <returns></returns> private List <Line2D> GetHuntWithOrigin(out Vector2D origin, List <Line2D> decomposeLine2ds) { List <Line2D> huntWalls = null; if (OrginLine == null) { List <Vector2D> points = new List <Vector2D>(); decomposeLine2ds.ForEach(x => { points.Add(x.Start); points.Add(x.End); }); //获取最小的点 origin = points.Distinct(new Vector2DEqualityComparer()).OrderBy(a => a.X).ThenBy(c => c.Y).FirstOrDefault(); //获取和最近点 huntWalls = GetHuntLines(origin, decomposeLine2ds); } else { huntWalls = new List <Line2D>(); Vector2D Orgin = new Vector2D(OrginLine.Start.X, OrginLine.Start.Y); origin = Orgin; Vector2D start = new Vector2D(OrginLine.Start.X, OrginLine.Start.Y); Vector2D end = new Vector2D(OrginLine.End.X, OrginLine.End.Y); Line2D line2d = Line2D.Create(start, end); huntWalls.Add(line2d); } return(huntWalls); }
/// <summary> /// 合并可以合并的线段 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MergeTestBtn_Click(object sender, RoutedEventArgs e) { List <Geometry2D> gss = this.drawingKernel.GeometryShapes; List <Line2D> lines = new List <Line2D>(); foreach (var g in gss) { if (g is DrawingKernel.Geometries.Primitives.LineGeometry) { DrawingKernel.Geometries.Primitives.LineGeometry line = g as DrawingKernel.Geometries.Primitives.LineGeometry; lines.Add(Line2D.Create(line.Start, line.End)); } if (g.GeometryId == "tp") { this.drawingKernel.RemoveGeometryShape(g); } } List <Line2D> mergeLines = GraphicAlgorithm.Merge(lines); if (mergeLines != null) { mergeLines.ForEach(x => { DrawingKernel.Geometries.Primitives.LineGeometry lg = new DrawingKernel.Geometries.Primitives.LineGeometry(x.Start, x.End); lg.PenColor = KernelProperty.GetRandomColor(); lg.GeometryId = "tp"; this.drawingKernel.AddShape(lg); }); } }
protected override void OnMouseMove(MouseMoveEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (MousePositionTracker.LastMouseDownPosition == null) { return; } //回滚到最近一次鼠标按下的位置; RollBackToLastMouseDownPosition(); var position = e.Position; //进行偏移变化; _mirrorEditDrawObjectCells.ForEach(p => { p.DrawObjectMirrorTool.Mirror(p.MirroredDrawObject, Line2D.Create(position, MousePositionTracker.LastMouseDownPosition)); }); MousePositionTracker.CurrentHoverPosition = position; RaiseVisualChanged(); e.Handled = true; base.OnMouseMove(e); }
private void ClosetTestBtn2_Click(object sender, RoutedEventArgs e) { //封闭区域测试 List <Geometry2D> gss = this.drawingKernel.GeometryShapes; List <Line2D> lines = new List <Line2D>(); //转换图形 foreach (var g in gss) { if (g is DrawingKernel.Geometries.Primitives.LineGeometry) { DrawingKernel.Geometries.Primitives.LineGeometry line = g as DrawingKernel.Geometries.Primitives.LineGeometry; lines.Add(Line2D.Create(line.Start, line.End)); } if (g.GeometryId == "tp") { this.drawingKernel.RemoveGeometryShape(g); } } //查找封闭区域 List <List <Line2D> > nn = GraphicAlgorithm.ClosedLookup(lines, false, true); if (nn != null) { nn.ForEach(x => { PolygonGeometry pg = new PolygonGeometry(); x.ForEach(y => { pg.PPoints.Add(y.Start); }); pg.FillColor = KernelProperty.GetRandomColor(); pg.GeometryId = "tp"; this.drawingKernel.AddShape(pg); }); } }
protected override void OnMirror(Rectangle drawObject, Line2D axis) { var s = TransformUtil.Mirror(drawObject.Rectangle2D.MiddleLine2D.Start, axis); var e = TransformUtil.Mirror(drawObject.Rectangle2D.MiddleLine2D.End, axis); drawObject.Rectangle2D = new Rectangle2D2(Line2D.Create(s, e), drawObject.Rectangle2D.Width); }
public static Line2D GetExtendLineWithIntersectPositions(Line2D line2D, Line2D[] extendLines, Vector2D[] intersectPositions, Rectangle2D2 rectIntersect) { if (extendLines.Length == 0) { return(null); } if (rectIntersect == null) { return(null); } if (intersectPositions.Length == 0) { return(null); } if (rectIntersect.Contains(line2D.Start) && rectIntersect.Contains(line2D.End) && intersectPositions.Length == 2) { var p1 = intersectPositions[0]; var p2 = intersectPositions[1]; if (line2D.Start.IsInLine(Line2D.Create(p1, line2D.End))) { return(Line2D.Create(p1, p2)); } return(Line2D.Create(p2, p1)); } if (rectIntersect.Contains(line2D.Start)) { return(Line2D.Create(intersectPositions.First(), line2D.End)); } if (rectIntersect.Contains(line2D.End)) { return(Line2D.Create(line2D.Start, intersectPositions.First())); } return(null); }
/// <summary> /// 图形的内缩小 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ElasticityTestBtn_Click(object sender, RoutedEventArgs e) { List <Geometry2D> gss = this.drawingKernel.GeometryShapes; List <Line2D> lines = new List <Line2D>(); foreach (var g in gss) { if (g is DrawingKernel.Geometries.Primitives.LineGeometry) { DrawingKernel.Geometries.Primitives.LineGeometry line = g as DrawingKernel.Geometries.Primitives.LineGeometry; lines.Add(Line2D.Create(line.Start, line.End)); } if (g.GeometryId == "tp") { this.drawingKernel.RemoveGeometryShape(g); } } //查找封闭区域 List <List <Line2D> > nn = GraphicAlgorithm.ClosedLookup(lines, true, true); if (nn != null && nn.Count > 0) { List <Line2D> nt = nn[0]; List <Line2D> wtn = GraphicAlgorithm.Elastic(nt, -20); PolygonGeometry pg = new PolygonGeometry(); wtn.ForEach(y => { pg.PPoints.Add(y.Start); }); pg.FillColor = KernelProperty.GetRandomColor(); pg.GeometryId = "tp"; this.drawingKernel.AddShape(pg); } }
protected override void OnMirror(LineBase drawObject, Line2D axis) { var s = TransformUtil.Mirror(drawObject.Line2D.Start, axis); var e = TransformUtil.Mirror(drawObject.Line2D.End, axis); drawObject.Line2D = Line2D.Create(s, e); }
public List <Rectangle2D> GetMinimunRectangle(List <Line2D> lines) { List <Vector2D> recPoints = new List <Vector2D>(); List <Vector2D> endPoints = lines.GetEndPoints(); List <Line2D> tempLines = new List <Line2D>(); foreach (var point in endPoints) { Line2D line1 = Line2D.Create(point, (GetBasicDirection()[0])); Line2D line2 = Line2D.Create(point, GetBasicDirection()[1]); tempLines.Add(line1); tempLines.Add(line2); } EliminateCollinearLines(tempLines); for (int i = 0; i < tempLines.Count; i++) { for (int j = tempLines.Count - 1; j > i; j--) { Vector2D p = tempLines[i].Intersect(tempLines[j]); if (p != null) { recPoints.Add(p); } } } recPoints = recPoints.DistinctPoint(); return(GetRecrangle(recPoints)); }
/// <summary> /// 获取一个点的镜像点 /// </summary> /// <param name="v"></param> /// <param name="l"></param> /// <returns></returns> public static Vector2D Mirror(Vector2D v, Line2D mirror) { Vector2D p = v.ProjectOn(mirror); Line2D le = Line2D.Create(v, p); Vector2D re = p.Offset(le.Direction * le.Length); return(re); }
/// <summary> /// 绘制当前的墙体 /// </summary> /// <param name="points"></param> protected override void Draw(List <Vector2D> points) { if (start != null && end != null) { var halfThickness = Thickness / 2; List <Vector2D> fillPoints = new List <Vector2D>(); var start3D = new Albert.Geometry.Primitives.Vector3D(Start.X, Start.Y, 0); var end3D = new Albert.Geometry.Primitives.Vector3D(End.X, End.Y, 0); Vector3D lineDir = end3D - start3D; Vector3D offsetDir = lineDir.Cross(new Vector3D(0, 0, 1)).Normalize(); Vector3D offv1 = start3D + halfThickness * offsetDir; Vector3D offv2 = start3D - halfThickness * offsetDir; Vector3D offv3 = end3D - halfThickness * offsetDir; Vector3D offv4 = end3D + halfThickness * offsetDir; Line2D l5 = Line2D.Create(start, end); //钢梁 fillPoints.Add(TransformUtil.Projection(offv1)); fillPoints.Add(TransformUtil.Projection(offv2)); fillPoints.Add(TransformUtil.Projection(offv3)); fillPoints.Add(TransformUtil.Projection(offv4)); fillPoints.Add(TransformUtil.Projection(offv4)); DrawingContext dc = this.RenderOpen(); Pen.Freeze(); //冻结画笔,这样能加快绘图速度 PathGeometry paths = new PathGeometry(); paths.FillRule = FillRule.EvenOdd; PathFigureCollection pfc = new PathFigureCollection(); PathFigure pf = new PathFigure(); pfc.Add(pf); pf.StartPoint = KernelProperty.MMToPix(fillPoints[0]); for (int i = 0; i < fillPoints.Count; i++) { LineSegment ps = new LineSegment(); ps.Point = KernelProperty.MMToPix(fillPoints[i]); pf.Segments.Add(ps); } pf.IsClosed = true; paths.Figures = pfc; PenColor = Colors.Black; dc.DrawGeometry(Brush, Pen, paths); PenColor = Colors.DeepPink; dc.DrawLine(Pen, KernelProperty.MMToPix(l5.Start), KernelProperty.MMToPix(l5.End)); dc.Close(); } }
/// <summary> /// 将三维线直接投影为二维线段 /// </summary> /// <param name="line3d"></param> /// <returns></returns> public static List <Line2D> Projection(List <Line3D> line3ds) { List <Line2D> line2ds = new List <Line2D>(); line3ds.ForEach(x => { line2ds.Add(Line2D.Create(Projection(x.Start), Projection(x.End))); }); return(line2ds); }
/// <summary> /// 当前直线的绘制功能 /// </summary> /// <param name="vss"></param> protected override void Draw(List <Vector2D> points) { DrawingContext dc = this.RenderOpen(); //冻结画笔,这样能加快绘图速度 Pen.Freeze(); dc.DrawLine(Pen, KernelProperty.MMToPix(points[0]), KernelProperty.MMToPix(points[1])); dc.DrawLine(Pen, KernelProperty.MMToPix(points[1]), KernelProperty.MMToPix(points[2])); SeText(dc, Line2D.Create(points[1], points[2])); dc.DrawLine(Pen, KernelProperty.MMToPix(points[2]), KernelProperty.MMToPix(points[3])); dc.Close(); }
/// <summary> /// 当前的拖拽 /// </summary> /// <param name="p"></param> public void Erase(Vector2D p) { if (!isPausing) { steelSupportGeometry.Face = Line2D.Create(this.steelSupportGeometry.Central, p).Direction; if (DrawEraseEvent != null) { DrawEraseEvent(new ActionEventArgs(this.Geometry)); } this.steelSupportGeometry.Update(); } }
/// <summary> /// 捕获圆形上的点 /// </summary> /// <param name="v"></param> /// <returns></returns> public override IntersectPoint IntersectPoint(Vector2D v) { if (Math.Abs(v.Distance(this.Start) - this.Radius) < KernelProperty.PixelToSize) { Line2D l = Line2D.Create(this.Start, v); Vector2D nv = this.Start.Offset(this.Radius, l.Direction); IntersectPoint ip = new IntersectPoint(); ip.IntersectPointStyle = 1; ip.Line = l; ip.Point = nv; return(ip); } return(null); }
/// <summary> /// 按照点,绘制连续的线段,且没有填充 /// </summary> /// <param name="points"></param> /// <param name="color"></param> /// <param name="thinkness"></param> /// <returns></returns> protected override void Draw(List <Vector2D> points) { DrawingContext dc = this.RenderOpen(); Pen.Freeze(); //冻结画笔,这样能加快绘图速度 for (int i = 0; i < points.Count - 1; i++) { dc.DrawLine(Pen, KernelProperty.MMToPix(points[i]), KernelProperty.MMToPix(points[i + 1])); } var line = Line2D.Create(start, end); this.DrawArrow(dc, line); SeText(dc, line); dc.Close(); }
public static Line2D GetExtendMemberWithIntersectPositions(Line2D line2D, Line2D[] extendLines, Vector2D[] intersectPositions, Rectangle2D2 rectIntersect, double width, double gap) { if (extendLines.Length == 0) { return(null); } if (rectIntersect == null) { return(null); } if (intersectPositions.Length == 0) { return(null); } if (rectIntersect.Contains(line2D.Start) && rectIntersect.Contains(line2D.End) && intersectPositions.Length == 2) { var p1 = intersectPositions[0]; var p2 = intersectPositions[1]; var line1 = extendLines.First(x => p1.IsInLine(x)); var angle1 = line1.Direction.AngleWith(line2D.Direction); var newP1 = GetExtendPoint(p1, -line2D.Direction, angle1, width, gap); var line2 = extendLines.First(x => p2.IsInLine(x)); var angle2 = line2.Direction.AngleWith(line2D.Direction); var newP2 = GetExtendPoint(p2, line2D.Direction, angle2, width, gap); if (line2D.Start.IsInLine(Line2D.Create(p1, line2D.End))) { return(Line2D.Create(newP1, newP2)); } return(Line2D.Create(newP2, newP1)); } if (rectIntersect.Contains(line2D.Start) && line2D.Start.IsInLine(Line2D.Create(intersectPositions.First(), line2D.End))) { var angle = line2D.Direction.AngleWith(extendLines[0].Direction); var newEndPoint = GetExtendPoint(intersectPositions.First(), -line2D.Direction, angle, width, gap); return(Line2D.Create(newEndPoint, line2D.End)); } if (rectIntersect.Contains(line2D.End) && line2D.End.IsInLine(Line2D.Create(intersectPositions.First(), line2D.Start))) { var angle = line2D.Direction.AngleWith(extendLines[0].Direction); var newEndPoint = GetExtendPoint(intersectPositions.First(), line2D.Direction, angle, width, gap); return(Line2D.Create(line2D.Start, newEndPoint)); } return(null); }
/// <summary> /// 拖拽 /// </summary> /// <param name="p"></param> public void Erase(Vector2D p) { this.end = p; //已经移动的距离 Line2D mirrorLine = Line2D.Create(this.start, this.end); //移动当前图形 this.GeometryShape.Mirror(this.tagert, mirrorLine); GeometryShape.Update(); //擦除效果 if (this.DrawEraseEvent != null) { this.DrawEraseEvent(new ActionEventArgs(GeometryShape)); } }
/// <summary> /// 将拷贝绘制对象(非原件)集合的位置回溯至上一次鼠标按下的位置; /// </summary> private void RollBackToLastMouseDownPosition() { if (MousePositionTracker.LastMouseDownPosition == null) { return; } if (MousePositionTracker.CurrentHoverPosition == null) { return; } _mirrorEditDrawObjectCells.ForEach(p => { p.DrawObjectMirrorTool.Mirror(p.MirroredDrawObject, Line2D.Create(MousePositionTracker.LastMouseDownPosition, MousePositionTracker.CurrentHoverPosition)); }); }
/// <summary> /// 设置第一个点 /// </summary> /// <param name="p"></param> public void SetPoint(Vector2D p) { if (steelSupportGeometry.Central == null) { steelSupportGeometry.Central = p; steelSupportGeometry.Face = Vector2D.Zero; if (DrawStartEvent != null) { Geometry.IsActioning = true; DrawStartEvent(new ActionEventArgs(this.Geometry)); } } else { steelSupportGeometry.Face = Line2D.Create(this.steelSupportGeometry.Central, p).Direction; this.Complete(); } }
/// <summary> /// 获取引用的点 /// </summary> /// <param name="canCatchPoints"></param> /// <param name="v"></param> /// <returns></returns> private IntersectPoint RefencePoint(List <Vector2D> canCatchPoints, Vector2D v) { IntersectPoint ip = null; if (canCatchPoints != null && canCatchPoints.Count > 0) { Vector2D point1 = canCatchPoints.OrderBy(x => Math.Abs(v.Y - x.Y)).First(); if (Math.Abs(v.Y - point1.Y) < KernelProperty.Tolerance) { if (ip == null) { ip = new IntersectPoint(); ip.IntersectPointStyle = 2; ip.Point = Vector2D.Create(v.X, point1.Y); ip.Refences = new List <Line2D>(); } else { ip.Point = Vector2D.Create(ip.Point.X, point1.Y); } ip.Refences.Add(Line2D.Create(point1, ip.Point)); } Vector2D point2 = canCatchPoints.OrderBy(x => Math.Abs(v.X - x.X)).First(); if (Math.Abs(v.X - point2.X) < KernelProperty.Tolerance) { if (ip == null) { ip = new IntersectPoint(); ip.IntersectPointStyle = 2; ip.Point = Vector2D.Create(point2.X, v.Y); ip.Refences = new List <Line2D>(); } else { ip.Point = Vector2D.Create(point2.X, ip.Point.Y); } ip.Refences.Add(Line2D.Create(point2, ip.Point)); } } return(ip); }
/// <summary> /// 进行拖拽转动 /// </summary> /// <param name="gs"></param> private void A_DrawEraseEvent(ActionEventArgs gs) { var start = command.Start; var end = command.End; sublineHGeometry.Start = start; sublineHGeometry.End = Vector2D.Create(start.X + 500, start.Y); sublineHGeometry.Update(); sublineVGeometry.Start = start; sublineVGeometry.End = start + Line2D.Create(start, end).Direction * 500; sublineVGeometry.Update(); angleGeometry.Start = Vector2D.Create(start.X + 100, start.Y);; angleGeometry.End = start + Line2D.Create(start, end).Direction * 100; angleGeometry.Angle = Line2D.Create(start, end).Direction.AngleFrom(Vector2D.BasisX); angleGeometry.Update(); }
/// <summary> /// 绘制缩放 /// </summary> /// <param name="gs"></param> private void A_DrawEraseEvent(ActionEventArgs gs) { ArcGeometry arc = action.Geometry as ArcGeometry; if (arc.Start != null && arc.End != null && arc.Central != null) { sublineGeometry.Start = arc.Start; if (arc.Start.Distance(arc.Central) < arc.Start.Distance(arc.End) / 2) { sublineGeometry.End = Line2D.Create(arc.Start, arc.End).MiddlePoint; } else { sublineGeometry.End = arc.Central; } if (sublineGeometry.Start.IsAlmostEqualTo(sublineGeometry.End)) { sublineGeometry.Opacity = 0; } else { sublineGeometry.Opacity = 1; sublineGeometry.Update(); } } else { sublineGeometry.Start = arc.Start; sublineGeometry.End = arc.End; if (sublineGeometry.Start.IsAlmostEqualTo(sublineGeometry.End)) { sublineGeometry.Opacity = 0; } else { sublineGeometry.Opacity = 1; sublineGeometry.Update(); } } }
/// <summary> /// 开始进行转动 /// </summary> /// <param name="p"></param> public void Erase(Albert.Geometry.Primitives.Vector2D p) { this.end = p; //已经移动的距离 Vector2D direction = Line2D.Create(this.start, this.end).Direction; //增量的移动距离 double a = Vector2D.BasisX.AngleFrom(direction); double incrementAngle = a - lastAngle; //最终移动距离 lastAngle = a; //移动当前图形 this.GeometryShape.Rolate(start, incrementAngle); //擦除效果 if (this.DrawEraseEvent != null) { this.DrawEraseEvent(new ActionEventArgs(GeometryShape)); } }
/// <summary> /// 对两个线进行合并 /// </summary> /// <param name="L1"></param> /// <param name="L2"></param> /// <returns></returns> private Line2D MergeLine(Line2D L1, Line2D L2) { if (L1.Direction.IsAlmostEqualTo(L2.Direction) || L1.Direction.IsAlmostEqualTo(-L2.Direction)) { if (L1.Start.IsOnLine(L2) && L1.End.IsOnLine(L2)) { return(L2); } if (L2.Start.IsOnLine(L1) && L2.End.IsOnLine(L1)) { return(L1); } //假如L1的起点在L2上,则说明远端点位L1的终点 if (L1.Start.IsOnLine(L2)) { //两个都为起点 if (L2.Start.IsOnLine(L1)) { return(Line2D.Create(L1.End, L2.End)); } else { return(Line2D.Create(L1.End, L2.Start)); } } else { if (L2.Start.IsOnLine(L1)) { return(Line2D.Create(L1.Start, L2.End)); } else { return(Line2D.Create(L1.Start, L2.Start)); } } } return(null); }
private List <Line3D> DecomposeLines(List <Line3D> allLines) { //获得打断后的楼板线 List <Line3D> resultDecomposedLines = new List <Line3D>(); //将所有的线段投影到XYZ平面 List <Line2D> line2ds = new List <Line2D>(); //获取线段的标高信息 double Elevation = allLines.First().Start.Z; //首先投影所有线段 allLines.ForEach(x => { if (!x.Start.Z.AreEqual(Elevation) || !x.End.Z.AreEqual(Elevation)) { resultDecomposedLines = null; } Vector2D start = new Vector2D(x.Start.X, x.Start.Y); Vector2D end = new Vector2D(x.End.X, x.End.Y); Line2D line2d = Line2D.Create(start, end); line2ds.Add(line2d); }); if (resultDecomposedLines == null) { //说明直线高度不一致 throw new Exception("给的线段高度不一致"); } //对当前的线段进行打断 List <Line2D> remainingLines = line2ds.Decompose(); remainingLines.ForEach(x => { Line3D line3d = new Line3D(Vector3D.Create(x.Start.X, x.Start.Y, Elevation), Vector3D.Create(x.End.X, x.End.Y, Elevation)); resultDecomposedLines.Add(line3d); }); return(resultDecomposedLines); }
/// <summary> /// 绘制当前直线 /// </summary> public override void Update() { if (Start != null && end != null) { //对直线矩形偏移 Line3D subline3d = Line3D.Create(Vector3D.Create(Start.X, Start.Y, 0), Vector3D.Create(end.X, end.Y, 0)); var offsetDirection = subline3d.Direction.Cross(Vector3D.BasisZ); //获取偏移量 var offsetdir = Vector2D.Create(offsetDirection.X, offsetDirection.Y) * KernelProperty.PixToMM(SublineOffset); //添加偏移 var offline = Line2D.Create(Start, end).Offset(offsetdir); List <Vector2D> points = new List <Vector2D>(); this.DashStyle = new System.Windows.Media.DashStyle(new double[] { 5, 5 }, 10); this.PenColor = Colors.DeepSkyBlue; this.Pen.EndLineCap = PenLineCap.Triangle; points.Add(Start); points.Add(offline.Start); points.Add(offline.End); points.Add(end); this.Draw(points); } }
/// <summary> /// 完成命令 /// </summary> public void Complete() { //已经移动的距离 Line2D mirrorLine = Line2D.Create(this.start, this.end); //移动当前图形 this.GeometryShape.Mirror(this.tagert, mirrorLine); //更新当前的目标对象 this.GeometryShape.Update(); //当前命令操作完成 if (DrawCompleteEvent != null) { GeometryShape.UnSelect(); this.DrawCompleteEvent(new ActionEventArgs(GeometryShape)); } if (RecordCommand != null) { CopyFunctional mf = new CopyFunctional(this.tagert); RecordCommand(this, mf); } }