示例#1
0
        protected override bool WorldDraw(AcGi.WorldDraw draw)
        {
            AcGi.WorldGeometry geo = draw.Geometry;
            if (geo != null)
            {
                geo.PushModelTransform(UCS);
                geo.Polygon(Corners);
                geo.PopModelTransform();
            }

            return(true);
        }
        protected override bool WorldDraw(AcGi.WorldDraw draw)
        {
            AcGi.WorldGeometry geo = draw.Geometry;
            if (geo != null)
            {
                geo.PushModelTransform(UCS);

                AcGe.Point3dCollection tempPts = new AcGe.Point3dCollection();
                foreach (AcGe.Point3d pt in allVertexes)
                {
                    tempPts.Add(pt);
                }
                if (lastVertex != null)
                {
                    if (tempPts.Count > 1)
                    {
                        AcDb.Line lastLine      = new AcDb.Line(allVertexes[allVertexes.Count - 2], allVertexes[allVertexes.Count - 1]);
                        double    offsetForward = ServiceGeodesy.GetProjectionOnLine(lastLine, lastVertex) - lastLine.Length;
                        double    offsetTowards = ServiceGeodesy.GetOffsetFromLine(lastLine, lastVertex);

                        AcDb.Xline xLine = new AcDb.Xline();
                        xLine.BasePoint = allVertexes[allVertexes.Count - 1];
                        xLine.UnitDir   = lastLine.Delta;

                        System.Windows.Forms.Keys mods = System.Windows.Forms.Control.ModifierKeys;
                        if ((mods & System.Windows.Forms.Keys.Control) > 0)
                        {
                            if (isMovingTowards)
                            {
                                lastVertex = xLine.GetPointAtDist(offsetForward);
                            }
                            else
                            {
                                xLine.TransformBy(AcGe.Matrix3d.Rotation(Math.PI / 2 * -1, AcGe.Vector3d.ZAxis, xLine.BasePoint));
                                lastVertex = xLine.GetPointAtParameter(offsetTowards);
                            }
                        }
                        else
                        {
                            if (Math.Abs(offsetForward) > Math.Abs(offsetTowards))
                            {
                                isMovingTowards = true;
                                lastVertex      = xLine.GetPointAtDist(offsetForward);
                            }
                            else
                            {
                                isMovingTowards = false;
                                xLine.TransformBy(AcGe.Matrix3d.Rotation(Math.PI / 2 * -1, AcGe.Vector3d.ZAxis, xLine.BasePoint));
                                lastVertex = xLine.GetPointAtParameter(offsetTowards);
                            }
                        }
                    }
                    tempPts.Add(lastVertex);
                }
                if (tempPts.Count > 0)
                {
                    geo.Polyline(tempPts, AcGe.Vector3d.ZAxis, IntPtr.Zero);
                }

                geo.PopModelTransform();
            }

            return(true);
        }