コード例 #1
0
        /// <summary>
        /// Performs the data processing associated with this editing operation.
        /// </summary>
        /// <param name="ctx">The context in which the geometry is being calculated.</param>
        internal override void CalculateGeometry(EditingContext ctx)
        {
            // Calculate the end positions
            IPosition spos, epos;

            if (!Calculate(out spos, out epos))
            {
                throw new Exception("Failed to calculate parallel line positions");
            }

            // Apply the calculated positions so long as the end points of the parallel line
            // were created by this edit
            if (m_ParLine.StartPoint.Creator == this)
            {
                m_ParLine.StartPoint.ApplyPointGeometry(ctx, PointGeometry.Create(spos));
            }

            if (m_ParLine.EndPoint.Creator == this)
            {
                m_ParLine.EndPoint.ApplyPointGeometry(ctx, PointGeometry.Create(epos));
            }

            // If the parallel is an arc, define the geometry
            if (m_ParLine is ArcFeature)
            {
                // Get the center of the reference line
                ArcFeature   refArc = m_RefLine.GetArcBase();
                PointFeature center = refArc.Circle.CenterPoint;

                // Obtain a circle for the parallel
                double radius = Geom.Distance(center, m_ParLine.StartPoint);
                Circle circle = MapModel.AddCircle(center, radius);

                // Define arc direction
                bool iscw = refArc.IsClockwise;
                if (IsArcReversed)
                {
                    iscw = !iscw;
                }

                ArcGeometry geom = new ArcGeometry(circle, m_ParLine.StartPoint, m_ParLine.EndPoint, iscw);
                (m_ParLine as ArcFeature).Geometry = geom;
            }
        }