示例#1
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            // TODO:  添加 DrawTraceLine.OnMouseDown 实现
            base.OnMouseDown(button, shift, x, y, mapX, mapY);

            m_pStatusBarService.SetStateMessage("1.选择要素;2.右键/ENTER/SPACEBAR,结束选择;3.左键,确定跟踪的起点;4.左键,结束跟踪。(ESC: 取消/DEL:删除)");

            m_CurrentLayer = ((IDFApplication)this.Hook).CurrentEditLayer;

            m_bIsSelect = true;

            if (button != 2 && bBegineMove && button1 == 2)            //结束跟踪,复位
            {
                object a = esriConstructOffsetEnum.esriConstructOffsetSimple;
                object b = System.Reflection.Missing.Value;
                m_pTraceLine = m_pCursor.CurrentTrace;
                m_pOffsetTraceLine.ConstructOffset(m_pTraceLine, m_dOffsetDistance, ref a, ref b);
                IGeometry pGeometry = (IGeometry)m_pOffsetTraceLine;
                if (((IFeatureLayer)m_App.CurrentEditLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                {
                    pGeometry = (IGeometry)CommonFunction.GetPolygonBoundary((IPolygon)pGeometry);
                }

                CommonFunction.CreateFeature(m_App.Workbench, pGeometry, m_FocusMap, m_CurrentLayer);

                Reset();                //复位

                return;
            }

            if (button != 2 && bBegineMove && button1 == 1)            //开始跟踪
            {
                //'Start a trace if one doesn't exist
                m_pCursor    = m_pGraph.GetCursor(m_pPoint);
                m_pTraceLine = m_pCursor.CurrentTrace;
                object a = esriConstructOffsetEnum.esriConstructOffsetSimple;
                object b = System.Reflection.Missing.Value;
                m_pOffsetTraceLine.ConstructOffset(m_pTraceLine, m_dOffsetDistance, ref a, ref b);
                RefreshTraceline();
                m_lMoveCounter = 0;
                button1        = 2;
                return;
            }

            if (button == 2 && !bBegineMove)            //右键单击,停止选择
            {
                if (m_OriginFeatureArray.Count == 0)
                {
                    return;
                }

                CreateGraph();

                bBegineMove = true;

                return;
            }
        }
        private ICurve ConstructOffset(IPolyline inPolyline, double distanceFromCurve, bool isRightSide, double elevation)
        {
            if (inPolyline == null || inPolyline.IsEmpty)
            {
                return(null);
            }
            object          Missing        = Type.Missing;
            IPolyline       pPoly          = new ESRI.ArcGIS.Geometry.Polyline() as IPolyline;
            IConstructCurve constructCurve = (IConstructCurve)pPoly;

            if (!isRightSide)
            {
                distanceFromCurve = -distanceFromCurve;
            }
            constructCurve.ConstructOffset(inPolyline, distanceFromCurve, ref Missing, ref Missing);


            IRgbColor rgbColor = GetColor(0, 0, 0);

            AddTempolralPathToMap(m_MapMapControl, constructCurve as IGeometry, rgbColor);
            AddTempolralPathToGlobe(constructCurve as IGeometry, elevation);
            return(constructCurve as ICurve);
        }