コード例 #1
0
ファイル: LineElevToolCls.cs プロジェクト: siszoey/geosufan
        //鼠标在Map的事件
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            IPoint pPt = m_ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (m_NewLineFeedBack == null)
            {
                m_NewLineFeedBack = new NewLineFeedbackClass();

                ISimpleLineSymbol pSimLineSymbol = null;
                IRgbColor         pRGBColor      = null;

                pSimLineSymbol            = m_NewLineFeedBack.Symbol as ISimpleLineSymbol;
                pRGBColor                 = new RgbColorClass();
                pRGBColor.Red             = 255;
                pRGBColor.Blue            = 0;
                pRGBColor.Green           = 0;
                pSimLineSymbol.Color      = pRGBColor as IColor;
                pSimLineSymbol.Style      = esriSimpleLineStyle.esriSLSSolid;
                m_NewLineFeedBack.Display = m_ScreenDisplay;
                m_NewLineFeedBack.Start(pPt);
            }
            else
            {
                m_NewLineFeedBack.AddPoint(pPt);
            }
        }
コード例 #2
0
        public override void OnMouseUp(int button, int shift, int x, int y, double mapX, double mapY)
        {
            m_pRecordPointArray.Add(movePoint);

            IPolyline pPolyline;

            pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray);
            IGeometry pGeomLn = (IGeometry)pPolyline;

            //m_pNewLineFeedback.Stop();

            if (pGeomLn != null)
            {
                AddCreateElement(pGeomLn, this.m_pMapControl.ActiveView);
                this.m_pMapControl.ActiveView.Refresh();
            }
            if (m_pRecordPointArray.Count != 0)
            {
                m_pRecordPointArray.RemoveAll();
            }


            m_pNewLineFeedback = null;


            base.OnMouseUp(button, shift, x, y, mapX, mapY);
        }
コード例 #3
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }

            IPoint pPnt = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (m_pNewLineFeedback == null) //第一次按下
            {
                m_pNewLineFeedback = new NewLineFeedbackClass();

                IRgbColor         pRGB    = new RgbColorClass();
                ISimpleLineSymbol pSLnSym = m_pNewLineFeedback.Symbol as ISimpleLineSymbol;
                pRGB.Red   = 255;
                pRGB.Blue  = 0;
                pRGB.Green = 0;

                pSLnSym.Color = pRGB;
                pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid;
                m_pNewLineFeedback.Display = m_MapControl.ActiveView.ScreenDisplay;
                m_pNewLineFeedback.Start(pPnt);
            }
            else                    //将点加入到工具中去
            {
                m_pNewLineFeedback.AddPoint(pPnt);
            }
        }
コード例 #4
0
        protected override void OnDoubleClick()
        {
            base.OnDoubleClick();


            try
            {
                if (LineFeedBack != null)
                {
                    trackgeom    = LineFeedBack.Stop();
                    LineFeedBack = null;

                    if (GetDriveCenterlineIntersection(trackgeom))
                    {
                        if (CalculateHouseNumber())
                        {
                            SetAttributes();
                        }
                    }

                    mMap.ClearSelection();
                    ITopologicalOperator to = SelectedPoint.Shape as ITopologicalOperator;
                    IGeometry            g  = to.Buffer(10);
                    mMap.SelectByShape(g, ArcMap.ThisApplication.SelectionEnvironment, true);
                    IFeatureSelection fsel = Globals.AddressPointLayer as IFeatureSelection;


                    ArcMap.Document.FocusMap.ClearSelection();
                    ArcMap.Document.ActiveView.Refresh();
                    ArcMap.Document.FocusMap.ClearSelection();
                }
            }
            catch { }
        }
コード例 #5
0
        //双击则创建该线,并弹出缓冲窗体
        public override void OnDblClick()
        {
            //获取折线 并获取当前视图的屏幕显示
            if (m_pNewLineFeedback == null)
            {
                return;
            }

            IPolyline pPolyline = m_pNewLineFeedback.Stop();

            m_pNewLineFeedback = null;
            pPolyline.Project(m_MapControl.Map.SpatialReference);

            frmBufferSet pFrmBufSet = new frmBufferSet(pPolyline as IGeometry, m_MapControl.Map);
            IGeometry    pGeometry  = pFrmBufSet.GetBufferGeometry();

            if (pGeometry == null || pFrmBufSet.Res == false)
            {
                return;
            }

            //==================================================================================================
            //执行查询数据操作
            ModDBOperator.QueryDataByGeometry(pGeometry, m_hook);
        }
コード例 #6
0
        public override void OnMouseUp(int button, int shift, int x, int y, double mapX, double mapY)
        {
            {
                /*CommonFunction.DrawPointSMSSquareSymbol(m_pMapControl, movePoint);       */
                m_pNewLineFeedback = new NewLineFeedbackClass();
                IGeometry pGeomLn = m_pNewLineFeedback.Stop();

                if (pGeomLn != null)
                {

                    AddCreateElement(pGeomLn, this.m_pMapControl.ActiveView);
                    this.m_pMapControl.ActiveView.Refresh();
                }
                m_pNewLineFeedback = null;

            }
            double dblZimuth = CommonFunction.GetAzimuth_P12(downPoint.Y, downPoint.X, movePoint.Y, movePoint.X);
            dblZimuth = CommonFunction.RadToDeg(dblZimuth);
            strResult1 = dblZimuth.ToString(".#####") + " (°) ";
            strResult2 = "X=" + downPoint.X.ToString(".##") + " " + "Y=" + downPoint.Y.ToString(".##");
            strResult3 = "X=" + movePoint.X.ToString(".##") + " " + "Y=" + movePoint.Y.ToString(".##");
            if (strResult1 != null && strResult2 != null && strResult3 != null)
            {
                //FrmAzimuthAngle.instance.SetInfo();
                FrmAzimuthAngle.instance.ShowDialog();

            }
        }
コード例 #7
0
ファイル: MeasureTools.cs プロジェクト: zhongshuiyuan/WLib
        /// <summary>
        /// 结束当前的测量,返回进行量算时在地图上绘的图形对象
        /// 建议在Map的DoubleClick事件或MouseDown(右键)事件中调用本方法
        /// 将返回对象用map.DrawShape方法绘在地图临时层上
        /// </summary>
        /// <param name="point">终点</param>
        /// <returns>地图上绘的图形对象</returns>
        public IGeometry SurveyEnd(IPoint point)
        {
            IGeometry geometry = null;

            if (_eMeasureType == EMeasureType.Distance || _eMeasureType == EMeasureType.Angle)
            {
                if (_newLineFeedback != null)
                {
                    _newLineFeedback.AddPoint(point);
                    geometry         = _newLineFeedback.Stop();
                    _newLineFeedback = null;
                }
            }
            else if (_eMeasureType == EMeasureType.Area)
            {
                if (_newPolygonFeedback != null)
                {
                    _newPolygonFeedback.AddPoint(point);
                    geometry            = _newPolygonFeedback.Stop();
                    _newPolygonFeedback = null;
                }
            }

            _pointCollection = null;
            IsSurveying      = false;
            return(geometry);
        }
コード例 #8
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            // TODO:  添加 CalculateZimuth.OnMouseDown 实现

               {
                downPoint = this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                if (m_pNewLineFeedback == null)
                {
                    ISimpleLineSymbol pSLnSym;
                    m_pNewLineFeedback = new NewLineFeedbackClass();
                    pSLnSym = (ISimpleLineSymbol)m_pNewLineFeedback.Symbol;
                    Color color = ColorTranslator.FromHtml(SystemInfo.Instance.LineColor);
                    IColor pColor = new RgbColorClass();
                    pColor.RGB = color.B * 65536 + color.G * 256 + color.R;
                    pSLnSym.Color = pColor;
                    pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid;
                    m_pNewLineFeedback.Display = this.m_pMapControl.ActiveView.ScreenDisplay;
                    m_pNewLineFeedback.Constraint = esriLineConstraints.esriLineConstraintsVertical;
                    m_pNewLineFeedback.Start(downPoint);

                }
            //                 else
            //                 {
            //                     m_pNewLineFeedback.AddPoint(downPoint);
            //                 }
            }
              /* CommonFunction.DrawPointSMSSquareSymbol(m_pMapControl, downPoint);*/
        }
コード例 #9
0
ファイル: CmdCreateLine.cs プロジェクト: frankerlee/Yutai
 public override void OnDblClick()
 {
     try
     {
         if (_lineFeedback == null)
         {
             return;
         }
         IPolyline polyline = _lineFeedback.Stop();
         if (_lineFeedback != null)
         {
             _context.ActiveView.Refresh();
             _lineFeedback = null;
         }
         if (polyline == null)
         {
             return;
         }
         //CommonHelper.CreatePointFeatures(_pointFeatureLayer, polyline, true, true, true);
         CommonHelper.CreateLineFeature(_lineFeatureLayer, polyline);
         _context.ActiveView.Refresh();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
コード例 #10
0
 public override void OnDblClick()
 {
     if (this._lineFeedback != null)
     {
         this._Point = null;
         IPolyline polyline = this._lineFeedback.Stop();
         this._lineFeedback = null;
         if (!polyline.IsEmpty)
         {
             frmInputText frm = new frmInputText();
             frm.Title             = "输入缓冲距离";
             frm.Label             = "缓冲距离";
             frm.txtText.EditValue = 50;
             if (frm.ShowDialog() != DialogResult.OK)
             {
                 return;
             }
             double bufferDist = 50;
             try
             {
                 bufferDist = Convert.ToDouble(frm.txtText.EditValue);
             }
             catch (Exception)
             {
                 MessageService.Current.Warn("缓冲距离必须为数字!");
                 return;
             }
             ITopologicalOperator topo   = polyline as ITopologicalOperator;
             IGeometry            buffer = topo.Buffer(bufferDist);
             _plugin.FireFenceAdded(new FenceAddedArgs((IGeometry)buffer));
             IActiveView activeView = this._context.FocusMap as IActiveView;
             activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, buffer.Envelope);
         }
     }
 }
コード例 #11
0
ファイル: DrawPolylineTool.cs プロジェクト: sishui198/ares
        protected override void OnMouseDown(MouseEventArgs arg)
        {
            base.OnMouseDown(arg);

            if (Painter.ActiveLayer != null && arg.Button == MouseButtons.Left)
            {
                try
                {
                    ValueSymbolForm valueSymbolForm = AddIn.FromID <ValueSymbolForm.AddinImpl>(ThisAddIn.IDs.ValueSymbolForm).UI;
                    selectedValue = valueSymbolForm.SelectedValue;
                    selectedColor = valueSymbolForm.SelectedColor;

                    IPoint startCoor = Raster.ScreenCoor2MapCoor(arg.X, arg.Y);

                    if (!isDrawing)
                    {
                        newLineFeedback         = new NewLineFeedback();
                        newLineFeedback.Display = ArcMap.Document.ActiveView.ScreenDisplay;
                        newLineFeedback.Symbol  = (ISymbol)Display.GetDefaultSelectLineSymbol();
                        newLineFeedback.Start(startCoor);
                    }

                    newLineFeedback.AddPoint(startCoor);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
                }
            }
        }
コード例 #12
0
 public override void OnMouseMove(int button, int shift, int x, int y)
 {
     if (!this.m_dmd.Visible)
     {
         this._lineFeedback.Stop();
         this._lineFeedback = null;
         this.gpolyLine_0.Clear();
     }
     else
     {
         IPoint point = _context.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
         this.gpoint_1.X = point.X;
         this.gpoint_1.Y = point.Y;
         if (this.gpolyLine_0.Size() > 0)
         {
             double num       = this.gpoint_0.DistanceToPt(this.gpoint_1);
             double totalDist = this.gpolyLine_0.Length + num;
             this.m_dmd.CurDist   = num;
             this.m_dmd.TotalDist = totalDist;
         }
         if (this._lineFeedback != null)
         {
             this._lineFeedback.MoveTo(point);
         }
     }
 }
コード例 #13
0
ファイル: DrawPolyline.cs プロジェクト: wwcc19870805/DIFGIS
        private void Reset()
        {
            m_MapControl.ActiveView.FocusMap.ClearSelection();

            m_pActiveView.GraphicsContainer.DeleteAllElements();

            m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, m_pEnvelope);             //视图刷新

            m_pStatusBarService.SetStateMessage("就绪");

            m_bInputWindowCancel = true;
            m_bInUse             = false;
            m_bkeyCodeS          = false;   //按S直角封闭
            m_drawState          = "";
            if (m_pLastPoint != null)
            {
                m_pLastPoint.SetEmpty();
            }
            ;
            m_pLineFeedArray.RemoveAll();            //清空绘图数组
            m_pUndoArray.RemoveAll();                //清空回退数组
            m_pEnvelope = null;
            if (m_pLineFeed != null)
            {
                m_pLineFeed = null;
            }
            if (m_pLastLineFeed != null)
            {
                m_pLastLineFeed.Stop();
            }
        }
コード例 #14
0
ファイル: ToolNewLabelElement.cs プロジェクト: secondii/Yutai
 public override void OnDblClick()
 {
     if (this.inewLineFeedback_0 != null)
     {
         IPolyline polyline = this.inewLineFeedback_0.Stop();
         this.inewLineFeedback_0 = null;
         if (!polyline.IsEmpty)
         {
             IElement element = new LineElement();
             element.Geometry = polyline;
             INewElementOperation newElementOperation = new NewElementOperation();
             newElementOperation.ActiveView  = this._context.ActiveView;
             newElementOperation.ContainHook = this.GetActiveView();
             newElementOperation.Element     = element;
             this._context.OperationStack.Do(newElementOperation);
             //if (this._context.Hook is IApplication)
             //{
             //	if ((this._context.Hook as IApplication).ContainerHook != null)
             //	{
             //		DocumentManager.DocumentChanged((this._context.Hook as IApplication).ContainerHook);
             //	}
             //	else
             //	{
             //		DocumentManager.DocumentChanged((this._context.Hook as IApplication).Hook);
             //	}
             //}
             //else
             //{
             //	DocumentManager.DocumentChanged(this._context.Hook);
             //}
         }
     }
 }
コード例 #15
0
        /// <summary>
        /// 完成新建对象,取得绘制的对象,并添加到图层中
        /// 建议在Map.DblClick或Map.MouseDown(Button = 2)事件中调用本方法
        /// </summary>
        public void NewFeatureEnd()
        {
            IGeometry        pGeom = null;
            IPointCollection pPointCollection;

            try
            {
                if (m_pFeedback is INewMultiPointFeedback)
                {
                    INewMultiPointFeedback pMPFeed = (INewMultiPointFeedback)m_pFeedback;
                    pMPFeed.Stop();
                    pGeom = (IGeometry)m_pPointCollection;
                }
                else if (m_pFeedback is INewLineFeedback)
                {
                    INewLineFeedback pLineFeed = (INewLineFeedback)m_pFeedback;

                    pLineFeed.AddPoint(m_pPoint);
                    IPolyline pPolyLine = pLineFeed.Stop();

                    pPointCollection = (IPointCollection)pPolyLine;
                    if (pPointCollection.PointCount < 2)
                    {
                        MessageBox.Show("至少输入两个节点");
                    }
                    else
                    {
                        pGeom = (IGeometry)pPointCollection;
                    }
                }
                else if (m_pFeedback is INewPolygonFeedback)
                {
                    INewPolygonFeedback pPolyFeed = (INewPolygonFeedback)m_pFeedback;
                    pPolyFeed.AddPoint(m_pPoint);

                    IPolygon pPolygon;
                    pPolygon = pPolyFeed.Stop();
                    if (pPolygon != null)
                    {
                        pPointCollection = (IPointCollection)pPolygon;
                        if (pPointCollection.PointCount < 3)
                        {
                            MessageBox.Show("至少输入三个节点");
                        }
                        else
                        {
                            pGeom = (IGeometry)pPointCollection;
                        }
                    }
                }

                CreateFeature(pGeom);
                m_pFeedback = null;
                m_bInUse    = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
            }
        }
コード例 #16
0
 public override void OnKeyDown(int button, int shift)
 {
     if (button == 27)
     {
         this._lineFeedback = null;
         this._context.ActiveView.Refresh();
         this.lineConstraints = esriLineConstraints.esriLineConstraintsNone;
         this._Point          = null;
     }
     else if (button == 16)
     {
         this.lineConstraints = esriLineConstraints.esriLineConstraintsHorizontal;
         if (this._lineFeedback != null)
         {
             this._lineFeedback.Constraint = esriLineConstraints.esriLineConstraintsHorizontal;
         }
     }
     else if (button == 17)
     {
         this.lineConstraints = esriLineConstraints.esriLineConstraintsVertical;
         if (this._lineFeedback != null)
         {
             this._lineFeedback.Constraint = esriLineConstraints.esriLineConstraintsHorizontal;
         }
     }
 }
コード例 #17
0
        /// <summary>
        /// 设置绘制过程中的线符号
        /// </summary>
        private void SetNewLineFeedBack()
        {
            m_pLineFeedback = new NewLineFeedback();
            IRgbColor pColor = new RgbColor();

            pColor.Red   = 0;
            pColor.Green = 0;
            pColor.Blue  = 0;

            m_LineSym       = new SimpleLineSymbol();
            m_LineSym.Color = pColor;
            m_LineSym.Width = 1;
            m_LineSym.Style = esriSimpleLineStyle.esriSLSSolid;

            ISymbol pSym = m_LineSym as ISymbol;

            pSym.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
            m_pLineFeedback.Symbol = pSym;

            m_hookHelper.ActiveView.ScreenDisplay.StartDrawing(m_hookHelper.ActiveView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            m_hookHelper.ActiveView.ScreenDisplay.SetSymbol(pSym);
            m_hookHelper.ActiveView.ScreenDisplay.FinishDrawing();

            m_pLineFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
        }
コード例 #18
0
        public override void OnDblClick()
        {
            try
            {
                if (_lineFeedback == null)
                {
                    return;
                }
                IPolyline polyline = _lineFeedback.Stop();
                _context.ActiveView.Refresh();
                _lineFeedback = null;
                if (polyline == null)
                {
                    return;
                }

                ISnappingResult snappingResult = _pointSnapper.Snap(polyline.ToPoint);
                if (snappingResult != null)
                {
                    IPointCollection pointCollection = polyline as IPointCollection;
                    pointCollection.UpdatePoint(pointCollection.PointCount - 1, snappingResult.Location);
                }
                CommonHelper.MovePointWithLine(_pointFeature, _lineFeatures, polyline.ToPoint, _tolerance);

                _lineFeedback = null;
                _pointFeature = null;
                _lineFeatures = null;
                _context.ActiveView.Refresh();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
コード例 #19
0
ファイル: mainForm.cs プロジェクト: hehao1999/GIS
 private void MainMapControl_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e)
 {
     if (pMouseOperate == "MeasureLength")
     {
         if (frmMeasureResult != null)
         {
             frmMeasureResult.label2.Text = "线段总长度为:" + dToltalLength + sMapUnits;
         }
         if (pNewLineFeedback != null)
         {
             pNewLineFeedback.Stop();
             pNewLineFeedback = null;
             //清空所画的线对象
             (mainMapControl.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
         }
         dToltalLength  = 0;
         dSegmentLength = 0;
     }
     else if (pMouseOperate == "MeasureArea")
     {
         if (pNewPolygonFeedback != null)
         {
             pNewPolygonFeedback.Stop();
             pNewPolygonFeedback = null;
             //清空所画的线对象
             (mainMapControl.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
         }
         pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //清空点集中所有点
     }
 }
コード例 #20
0
ファイル: SnapEx.cs プロジェクト: 605258778/GISData
 public override void OnClick()
 {
     this._command.OnClick();
     this._cursor       = this._tool.Cursor;
     this._lineFeedback = null;
     this._bStarted     = false;
     this._bFinished    = false;
     this._bMouse       = false;
     try
     {
         IEngineSnapEnvironment engineEditor = Editor.UniqueInstance.EngineEditor as IEngineSnapEnvironment;
         engineEditor.SnapTolerance = 1.0;
         (Editor.UniqueInstance.EngineEditor as IEngineEditEvents_Event).OnSketchModified += (new IEngineEditEvents_OnSketchModifiedEventHandler(this.editEvents_OnSketchModified));
         IHookHelper2      helper           = this._hookHelper as IHookHelper2;
         IExtensionManager extensionManager = helper.ExtensionManager;
         if (extensionManager != null)
         {
             UID nameOrID = new UIDClass {
                 Value = "{E07B4C52-C894-4558-B8D4-D4050018D1DA}"
             };
             IExtension extension = extensionManager.FindExtension(nameOrID);
             this._snappingEnv  = extension as ISnappingEnvironment;
             this._snapFeedback = new SnappingFeedbackClass();
             this._snapFeedback.Initialize(this._hookHelper.Hook, this._snappingEnv, true);
         }
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.SnapEx", "OnClick", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
 }
コード例 #21
0
 private void axMapControl1_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e)  //地图双击
 {
     #region 长度量算
     if (pMouseOperate == "MeasureLength")
     {
         if (frmMeasureResult != null)
         {
             frmMeasureResult.lblMeasureResult.Text = "量测的总路线距离为:" + dToltalLength + sMapUnits;
         }
         if (pNewLineFeedback != null)
         {
             pNewLineFeedback.Stop();
             pNewLineFeedback = null;
             //清空所画的线对象
             (axMapControl1.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
         }
         dToltalLength  = 0;
         dSegmentLength = 0;
     }
     #endregion
     #region 面积量算
     if (pMouseOperate == "MeasureArea")
     {
         if (pNewPolygonFeedback != null)
         {
             pNewPolygonFeedback.Stop();
             pNewPolygonFeedback = null;
             //清空所画的线对象
             (axMapControl1.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
         }
         pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //清空点集中所有点
     }
     #endregion
 }
コード例 #22
0
ファイル: SnapEx.cs プロジェクト: 605258778/GISData
 public void OnKeyDown(int keyCode, int shift)
 {
     if (keyCode == 0x1b)
     {
         this._bMouse = true;
         Editor.UniqueInstance.CancleSketch();
         this._bMouse = false;
         if (this._lineFeedback != null)
         {
             this._lineFeedback.Stop();
         }
         this._lineFeedback = null;
         this._bStarted     = false;
         this._hookHelper.ActiveView.Refresh();
     }
     else if (keyCode == 8)
     {
         Editor.UniqueInstance.OperationStack.Undo();
         Editor.UniqueInstance.LinageShape       = null;
         Editor.UniqueInstance.ReservedLinkShape = null;
     }
     else
     {
         this._tool.OnKeyDown(keyCode, shift);
     }
 }
コード例 #23
0
ファイル: Form1.cs プロジェクト: 15968865116/arcengine
        private void axMapControl1_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e)
        {
            switch (mousedownname)
            {
            case "MeasureLength":
                if (frmMeasureresult != null)
                {
                    frmMeasureresult.label2.Text = "线段总长度为:" + dToltaLength + sMapUnit;
                }
                if (pNewLineFeedback != null)
                {
                    pNewLineFeedback.Stop();
                    pNewLineFeedback = null;
                    //清空线对象
                    axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
                }
                dToltaLength   = 0;
                dSegmentLength = 0;

                break;

            case "MeasureArea":
                if (pNewPolygonFeedback != null)
                {
                    pNewPolygonFeedback.Stop();
                    pNewPolygonFeedback = null;
                    axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); //清空面对象
                }
                pAreaPointCollection.RemovePoints(0, pAreaPointCollection.PointCount);                         //清空点集中所有点


                break;
            }
        }
コード例 #24
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            downPoint = this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            if (button == 1 && ptCount == 0 && m_pNewLineFeedback == null)
            {
                ISimpleLineSymbol pSLnSym;
                m_pNewLineFeedback = new NewLineFeedbackClass();
                pSLnSym            = (ISimpleLineSymbol)m_pNewLineFeedback.Symbol;
                Color  color  = ColorTranslator.FromHtml(SystemInfo.Instance.LineColor);
                IColor pColor = new RgbColorClass();
                pColor.RGB    = color.B * 65536 + color.G * 256 + color.R;
                pSLnSym.Color = pColor;
                pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid;

                m_pNewLineFeedback.Display    = this.m_pMapControl.ActiveView.ScreenDisplay;
                m_pNewLineFeedback.Constraint = esriLineConstraints.esriLineConstraintsVertical;
                m_pNewLineFeedback.Start(downPoint);
                ptCount++;
                mapControlEvents.OnMouseDown -= new IMapControlEvents2_OnMouseDownEventHandler(map2DCommand.OnMouseDown);
                mapControlEvents.OnMouseUp   += new IMapControlEvents2_OnMouseUpEventHandler(map2DCommand.OnMouseUp);
            }
            else if (button == 1 && m_pNewLineFeedback != null && ptCount > 0)
            {
                m_pNewLineFeedback.AddPoint(downPoint);
                ptCount++;
            }
        }
コード例 #25
0
ファイル: CmdCreateLine.cs プロジェクト: frankerlee/Yutai
        public override void OnMouseDown(int button, int shift, int x, int y)
        {
            if (button != 1)
            {
                return;
            }

            IActiveView     activeView     = _context.ActiveView;
            IPoint          point          = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            ISnappingResult snappingResult = _pointSnapper.Snap(point);

            if (snappingResult != null)
            {
                point = snappingResult.Location;
            }

            if (_lineFeedback == null)
            {
                _lineFeedback = new NewLineFeedbackClass()
                {
                    Display = activeView.ScreenDisplay
                };
                _lineFeedback.Start(point);
            }
            else
            {
                _lineFeedback.AddPoint(point);
            }
        }
コード例 #26
0
ファイル: SnapEx.cs プロジェクト: 605258778/GISData
 private void editEvents_OnSketchModified()
 {
     if (!this._bMouse)
     {
         try
         {
             IEngineEditSketch engineEditor = Editor.UniqueInstance.EngineEditor as IEngineEditSketch;
             IPointCollection  geometry     = engineEditor.Geometry as IPointCollection;
             if ((geometry == null) || (geometry.PointCount == 0))
             {
                 if (this._lineFeedback != null)
                 {
                     this._lineFeedback.Stop();
                 }
                 this._lineFeedback = null;
                 this._bStarted     = false;
             }
             if (this._lineFeedback != null)
             {
                 int num = 1;
                 if (engineEditor.GeometryType == esriGeometryType.esriGeometryPolygon)
                 {
                     num = 2;
                 }
                 this._lineFeedback.Stop();
                 this._lineFeedback.Start(geometry.get_Point(geometry.PointCount - num));
             }
         }
         catch (Exception exception)
         {
             this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.SnapEx", "editEvents_OnSketchModified", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         }
     }
 }
コード例 #27
0
        public override void OnMouseDown(int button, int Shift, int x, int y)
        {
            IActiveView activeView = this._context.ActiveView;
            IPoint      mapPoint   = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            if (this._lineFeedback != null)
            {
                if (this._Point != null)
                {
                    if (this.lineConstraints == esriLineConstraints.esriLineConstraintsVertical)
                    {
                        mapPoint.X = this._Point.X;
                    }
                    else if (this.lineConstraints == esriLineConstraints.esriLineConstraintsHorizontal)
                    {
                        mapPoint.Y = this._Point.Y;
                    }
                }
                this._lineFeedback.AddPoint(mapPoint);
                this._Point = mapPoint;
            }
            else
            {
                this._lineFeedback = new NewLineFeedback()
                {
                    Constraint = this.lineConstraints,
                    Display    = activeView.ScreenDisplay
                };
                this._lineFeedback.Start(mapPoint);
                this._Point = mapPoint;
            }
        }
コード例 #28
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            downPoint = this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            if (m_pNewLineFeedback == null)
            {
                ISimpleLineSymbol pSLnSym;
                m_pNewLineFeedback = new NewLineFeedbackClass();
                pSLnSym            = (ISimpleLineSymbol)m_pNewLineFeedback.Symbol;
                Color  color  = ColorTranslator.FromHtml(SystemInfo.Instance.LineColor);
                IColor pColor = new RgbColorClass();
                pColor.RGB = color.B * 65536 + color.G * 256 + color.R;

                pSLnSym.Color = pColor;
                pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid;

                m_pNewLineFeedback.Display = this.m_pMapControl.ActiveView.ScreenDisplay;
                m_pNewLineFeedback.Start(downPoint);
            }
            else
            {
                m_pNewLineFeedback.AddPoint(downPoint);
            }
            m_pRecordPointArray.Add(downPoint);

            base.OnMouseDown(button, shift, x, y, mapX, mapY);
        }
コード例 #29
0
ファイル: SnapEx.cs プロジェクト: 605258778/GISData
 public void OnDblClick()
 {
     this._bStarted  = false;
     this._bFinished = true;
     this._bMouse    = true;
     try
     {
         this._lineFeedback.Stop();
         this._lineFeedback.Refresh(this._hookHelper.ActiveView.ScreenDisplay.hDC);
         this._lineFeedback = null;
         IEngineEditor     engineEditor = Editor.UniqueInstance.EngineEditor;
         IEngineEditSketch sketch       = Editor.UniqueInstance.EngineEditor as IEngineEditSketch;
         IGeometry         pGeo         = sketch.Geometry;
         if (pGeo == null)
         {
             return;
         }
         if ((Editor.UniqueInstance.CheckOverlap && !Editor.UniqueInstance.CheckFeatureOverlap(pGeo, false)) && (XtraMessageBox.Show("要素与其他要素重叠!是否保留此要素?", "", MessageBoxButtons.YesNo) == DialogResult.No))
         {
             Editor.UniqueInstance.CancleSketch();
             this._hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewGeography, null, this._hookHelper.ActiveView.Extent);
             return;
         }
         Editor.UniqueInstance.AddAttribute = true;
         this._tool.OnDblClick();
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.SnapEx", "OnDblClick", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
     this._bMouse = false;
 }
コード例 #30
0
        //回退操作
        private void  Undo()
        {
            if (m_pUndoArray.Count > 1)
            {
                m_pEnvelope = CommonFunction.GetMinEnvelopeOfTheArray(m_pUndoArray);
            }
            else if (m_pUndoArray.Count == 1)
            {
                IPoint pTempPoint = new PointClass();
                pTempPoint.X = (m_pUndoArray.get_Element(0) as Point).X;
                pTempPoint.Y = (m_pUndoArray.get_Element(0) as Point).Y;

                m_pEnvelope.Width  = Math.Abs(m_pPoint.X - pTempPoint.X);
                m_pEnvelope.Height = Math.Abs(m_pPoint.Y - pTempPoint.Y);

                pTempPoint.X = (pTempPoint.X + m_pPoint.X) / 2;
                pTempPoint.Y = (pTempPoint.Y + m_pPoint.Y) / 2;

                m_pEnvelope.CenterAt(pTempPoint);
            }
            if (m_pEnvelope != null && !m_pEnvelope.IsEmpty)
            {
                m_pEnvelope.Expand(10, 10, false);
            }
            ;

            m_pUndoArray.Remove(m_pUndoArray.Count - 1);//删除数组中最后一个点
            m_mouseDownCount--;

            //屏幕刷新
            m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, m_pEnvelope);
            m_pActiveView.ScreenDisplay.UpdateWindow();

            //开始作复位工作
            if (m_pUndoArray.Count != 0)
            {
                CommonFunction.DisplaypSegmentColToScreen(m_MapControl, ref m_pUndoArray);

                m_pLastPoint = (IPoint)m_pUndoArray.get_Element(m_pUndoArray.Count - 1);

                m_pFeedback         = new NewLineFeedbackClass();
                m_pLineFeed         = (NewLineFeedback)m_pFeedback;
                m_pLineFeed.Display = m_pActiveView.ScreenDisplay;
                if (m_pLineFeed != null)
                {
                    m_pLineFeed.Stop();
                }
                m_pLineFeed.Start(m_pLastPoint);

                m_MapControl.ActiveView.GraphicsContainer.DeleteAllElements();
                CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, m_pLastPoint);
                m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_pEnvelope);                //视图刷新
            }
            else
            {  //复位
                m_pFeedback.MoveTo(m_pAnchorPoint);
                Reset();
            }
        }
コード例 #31
0
ファイル: FrmMeasure.cs プロジェクト: lovelll/DQHP
        public void frmMove(ref IPoint pPoint,ref INewLineFeedback m_FeedbackLine )
        {
            if (tbtnLine.Checked == true)
            {
                IPoint pPnt = pPoint;
                m_CurPoint = pPnt;
                if (m_FeedbackLine != null)
                {
                    m_FeedbackLine.MoveTo(pPnt);

                    double MoveLength = 0.0;
                    IPoint m_LastPoint = pCollection.get_Point(pCollection.PointCount - 1);
                    if (m_LastPoint != null)
                    {
                        SegLength = Math.Sqrt(Math.Pow((m_LastPoint.X - m_CurPoint.X),2) + Math.Pow((m_LastPoint.Y - m_CurPoint.Y),2));
                        MoveLength = TotalLength + SegLength;
                    }

                    SegLength = CntUnit.ConvertUnits(SegLength, inUnit.pUnit, outUnit.pUnit);
                    MoveLength = CntUnit.ConvertUnits(MoveLength, inUnit.pUnit, outUnit.pUnit);
                    //单位变换
                    m_SegLen.value = SegLength;
                    m_SegLen.units = outUnit.pUnit;
                    m_TotLen.value = MoveLength;
                    m_TotLen.units = outUnit.pUnit;

                    SegLength = Math.Round(SegLength, 6);
                    MoveLength = Math.Round(MoveLength, 6);
                    double tempSumLen = SumLengths + MoveLength;
                    UnitSumLen = tempSumLen;

                    txtMessage.Text = "测量线"+"\r\n线段的长度是:" + SegLength +outUnit.UnitName + "\r\n总长度是:" + MoveLength+outUnit .UnitName;
                    if(tbtnSum.Checked==true)
                    txtMessage.Text += "\r\n" + "\r\n线段长度之和是:" + tempSumLen+ outUnit.UnitName;
                }
            }
        }
コード例 #32
0
ファイル: FrmMeasure.cs プロジェクト: lovelll/DQHP
        public void frmDbClick(ref INewLineFeedback m_FeedbackLine,ref IGeometry m_Geometry)
        {
            if (tbtnLine.Checked == true)
            {
                if (m_FeedbackLine != null)
                {
                    pGeometry = m_FeedbackLine.Stop();
                    m_Geometry = pGeometry;
                    m_FeedbackLine = null;
                }

                IPolyline pPolyLine = (IPolyline)pGeometry;

                SegLength = LastSeg;
                TotalLength = CntUnit.ConvertUnits(pPolyLine.Length, inUnit.pUnit, outUnit.pUnit);
                SegLength = CntUnit.ConvertUnits(SegLength, inUnit.pUnit, outUnit.pUnit);
                m_SegLen.value = SegLength;
                m_SegLen.units = outUnit.pUnit;
                m_TotLen.value = TotalLength;
                m_TotLen.units = outUnit.pUnit;

                SegLength = Math.Round(SegLength, 6);
                TotalLength = Math.Round(TotalLength, 6);
                SumLengths += TotalLength;
                UnitSumLen = SumLengths;
                txtMessage.Clear();
                txtMessage.Text = "测量线"+"\r\n线段的长度是:" + SegLength+outUnit.UnitName + "\r\n总长度是:" + TotalLength+outUnit.UnitName;
                if(tbtnSum.Checked==true)
                txtMessage.Text+="\r\n"+"\r\n线段长度之和是:"+ SumLengths+outUnit.UnitName;

            }

            //重新初始化
            TotalLength = 0.0;
            SegLength = 0.0;
            TotalAreaLength = 0.0;
            SegAreaLength = 0.0;
            myArea = 0.0;
            Perimeter = 0.0;
            pCollection = new MultipointClass();
            pGeometry = null;
        }
コード例 #33
0
ファイル: MeasureDisTool.cs プロジェクト: lovelll/DQHP
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add MeasureDisTool.OnMouseDown implementation
            frm = GetFrm();
            frm.Show();
            frm.TopMost = true;

            IPoint pPnt;
            IMap pMap = m_hookHelper.FocusMap;
            IActiveView pActView = m_hookHelper.ActiveView;

            if (Button == 1)
            {

               pPnt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

                if (frm.CheckedBtn == 1)
                {
                    if (m_FeedbackLine == null)
                    {
                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
                        m_FeedbackLine = new NewLineFeedbackClass();
                        m_FeedbackLine.Display = m_hookHelper.ActiveView.ScreenDisplay;
                        m_FeedbackLine.Start(pPnt);

                    }
                    else
                        m_FeedbackLine.AddPoint(pPnt);

                    frm.frmLineDown(ref pPnt);
                }

                if (frm.CheckedBtn == 2)
                {
                    if (m_FeedbackPolygon == null)
                    {
                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
                        m_FeedbackPolygon = new NewPolygonFeedbackClass();
                        m_FeedbackPolygon.Display = m_hookHelper.ActiveView.ScreenDisplay;
                        m_FeedbackPolygon.Start(pPnt);
                    }
                    else
                        m_FeedbackPolygon.AddPoint(pPnt);

                    frm.frmAreaDown(ref pPnt);
                }

                if(frm.CheckedBtn==3)
                 frm.frmFeatDown(ref pMap, ref pPnt,pActView);

            }
        }
コード例 #34
0
 /// <summary>
 /// Creates a new geodetic line feedback to visualize the line to the user
 /// </summary>
 /// <param name="point">IPoint, start point</param>
 /// <param name="av">The current active view</param>
 internal void CreateFeedback(IPoint point, IActiveView av)
 {
     ResetFeedback();
     feedback = new NewLineFeedback();
     var geoFeedback = feedback as IGeodeticLineFeedback;
     geoFeedback.GeodeticConstructionMethod = GetEsriGeodeticType();
     geoFeedback.UseGeodeticConstruction = true;
     geoFeedback.SpatialReference = point.SpatialReference;
     var displayFB = feedback as IDisplayFeedback;
     displayFB.Display = av.ScreenDisplay;
 }
コード例 #35
0
 //����
 public void Recycle()
 {
     m_NewLineFeedback = null;
     m_ptColl.RemovePoints(0, m_ptColl.PointCount);
     m_ptColl = null;
     m_TraceLine = null;//20140218 lyf
     m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, m_hookHelper.ActiveView.Extent);
 }
コード例 #36
0
        public void EndFeedBack()
        {
            m_schematicFeature1 = null;
            m_schematicFeature2 = null;
            
            if (m_dockableDigit != null)
            {
                m_dockableDigit.SchematicFeature1(m_schematicFeature1);
                m_dockableDigit.SchematicFeature2(m_schematicFeature2);
            }

            if (m_linkFbk != null)
            {
                m_linkFbk.Stop();
                m_linkFbk = null;
            }
        }
コード例 #37
0
ファイル: SelectPoint.cs プロジェクト: chinasio/minegis
        public override void OnDblClick()
        {
            newItem.SubItems.Add(toPoint.X.ToString("f3"));
            newItem.SubItems.Add(toPoint.Y.ToString("f3"));
            frmAdjPoint.ToPoint.AddPoint(toPoint, ref obj, ref obj);

            IGeometry pGeom;
            pGeom = pLineFeedback.Stop();
            pLineFeedback = null;
            AddLineElement(pGeom, pGraphicsContainer);
            frmAdjPoint.ListPoint.Items.Add(newItem);
            pointCount++;
            //clickCount = 0;
            newItem = null;
        }
コード例 #38
0
ファイル: MeasureDisTool.cs プロジェクト: lovelll/DQHP
        public override void OnKeyDown(int keyCode, int Shift)
        {
            if (keyCode == (int)Keys.Escape)
            {
                if (m_FeedbackLine != null)
                {
                    m_FeedbackLine.Stop();
                    m_FeedbackLine = null;
                }

                if (m_FeedbackPolygon != null)
                {
                    m_FeedbackPolygon.Stop();
                    m_FeedbackPolygon = null;
                }
                m_Geometry = null;
            }
        }
コード例 #39
0
        /// <summary>
        /// Resets feedback aka cancels feedback
        /// </summary>
        internal void ResetFeedback()
        {
            if (feedback == null)
                return;

            feedback.Stop();
            feedback = null;
        }
コード例 #40
0
ファイル: SelectPoint.cs プロジェクト: chinasio/minegis
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add SelectPoint.OnMouseDown implementation

            pActiveView = m_hookHelper.ActiveView;
            pMap = m_hookHelper.FocusMap;
            pGraphicsContainer = pMap as IGraphicsContainer;
            IPoint pPt = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X,
            Y);

            if (newItem==null)
            {
                newItem = new ListViewItem(pointCount.ToString());
                newItem.SubItems.Add(pPt.X.ToString("f3"));
                newItem.SubItems.Add(pPt.Y.ToString("f3"));
                frmAdjPoint.FromPoint.AddPoint(pPt, ref obj, ref obj);
            }

            /*if (clickCount == 2&&newItem.SubItems.Count<=4)
            {
                newItem.SubItems.Add(pPt.X.ToString("f3"));
                newItem.SubItems.Add(pPt.Y.ToString("f3"));
                frmAdjPoint.ToPoint.AddPoint(pPt, ref obj, ref obj);
                clickCount++;
            }*/

            AddPointElement((IGeometry)pPt, pGraphicsContainer);

            if (pLineFeedback == null)
            {
                pLineFeedback = new NewLineFeedbackClass();
                pLineFeedback.Display = pActiveView.ScreenDisplay;
                pLineFeedback.Start(pPt);
            }
            else
            {
                pLineFeedback.AddPoint(pPt);
            }
        }
コード例 #41
0
ファイル: ToolMeasureLength.cs プロジェクト: hy1314200/HyDM
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            //���ӵ����Ҽ��������� �ᄃ���20081028
            if (Button == 2)
            {
                OnDblClick();
                return;
            }

            IActiveView ipAV = this.m_hookHelper.ActiveView;

            //�����µ�
            IPoint ipPt = new PointClass();
            ipPt = ipAV.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            SnapPoint(ipPt);
            //�����ʾ����
            //if (this.m_FormDis == null)
            //{
            //    this.m_FormDis = new FormDis(MeasureType.Length, this);
            //    this.m_FormDis.TopMost = true;
            //    this.m_FormDis.Show();
            //    this.m_FormDis.WriteLabelText(null);
            //}

            if (this.m_GeoMeasure == null)
            {
                m_pNewLineFeed = new NewLineFeedbackClass();
                IScreenDisplay pScreen = ipAV.ScreenDisplay;
                m_pNewLineFeed.Display = pScreen;
                m_pNewLineFeed.Start(ipPt);

                this.m_GeoMeasure = new PolylineClass();

            }
            else
            {
                m_pNewLineFeed.AddPoint(ipPt);
            }

            ////����ʵ��
            //if (this.m_GeoMeasure == null)
            //{
            //    this.m_GeoMeasure = new PolylineClass();
            //    ISegmentCollection ipSegCol = this.m_GeoMeasure as ISegmentCollection;
            //    ILine ipLine = new LineClass();
            //    ipLine.PutCoords(ipPt, ipPt);
            //    object obj = Type.Missing;
            //    ipSegCol.AddSegment(ipLine as ISegment, ref obj, ref obj);
            //}
            //else
            //{
            //    ISegmentCollection ipSegCol = this.m_GeoMeasure as ISegmentCollection;
            //    ILine ipLine = new LineClass();
            //    ipLine.PutCoords(ipSegCol.get_Segment(ipSegCol.SegmentCount - 1).ToPoint, ipPt);
            //    object obj = Type.Missing;
            //    ipSegCol.AddSegment(ipLine as ISegment, ref obj, ref obj);
            //}

            ////////////////////��ʾ/////////////////////
            //this.m_Element.Geometry = this.m_GeoMeasure;
            ////�ֲ�ˢ��
            //ipAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, this.m_GeoMeasure, null);
            ////ipAV.Refresh();

            ////ESRI.ArcGIS.esriSystem.IClone ipClone = this.m_GeoMeasure as ESRI.ArcGIS.esriSystem.IClone;
            ////IGeometry ipGeoCopy = ipClone.Clone() as IGeometry;
            ////this.m_FormDis.WriteLabelText(ipGeoCopy);
        }
コード例 #42
0
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            bool abortOperation = false;
            ESRI.ArcGIS.Schematic.ISchematicOperation schematicOperation = null;

            try
            {
                if (m_dockableDigit == null)
                    return;

                if (arg != null)
                {
                    m_x = arg.X;
                    m_y = arg.Y;
                }

                if (m_dockableWindow == null)
                    return;

                if (m_dockableWindow.IsVisible() == false)
                {
                    m_dockableWindow.Show(true);
                }

                ESRI.ArcGIS.SchematicControls.ISchematicTarget target = (ESRI.ArcGIS.SchematicControls.ISchematicTarget)m_schematicExtension;

                if (target != null)
                    m_schematicLayer = target.SchematicTarget;

                if (m_schematicLayer == null)
                {
                    System.Windows.Forms.MessageBox.Show("No target Layer");
                    return;
                }

                ISchematicInMemoryDiagram inMemoryDiagram;
                ISchematicInMemoryFeatureClass schematicInMemoryFeatureClass;
                ISchematicInMemoryFeatureClassContainer schematicInMemoryFeatureClassContainer;

                //Get the point
                ESRI.ArcGIS.Geometry.Point point = new ESRI.ArcGIS.Geometry.Point();

                ESRI.ArcGIS.ArcMapUI.IMxApplication mxApp;
                ESRI.ArcGIS.Display.IAppDisplay appDisplay;
                IScreenDisplay screenDisplay;
                IDisplay display;
                IDisplayTransformation transform;
                ISpatialReference spatialReference;

                inMemoryDiagram = m_schematicLayer.SchematicInMemoryDiagram;
                schematicInMemoryFeatureClassContainer = (ISchematicInMemoryFeatureClassContainer)inMemoryDiagram;

                if (schematicInMemoryFeatureClassContainer == null)
                    return;

                mxApp = (ESRI.ArcGIS.ArcMapUI.IMxApplication)m_app;

                if (mxApp == null)
                    return;

                appDisplay = mxApp.Display;

                if (appDisplay == null)
                    return;

                screenDisplay = appDisplay.FocusScreen;
                display = screenDisplay;

                if (display == null)
                    return;

                transform = display.DisplayTransformation;

                if (transform == null)
                    return;

                spatialReference = transform.SpatialReference;

                WKSPoint mapPt = new WKSPoint();
                ESRI.ArcGIS.Display.tagPOINT devPoint;
                devPoint.x = m_x;
                devPoint.y = m_y;
                transform.TransformCoords(ref mapPt, ref devPoint, 1, 1); //'esriTransformToMap

                point.SpatialReference = spatialReference;
                point.Project(spatialReference);
                point.X = mapPt.X;
                point.Y = mapPt.Y;

                schematicInMemoryFeatureClass = schematicInMemoryFeatureClassContainer.GetSchematicInMemoryFeatureClass(m_dockableDigit.FeatureClass());

                if (schematicInMemoryFeatureClass == null)
                {
                    System.Windows.Forms.MessageBox.Show("Invalid Type.");
                    return;
                }

                if (m_dockableDigit.CreateNode())
                {
                    //TestMandatoryField
                    m_dockableDigit.btnOKPanel1.Visible = false;

                    if (m_dockableDigit.ValidateFields() == false)
                    {
                        m_dockableDigit.x(m_x);
                        m_dockableDigit.y(m_y);

                        System.Windows.Forms.MessageBox.Show(m_dockableDigit.ErrorProvider1.GetError(m_dockableDigit.btnOKPanel1) + m_messageFromOK);
                        return;
                    }

                    ESRI.ArcGIS.Geometry.IGeometry geometry;

                    ISchematicInMemoryFeature schematicInMemoryFeatureNode;

                    geometry = point;

                    schematicOperation = (ESRI.ArcGIS.Schematic.ISchematicOperation) new ESRI.ArcGIS.SchematicControls.SchematicOperation();

                    //digit operation is undo(redo)able we add it in the stack
                    IMxDocument doc  = (IMxDocument)m_app.Document;
                    ESRI.ArcGIS.SystemUI.IOperationStack operationStack; 
                    operationStack = doc.OperationStack;
                    operationStack.Do(schematicOperation);
                    schematicOperation.StartOperation("Digit", m_app, m_schematicLayer, true);

                    //do abort operation
                    abortOperation = true;

                    schematicInMemoryFeatureNode = schematicInMemoryFeatureClass.CreateSchematicInMemoryFeatureNode(geometry, "");
                    //schematicInMemoryFeatureNode.UpdateStatus = esriSchematicUpdateStatus.esriSchematicUpdateStatusNew; if we want the node deleted after update
                    schematicInMemoryFeatureNode.UpdateStatus = esriSchematicUpdateStatus.esriSchematicUpdateStatusLocked;

                    abortOperation = false;
                    schematicOperation.StopOperation();

                    ISchematicFeature schematicFeature = schematicInMemoryFeatureNode;
                    m_dockableDigit.FillValue(ref schematicFeature);

                    if (m_dockableDigit.AutoClear())
                        m_dockableDigit.SelectionChanged();
                }
                else
                {
                    m_dockableDigit.btnOKPanel2.Visible = false;

                    //Get the Tolerance of ArcMap
                    Double tolerance;
                    IMxDocument mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)m_app.Document;
                    ESRI.ArcGIS.esriSystem.WKSPoint point2 = new WKSPoint();
                    ESRI.ArcGIS.Display.tagPOINT devPt;

                    tolerance = mxDocument.SearchTolerancePixels;
                    devPt.x = (int)tolerance;
                    devPt.y = (int)tolerance;

                    transform.TransformCoords(ref point2, ref devPt, 1, 2);//2 <-> esriTransformSize 4 <-> esriTransformToMap

                    tolerance = point2.X * 5;//increase the tolerance value

                    IEnumSchematicFeature schematicFeatures = m_schematicLayer.GetSchematicFeaturesAtPoint(point, tolerance, false, true);

                    ISchematicFeature schematicFeatureSelected = null;
                    double distancetmp;
                    double distance = 0;
                    schematicFeatures.Reset();

                    if (schematicFeatures.Count <= 0)
                        return;

                    //pSchematicFeatures may contain several features, we are choosing the closest node.
                    ISchematicFeature schematicFeature2 = schematicFeatures.Next();

                    double dX;
                    double dY;
                    ISchematicInMemoryFeatureNode schematicInMemoryFeatureNode =  null;
                    if (schematicFeature2 != null)
                    {
                        if (schematicFeature2.SchematicElementClass.SchematicElementType == ESRI.ArcGIS.Schematic.esriSchematicElementType.esriSchematicNodeType)
                            schematicInMemoryFeatureNode = (ISchematicInMemoryFeatureNode)schematicFeature2;
                    }
                                        
                    ISchematicInMemoryFeatureNodeGeometry schematicInMemoryFeatureNodeGeometry = (ISchematicInMemoryFeatureNodeGeometry)schematicInMemoryFeatureNode;
                    dX = schematicInMemoryFeatureNodeGeometry.Position.X;
                    dY = schematicInMemoryFeatureNodeGeometry.Position.Y;
                    schematicFeatureSelected = schematicFeature2;
                    distance = SquareDistance(dX - point.X, dY - point.Y);

                    while (schematicFeature2 != null)
                    {
                        //find the closest featureNode...
                        if (schematicInMemoryFeatureNode != null)
                        {
                            schematicInMemoryFeatureNodeGeometry = (ISchematicInMemoryFeatureNodeGeometry) schematicInMemoryFeatureNode;

                            if (schematicInMemoryFeatureNodeGeometry == null)
                                continue;

                            dX = schematicInMemoryFeatureNodeGeometry.Position.X;
                            dY = schematicInMemoryFeatureNodeGeometry.Position.Y;
                            distancetmp = SquareDistance(dX - point.X, dY - point.Y);
                            
                            if (distancetmp < distance)
                            {
                                distance = distancetmp;
                                schematicFeatureSelected = schematicFeature2;
                            }
                        }

                        schematicFeature2 = schematicFeatures.Next();
                        
                        if (schematicFeature2 != null)
                        {
                            if (schematicFeature2.SchematicElementClass.SchematicElementType == ESRI.ArcGIS.Schematic.esriSchematicElementType.esriSchematicNodeType)
                                schematicInMemoryFeatureNode = (ISchematicInMemoryFeatureNode)schematicFeature2;
                        }
                    }
                    
                    if (schematicFeatureSelected == null)
                        return;

                    if (schematicFeatureSelected.SchematicElementClass.SchematicElementType != esriSchematicElementType.esriSchematicNodeType)
                        return;

                    if (m_schematicFeature1 == null)
                    {
                        m_schematicFeature1 = schematicFeatureSelected;
                        m_dockableDigit.SchematicFeature1(m_schematicFeature1);

                        if (!m_dockableDigit.CheckValidFeature(true))
                        {
                            m_schematicFeature1 = null;
                            m_dockableDigit.SchematicFeature1(m_schematicFeature1);
                            throw new Exception("Invalid starting node for this link type");
                        }

                        //Begin Feedback 
                        m_linkFbk = new NewLineFeedback();
                        m_linkFbk.Display = screenDisplay;

                        //symbol
                        ISimpleLineSymbol sLnSym;
                        IRgbColor rGB = new RgbColor();

                        sLnSym = (ESRI.ArcGIS.Display.ISimpleLineSymbol)m_linkFbk.Symbol;

                        //Make a color
                        rGB.Red = 255;
                        rGB.Green = 0;
                        rGB.Blue = 0;

                        // Setup the symbol with color and style
                        sLnSym.Color = rGB;

                        m_linkFbk.Start(point);
                        //End Feedback

                        //To know if we are in the same diagram.
                        m_schematicLayerForLink = m_schematicLayer;
                    }
                    else
                    {
                        if (m_schematicLayerForLink != m_schematicLayer)
                        {
                            System.Windows.Forms.MessageBox.Show("wrong Target layer");
                            m_schematicLayerForLink = null;
                            EndFeedBack();
                            return;
                        }
                        m_schematicFeature2 = schematicFeatureSelected;
                        m_dockableDigit.SchematicFeature2(m_schematicFeature2);

                        //TestMandatoryField
                        if (m_dockableDigit.ValidateFields() == false)
                        {
                            m_dockableDigit.x(m_x);
                            m_dockableDigit.y(m_y);

                            System.Windows.Forms.MessageBox.Show(m_dockableDigit.ErrorProvider1.GetError(m_dockableDigit.btnOKPanel2) + m_messageFromOK);
                            return;
                        }

                        if (!m_dockableDigit.CheckValidFeature(false))
                        {
                            m_schematicFeature2 = null;
                            m_dockableDigit.SchematicFeature2(m_schematicFeature2);
                            throw new Exception("Invalid End node for this link type");
                        }

                        //CreateLink
                        ISchematicInMemoryFeature schematicInMemoryFeatureLink;

                        schematicOperation = (ESRI.ArcGIS.Schematic.ISchematicOperation) new ESRI.ArcGIS.SchematicControls.SchematicOperation();

                        //digit operation is undo(redo)able we add it in the stack
                        IMxDocument doc  = (IMxDocument)m_app.Document;
                        ESRI.ArcGIS.SystemUI.IOperationStack operationStack; 
                        operationStack = doc.OperationStack;
                        operationStack.Do(schematicOperation);
                        schematicOperation.StartOperation("Digit", m_app, m_schematicLayer, true);

                        //do abort operation
                        abortOperation = true;

                        schematicInMemoryFeatureLink = schematicInMemoryFeatureClass.CreateSchematicInMemoryFeatureLink((ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode)m_schematicFeature1, (ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode)m_schematicFeature2, "");
                        //schematicInMemoryFeatureLink.UpdateStatus = esriSchematicUpdateStatus.esriSchematicUpdateStatusNew; if we want the node deleted after update
                        schematicInMemoryFeatureLink.UpdateStatus = esriSchematicUpdateStatus.esriSchematicUpdateStatusLocked;

                        abortOperation = false;
                        schematicOperation.StopOperation();

                        ISchematicFeature schematicFeature = schematicInMemoryFeatureLink;
                        m_dockableDigit.FillValue(ref schematicFeature);

                        //End Feedback
                        EndFeedBack();

                        m_schematicLayerForLink = null;

                        if (m_dockableDigit.AutoClear())
                            m_dockableDigit.SelectionChanged();

                    }
                }

                //Refresh the view and viewer windows
                RefreshView();
            }
            catch (System.Exception e)
            {
                if (abortOperation && (schematicOperation != null))
                    schematicOperation.AbortOperation();

                EndFeedBack();
                System.Windows.Forms.MessageBox.Show(e.Message);
            }

            return;
        }
コード例 #43
0
ファイル: AddArc.cs プロジェクト: ismethr/gas-geological-map
        /// <summary>
        /// ���û��ƹ����е��߷���
        /// </summary>
        private void SetNewLineFeedBack()
        {
            m_pLineFeedback = new NewLineFeedback();
            IRgbColor pColor = new RgbColor();
            pColor.Red = 0;
            pColor.Green = 0;
            pColor.Blue = 0;

            m_LineSym = new SimpleLineSymbol();
            m_LineSym.Color = pColor;
            m_LineSym.Width = 1;
            m_LineSym.Style = esriSimpleLineStyle.esriSLSSolid;

            ISymbol pSym = m_LineSym as ISymbol;
            pSym.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
            m_pLineFeedback.Symbol = pSym;

            m_hookHelper.ActiveView.ScreenDisplay.StartDrawing(m_hookHelper.ActiveView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            m_hookHelper.ActiveView.ScreenDisplay.SetSymbol(pSym);
            m_hookHelper.ActiveView.ScreenDisplay.FinishDrawing();

            m_pLineFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
        }
コード例 #44
0
ファイル: ToolMeasureLength.cs プロジェクト: hy1314200/HyDM
 public override void OnKeyDown(int keyCode, int Shift)
 {
     if (keyCode.Equals(27))
     {
         m_GeoMeasure = null;
         m_pNewLineFeed = null;
         m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, m_hookHelper.ActiveView.Extent);
     }
 }
コード例 #45
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 2)
                return;
            IPoint pt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            pt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pt);
            IGraphicsContainer g = m_hookHelper.ActiveView.GraphicsContainer;
            IEnvelope pEnvBounds = null;

            //��ȡ��һ�ι켣�ߵķ�Χ,�Ա�ȷ��ˢ�·�Χ
            try
            {
                if (m_TraceLine != null)
                {
                    m_TraceLine.QueryEnvelope(pEnvBounds);
                    pEnvBounds.Expand(4, 4, true); //���ο�����������4��(����2������),Ŀ����Ϊ�˱�֤�г����ˢ������
                }
                else
                    pEnvBounds = m_hookHelper.ActiveView.Extent;
            }
            catch
            {
                pEnvBounds = m_hookHelper.ActiveView.Extent;
            }

            #region �������
            if (m_NewLineFeedback == null)
            {
                //�Ƴ�element
                RemoveElements();
                //ˢ��
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                Application.DoEvents();

                m_NewLineFeedback = new NewLineFeedbackClass();
                m_NewLineFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
                //�����ȵõ�symbol,������symbol
                ISimpleLineSymbol simpleLineSymbol = m_NewLineFeedback.Symbol as ISimpleLineSymbol;
                simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                simpleLineSymbol.Width = 2;
                simpleLineSymbol.Color = TransColorToAEColor(Color.Blue);

                m_NewLineFeedback.Start(pt);
            }
            else
            {
                m_NewLineFeedback.AddPoint(pt);
            }

            if (m_ptColl == null)
            {
                m_ptColl = new PolylineClass();
            }
            //��¼�ڵ�
            object obj = Type.Missing;
            m_ptColl.AddPoint(pt, ref obj, ref obj);

            #endregion

            #region ���ƽ��

            try
            {
                IElement vertexElement = createElement_x(pt);
                //
                g = m_hookHelper.ActiveView as IGraphicsContainer;

                //g.AddElement(vertexElement, 0);
                //g.MoveElementToGroup(vertexElement, m_VertexElement);

                m_VertexElement.AddElement(vertexElement);
                //ˢ��
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, vertexElement, pEnvBounds);

            }
            catch
            { }
            #endregion

            try
            {
                if (m_ptColl.PointCount >= 2)
                {
                    IPoint fromPt = m_ptColl.get_Point(m_ptColl.PointCount - 2); //�����ڶ�����
                    IPoint toPt = m_ptColl.get_Point(m_ptColl.PointCount - 1); //����һ����
                    ILine line = new LineClass();
                    line.PutCoords(fromPt, toPt);

                    #region ���ƹ켣��

                    try
                    {
                        object missing = Type.Missing;
                        ISegmentCollection segColl = new PolylineClass();
                        segColl.AddSegment(line as ISegment, ref missing, ref missing);
                        IElement traceElement = createElement_x(segColl as IPolyline);
                        //
                        g = m_hookHelper.ActiveView as IGraphicsContainer;

                        //g.AddElement(traceElement, 0);
                        //g.MoveElementToGroup(traceElement, m_TraceElement);

                        m_TraceElement.AddElement(traceElement);

                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, traceElement, pEnvBounds);

                    }
                    catch
                    { }
                    #endregion

                    #region ���㵥�ߵij���,���������ʾ�ڵ����е�ƫ������
                    try
                    {
                        double angle = line.Angle;
                        if ((angle > (Math.PI / 2) && angle < (Math.PI)) || (angle > -Math.PI && angle < -(Math.PI / 2))) // ����90��С�ڵ���180
                            angle += Math.PI;

                        //��ע��Yֵƫ����
                        double d_OffsetY = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.FromPoints(9);

                        //��ע��

                        double d_CenterX = (fromPt.X + toPt.X) / 2;
                        double d_CenterY = (fromPt.Y + toPt.Y) / 2 + d_OffsetY; //����ƫ��

                        IPoint labelPt = new PointClass();
                        labelPt.PutCoords(d_CenterX, d_CenterY);
                        IUnitConverter unitConverter = new UnitConverterClass();
                        double segmentLength = unitConverter.ConvertUnits(line.Length, _MsgInfo.inUnit.pUnit, _MsgInfo.outUnit.pUnit);
                        ITextElement txtElement = CreateTextElement(segmentLength.ToString("0.00"));

                        IElement labelelement = txtElement as IElement;
                        labelelement.Geometry = labelPt;
                        object oElement = (object)labelelement;

                        //���ݽǶ���ת
                        TransformByRotate(ref oElement, labelPt, angle);

                        ////��ӵ�GraphicsContainer
                        //g.AddElement(labelelement, 0);

                        ////�Ƶ�m_LabelElement����
                        //g.MoveElementToGroup(labelelement, m_LabelElement);

                        //��ӵ���
                        m_LabelElement.AddElement(labelelement);

                        //ˢ��

                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, labelelement, pEnvBounds);
                    }
                    catch
                    { }
                    #endregion
                }

            }
            catch
            { }

            _MsgInfo.LineResultChange();
        }
コード例 #46
0
ファイル: AddArc.cs プロジェクト: ismethr/gas-geological-map
 public override void OnKeyDown(int keyCode, int Shift)
 {
     if (keyCode == (int)Keys.Escape)
     {
         m_pLineFeedback = null;
         m_lMouseDownCount = 0;
         m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
     }
 }