Пример #1
0
        public override void OnMouseMove(int button, int shift, int x, int y, double mapX, double mapY)
        {
            // TODO:  添加 DrawRectSide2P.OnMouseMove 实现
            base.OnMouseMove(button, shift, x, y, mapX, mapY);

            m_pPoint = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            m_pAnchorPoint = m_pPoint;
            //+++++++++++++开始捕捉+++++++++++++++++++++
            //CommonFunction.Snap(m_MapControl,m_App.CurrentConfig.cfgSnapEnvironmentSet,(IGeometry)m_pLastPoint,m_pAnchorPoint);

            if (m_bInUse == true)
            {
                if (m_mouseDownCount == 1) //计数器=1时
                {
                    m_pPoint = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

                    m_pAnchorPoint = m_pPoint;

                    m_pFeedback.MoveTo(m_pAnchorPoint);
                }
                else if (m_mouseDownCount == 2)
                {
                    m_pLineFeed.Stop();

                    //if(m_bFixDirection && m_bInputWindowCancel == false)  //固定m_pAnchorPoint使其在一个固定方向上
                    //{
                    //    m_pPoint = Class.Common.GetTwoPoint_FormPointMousePointFixDirection(m_pLastPoint,m_pPoint,m_dblFixDirection);
                    //    m_pAnchorPoint = m_pPoint;
                    //}

                    if (!m_bFixSideLength)                      //获取矩形一边长
                    {
                        m_dblSideLength = Class.Common.GetRectangleOfSide_Length((IPoint)m_pUndoArray.get_Element(0), (IPoint)m_pUndoArray.get_Element(1), m_pAnchorPoint);
                    }
                    //else if (m_bInputWindowCancel == false)//按S键,用户输入边长,修正m_dblSideLength值
                    //{
                    //    bool bRight;//判断鼠标是否位于P1到P2方向的右边
                    //    bRight = CommonFunction.GetRectP0_Right((IPoint)m_pUndoArray.get_Element(0), (IPoint)m_pUndoArray.get_Element(1),m_pAnchorPoint);
                    //    if (bRight) m_dblSideLength = - m_dblSideLength;//对输入值反号
                    //}

                    //获取矩形另两点坐标
                    m_pSavePointArray.RemoveAll();
                    m_pSavePointArray = Class.Common.GetPointRectangle2((IPoint)m_pUndoArray.get_Element(0), (IPoint)m_pUndoArray.get_Element(1), m_dblSideLength);

                    Class.Common.DisplaypSegmentColToScreen(m_MapControl, ref m_pUndoArray);
                    //绘制矩形
                    m_pLineFeed.Start((IPoint)m_pUndoArray.get_Element(1));
                    m_pLineFeed.AddPoint((IPoint)m_pSavePointArray.get_Element(0));
                    m_pLineFeed.AddPoint((IPoint)m_pSavePointArray.get_Element(1));
                    m_pLineFeed.AddPoint((IPoint)m_pUndoArray.get_Element(0));

                    m_pSavePointArray.Add((IPoint)m_pUndoArray.get_Element(0));
                    m_pSavePointArray.Add((IPoint)m_pUndoArray.get_Element(1));
                    m_pSavePointArray.Add((IPoint)m_pSavePointArray.get_Element(0));
                }//m_mouseDownCount == 2
            }
        }
Пример #2
0
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     if (m_hookHelper != null)
     {
         if (Button == 1)
         {
             m_blnInMouseDown = true;
             m_pPoint         = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
             //此处可能要加m_blnSnap=false;
             if (m_pNewLineFeedback == null)
             {
                 m_pNewLineFeedback         = new NewLineFeedback();
                 m_pNewLineFeedback.Display = m_pScreenDisplay;
                 m_douTotal = 0d;
                 if (m_blnSnap == true)
                 {
                     m_pNewLineFeedback.Start(m_pSnapPoint);
                 }
                 else
                 {
                     m_pNewLineFeedback.Start(m_pPoint);
                 }
             }
             else
             {
                 if (m_blnSnap == true)
                 {
                     m_pNewLineFeedback.AddPoint(m_pSnapPoint);
                 }
                 else
                 {
                     m_pNewLineFeedback.AddPoint(m_pPoint);
                 }
             }
             m_pGeometry = m_pPoint;
             if (m_douDistance != 0d)
             {
                 m_douTotal = m_douTotal + m_douDistance;
             }
         }
         else if (Button == 2)
         {
             m_blnInMouseDown = false;
         }
     }
     else if (m_sceneHookHelper != null)
     {
     }
     else if (m_globeHookHelper != null)
     {
     }
 }
Пример #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
        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);*/
        }
Пример #5
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);
        }
        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++;
            }
        }
Пример #7
0
        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);
            }
        }
Пример #8
0
        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");
                }
            }
        }
Пример #9
0
        //鼠标在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);
            }
        }
Пример #10
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();
            }
        }
Пример #11
0
        private void CalculateCornerMouseDown(IPoint pPoint)
        {
            IGeometry pGeom = null;

            if (!m_bInUse)            //如果命令没有使用
            {
                     m_pPoint1 = pPoint;
                m_pLastPoint = pPoint;
                m_pRecordPointArray.Add(m_pPoint1);
                m_bInUse = true;

                m_pFeedback = new NewLineFeedbackClass();
                m_pLineFeed = (INewLineFeedback)m_pFeedback;
                m_pLineFeed.Start(pPoint);
                if (m_pFeedback != null)
                {
                    m_pFeedback.Display = m_pActiveView.ScreenDisplay;
                }

                CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, m_pPoint1);
            }
            else             //如果命令正在使用
            {
                m_pPoint2 = pPoint;
                m_pRecordPointArray.Add(pPoint);
                m_bInUse = true;

                m_pLineFeed.AddPoint(pPoint);

                CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, m_pPoint2);
                if (m_pRecordPointArray.Count > 2)
                {
                    IPolyline pPolyline;
                    pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray);
                    pGeom     = (IGeometry)pPolyline;
                    CommonFunction.AddElement(m_MapControl, pGeom);

                    double dblZimuth = CommonFunction.GetAngleZuo_P123(m_pPoint1, (IPoint)m_pRecordPointArray.get_Element(1), m_pPoint2);
                    dblZimuth = CommonFunction.RadToDeg(dblZimuth);

                    System.Windows.Forms.DialogResult result;
                    string strResult = "三点夹角:" + dblZimuth.ToString(".#####") + "(°′″)";
                    strResult = strResult + CRLF;
                    strResult = strResult + "第一点坐标 X=" + m_pPoint1.X.ToString(".###") + "Y=" + m_pPoint1.Y.ToString(".###");
                    strResult = strResult + CRLF;
                    strResult = strResult + "第二点坐标 X=" + ((IPoint)m_pRecordPointArray.get_Element(1)).X.ToString(".###") + "Y=" + ((IPoint)m_pRecordPointArray.get_Element(1)).Y.ToString(".###");
                    strResult = strResult + CRLF;
                    strResult = strResult + "第三点坐标 X=" + m_pPoint2.X.ToString(".###") + "Y=" + m_pPoint2.Y.ToString(".###");

                    result = MessageBox.Show(strResult, "三点夹角计算", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (result == DialogResult.OK)
                    {
                        Reset();                        //复位;
                    }
                }
            }
        }
Пример #12
0
        /// <summary>
        /// Handler for the new map point click event
        /// </summary>
        /// <param name="obj">IPoint</param>
        internal virtual void OnNewMapPointEvent(object obj)
        {
            if (!IsActiveTab)
            {
                return;
            }

            var mxdoc = ArcMap.Application.Document as IMxDocument;
            var av    = mxdoc.FocusMap as IActiveView;
            var point = obj as IPoint;

            if (point == null)
            {
                return;
            }

            if (!HasPoint1)
            {
                // clear temp graphics
                ClearTempGraphics();
                Point1          = point;
                HasPoint1       = true;
                Point1Formatted = string.Empty;

                AddGraphicToMap(Point1, true);

                // lets try feedback
                CreateFeedback(point, av);
                feedback.Start(point);
            }
            else if (!HasPoint2)
            {
                ResetFeedback();
                Point2          = point;
                HasPoint2       = true;
                point2Formatted = string.Empty;
                RaisePropertyChanged(() => Point2Formatted);
            }

            if (HasPoint1 && HasPoint2)
            {
                CreateMapElement();
                ResetPoints();
            }
        }
Пример #13
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add CreatShape.OnMouseDown implementation
            if (Button == 1)
            {
                IFeatureLayer m_FeatureLayer = (IFeatureLayer)m_CurrentLayer;
                if (m_FeatureLayer.FeatureClass == null)
                {
                    return;
                }

                IActiveView m_ActiveView     = m_hookHelper.ActiveView;
                IPoint      m_PointMousedown = m_ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                m_PointStop = m_PointMousedown;
                if (!m_bInUse)
                {
                    switch (m_FeatureLayer.FeatureClass.ShapeType)
                    {
                    case esriGeometryType.esriGeometryPoint:          //点类型
                        CreatFeature(m_PointMousedown);
                        m_hookHelper.ActiveView.Refresh();
                        break;

                    case esriGeometryType.esriGeometryPolyline:        //线类型
                        m_bInUse   = true;
                        m_Feedback = new NewLineFeedback();
                        INewLineFeedback m_LineFeed = (INewLineFeedback)m_Feedback;
                        m_LineFeed.Start(m_PointMousedown);
                        break;

                    case esriGeometryType.esriGeometryPolygon:
                        m_bInUse   = true;
                        m_Feedback = new NewPolygonFeedback();
                        INewPolygonFeedback m_PolyFeed = (INewPolygonFeedback)m_Feedback;
                        m_PolyFeed.Start(m_PointMousedown);
                        break;
                    }
                    if (m_Feedback != null)
                    {
                        m_Feedback.Display = m_ActiveView.ScreenDisplay;
                    }
                }
                else
                {
                    if (m_Feedback is INewLineFeedback)
                    {
                        INewLineFeedback m_LineFeed = (INewLineFeedback)m_Feedback;
                        m_LineFeed.AddPoint(m_PointMousedown);
                    }
                    else if (m_Feedback is INewPolygonFeedback)
                    {
                        INewPolygonFeedback m_PolyFeed = (INewPolygonFeedback)m_Feedback;
                        m_PolyFeed.AddPoint(m_PointMousedown);
                    }
                }
            }
        }
Пример #14
0
        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);
                }
            }
        }
Пример #15
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            object pObj = Type.Missing;

            if (Button == 1)
            {
                //IFeatureLayer m_FeatureLayer = (IFeatureLayer)CreateShape.m_CurrentLayer;
                //if (m_FeatureLayer.FeatureClass == null) return;
                IActiveView m_ActiveView     = m_AxMapControl.ActiveView;
                IPoint      m_PointMousedown = m_ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

                m_PointStop = m_PointMousedown;

                if (!m_bInUse)
                {
                    //switch (m_FeatureLayer.FeatureClass.ShapeType)
                    //{
                    //    case esriGeometryType.esriGeometryPoint:         //点类型
                    //        CreateFeature(m_PointMousedown);
                    //        m_AxMapControl.ActiveView.Refresh();
                    //        break;
                    //    case esriGeometryType.esriGeometryPolyline:      //线类型
                    //        m_bInUse = true;
                    //        m_pNewLineFeedback = new NewLineFeedbackClass();
                    //        m_pNewLineFeedback.Display = m_ActiveView.ScreenDisplay;
                    //        m_pNewLineFeedback.Start(m_PointMousedown);
                    //        break;
                    //    case esriGeometryType.esriGeometryPolygon:       //多边形类型
                    //        m_bInUse = true;
                    //        m_pPlygonFeadback = new NewPolygonFeedbackClass();
                    //        m_pPlygonFeadback.Display = m_ActiveView.ScreenDisplay;
                    //        m_pPlygonFeadback.Start(m_PointMousedown);
                    //        break;
                    //}
                    m_bInUse                   = true;
                    m_pNewLineFeedback         = new NewLineFeedbackClass();
                    m_pNewLineFeedback.Display = m_ActiveView.ScreenDisplay;
                    m_pNewLineFeedback.Start(m_PointMousedown);
                }
                else
                {
                    if (m_pNewLineFeedback != null)
                    {
                        m_pNewLineFeedback.AddPoint(m_PointMousedown);
                    }
                    else if (m_pPlygonFeadback != null)
                    {
                        m_pPlygonFeadback.AddPoint(m_PointMousedown);
                    }
                }
            }
        }
Пример #16
0
        private void CalculateZimuthMouseDown(IPoint pPoint)
        {
            IGeometry pGeom = null;

            if (!m_bInUse) //如果命令没有使用
            {
                m_pPoint1    = pPoint;
                m_pLastPoint = pPoint;
                m_pRecordPointArray.Add(m_pPoint1);
                m_bInUse = true;

                m_pFeedback = new NewLineFeedbackClass();
                m_pLineFeed = (INewLineFeedback)m_pFeedback;
                m_pLineFeed.Start(pPoint);
                if (m_pFeedback != null)
                {
                    m_pFeedback.Display = m_pActiveView.ScreenDisplay;
                }

                CommonFunction.DrawPointSMSSquareSymbol(m_pMapControl, m_pPoint1);
            }
            else //如果命令正在使用
            {
                m_pPoint2 = pPoint;
                m_pRecordPointArray.Add(m_pPoint2);


                CommonFunction.DrawPointSMSSquareSymbol(m_pMapControl, m_pPoint2);

                IPolyline pPolyline;
                pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray);
                pGeom     = (IGeometry)pPolyline;
                CommonFunction.AddElement(m_pMapControl, pGeom);

                double dblZimuth = CommonFunction.GetAzimuth_P12(m_pPoint1.Y, m_pPoint1.X, m_pPoint2.Y, m_pPoint2.X);
                dblZimuth = CommonFunction.RadToDeg(dblZimuth);

                strResult1 = dblZimuth.ToString(".#####") + " (°) ";
                strResult2 = "X=" + m_pPoint1.X.ToString(".##") + "; " + "Y=" + m_pPoint1.Y.ToString(".##");
                strResult3 = "X=" + m_pPoint2.X.ToString(".##") + "; " + "Y=" + m_pPoint2.Y.ToString(".##");
                if (strResult1 != null && strResult2 != null && strResult3 != null)
                {
                    FrmAzimuthAngle frmAzimuthAngle = FrmAzimuthAngle.Instance();
                    frmAzimuthAngle.ShowDialog();
                }
                if (m_pRecordPointArray.Count != 0)
                {
                    m_pRecordPointArray.RemoveAll();
                }
                m_bInUse = false;
            }
        }
Пример #17
0
        public void OnMouseDown(int button, int shift, int x, int y)
        {
            IPoint pPoint = m_pScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            if (m_pLinefeedback == null)
            {
                m_pLinefeedback         = new NewLineFeedbackClass();
                m_pLinefeedback.Display = m_pScreenDisplay;
                m_pLinefeedback.Start(pPoint);
                m_iLocateX = x;
                m_iLocateY = y;
            }
        }
Пример #18
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1 || m_MapControl.Map.SelectionCount == 0)
            {
                return;
            }
            MoData.v_bVertexSelectionTracker = false;

            m_pNewLineFeedback      = new NewLineFeedbackClass();
            m_pMoveGeometryFeedback = new MoveGeometryFeedbackClass();
            IDisplayFeedback pDisplayFeedback = m_pMoveGeometryFeedback as IDisplayFeedback;

            pDisplayFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;

            m_pPtStart = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            m_pNewLineFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
            m_pNewLineFeedback.Start(m_pPtStart);

            //只刷新选中的地物
            IEnumFeature pEnumFeature = m_MapControl.Map.FeatureSelection as IEnumFeature;
            IInvalidArea pInvalidArea = new InvalidAreaClass();

            pInvalidArea.Display = m_hookHelper.ActiveView.ScreenDisplay;
            pInvalidArea.Add(pEnumFeature);

            pEnumFeature.Reset();
            IFeature pFeature = pEnumFeature.Next();

            m_pMoveSet = new SetClass();
            while (pFeature != null)
            {
                //'判断选中的要素是否启动了编辑
                IFeatureClass  pFeatureClass = pFeature.Class as IFeatureClass;
                IDataset       pDataset      = pFeatureClass as IDataset;
                IWorkspaceEdit pWSEdit       = pDataset.Workspace as IWorkspaceEdit;
                if (pWSEdit != null)
                {
                    if (pWSEdit.IsBeingEdited())
                    {
                        m_pMoveGeometryFeedback.AddGeometry(pFeature.Shape);
                        m_pMoveSet.Add(pFeature);
                    }
                }
                pFeature = pEnumFeature.Next();
            }

            m_pMoveGeometryFeedback.Start(m_pPtStart);

            m_bMouseDown = true;
        }
Пример #19
0
        /// <summary>
        /// 开始测角度,point为折线起点,测量结果为
        /// Direction:当前线段的方向角,即与正北方向的夹角
        /// Angle:当前线段与前一线段的夹角
        /// 在Map的MouseDown事件中调用本方法
        /// </summary>
        /// <param name="point">折线起点</param>
        public void AngleStart(IPoint point)
        {
            _eMeasureType    = EMeasureType.Angle;
            _newLineFeedback = new NewLineFeedbackClass {
                Display = MapCtrl.ActiveView.ScreenDisplay
            };
            _newLineFeedback.Start(point);

            _pointCollection = new PolylineClass();
            object ep = System.Reflection.Missing.Value;

            _pointCollection.AddPoint(point, ref ep, ref ep);
            IsSurveying = true;
        }
Пример #20
0
        private void DrawLineMouseDown(IPoint pPoint)
        {
            if (!m_bInUse)           //如果命令没有使用
            {
                m_bInUse = true;

                m_pUndoArray.Add(pPoint);

                m_pLastPoint = pPoint;

                Class.Common.DrawPointSMSSquareSymbol(m_MapControl, pPoint);

                m_pFeedback = new NewLineFeedbackClass();
                m_pLineFeed = (INewLineFeedback)m_pFeedback;
                m_pLineFeed.Start(pPoint);
                if (m_pFeedback != null)
                {
                    m_pFeedback.Display = m_pActiveView.ScreenDisplay;
                }

                if (((IFeatureLayer)m_CurrentLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                {
                     
                    //若当前图层是面层,则显示回馈开始点到鼠标点的线段
                        m_pLastFeedback = new NewLineFeedbackClass();
                    m_pLastLineFeed = (INewLineFeedback)m_pLastFeedback;
                    m_pLastLineFeed.Start(pPoint);
                    if (m_pLastFeedback != null)
                    {
                        m_pLastFeedback.Display = m_pActiveView.ScreenDisplay;
                    }
                }
            }
            else            //若果命令正使用中
            {
                m_pLineFeed.Stop();
                m_pLineFeed.Start(pPoint);

                IPoint tempPoint = new PointClass();
                tempPoint.X = pPoint.X;
                tempPoint.Y = pPoint.Y;
                m_pUndoArray.Add(tempPoint);

                m_pLastPoint = m_pAnchorPoint;

                Class.Common.DisplaypSegmentColToScreen(m_MapControl, ref m_pUndoArray);                //可以刷新屏幕了
            }
        }
Пример #21
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            //获得鼠标在控件上点击的位置,产生一个点对象
            IPoint pPt = m_ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (pLineFeedback == null)
            {
                pLineFeedback         = new NewLineFeedbackClass();
                pLineFeedback.Display = m_ActiveView.ScreenDisplay;
                pLineFeedback.Start(pPt);
            }
            else
            {
                pLineFeedback.AddPoint(pPt);
            }
        }
Пример #22
0
        private void DrawRectSide2PMouseDown(IPoint pPoint)
        {
            IPoint tempPoint = new PointClass();

            m_mouseDownCount = m_mouseDownCount + 1;

            if (m_mouseDownCount < 3) //点击鼠标次数小于3时
            {
                //绘制线
                if (m_bInUse == false)
                {
                    m_pFeedback = new NewLineFeedbackClass();
                    m_pLineFeed = (INewLineFeedback)m_pFeedback;
                    m_pLineFeed.Start(pPoint);

                    tempPoint.X = pPoint.X;
                    tempPoint.Y = pPoint.Y;

                    Class.Common.DrawPointSMSSquareSymbol(m_MapControl, pPoint);
                    m_pUndoArray.Add(tempPoint);//将第一个点保存到变量

                    m_pLastPoint = pPoint;
                    m_bInUse     = true;
                }
                else
                {
                    m_pLineFeed = (INewLineFeedback)m_pFeedback;
                    tempPoint.X = m_pAnchorPoint.X;
                    tempPoint.Y = m_pAnchorPoint.Y;
                    m_pLineFeed.AddPoint(tempPoint);

                    Class.Common.DrawPointSMSSquareSymbol(m_MapControl, tempPoint);
                    m_pUndoArray.Add(tempPoint);; //将第二个点保存到变量
                }

                if (m_pFeedback != null)
                {
                    m_pFeedback.Display = m_pActiveView.ScreenDisplay;
                }
            }
            else if (m_mouseDownCount == 3) //点击鼠标次数等于3后,停止绘制
            {
                EndDrawRectSide2P();
            }
        }
Пример #23
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            base.OnMouseDown(button, shift, x, y, mapX, mapY);

            m_CurrentLayer = m_App.CurrentEditLayer;

            m_bIsSelect = true;

            if (button == 2 && !m_bBeginDrawLineFeed)            //右键单击,开始绘制分割线
            {
                if (m_OriginFeatureArray.Count == 0)
                {
                    return;
                }

                m_bBeginDrawLineFeed = true;

                return;
            }

            if (button != 2 && m_bBeginDrawLineFeed)   //绘制分割线(“剪刀”)工作
            {
                if (!m_bIsDrawLineFeed)                //第1个点
                {
                    m_bIsDrawLineFeed = true;
                    m_pFeedback       = new NewLineFeedbackClass();
                    m_pLineFeed       = (INewLineFeedback)m_pFeedback;
                    m_pLineFeed.Start(m_pPoint);
                    if (m_pFeedback != null)
                    {
                        m_pFeedback.Display = m_pActiveView.ScreenDisplay;
                    }
                }
                else                //第2、3个点
                {
                    m_pLineFeed = (INewLineFeedback)m_pFeedback;
                    m_pLineFeed.AddPoint(m_pPoint);
                }
            }

            if (button == 2 && m_bBeginDrawLineFeed)            //执行分割操作
            {
                DoSplit();
            }
        }
Пример #24
0
        private void CalculateAreaeMouseDown(IPoint pPoint)
        {
            if (!m_bInUse)//如果命令没有使用
            {
                m_bInUse = true;

                m_pRecordPointArray.Add(pPoint);

                m_pLastPoint = pPoint;

                CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, pPoint);

                m_pFeedback = new NewLineFeedbackClass();
                m_pLineFeed = (INewLineFeedback)m_pFeedback;
                m_pLineFeed.Start(pPoint);
                if (m_pFeedback != null)
                {
                    m_pFeedback.Display = m_pActiveView.ScreenDisplay;
                }

                m_pLastFeedback = new NewLineFeedbackClass();
                m_pLastLineFeed = (INewLineFeedback)m_pLastFeedback;
                m_pLastLineFeed.Start(pPoint);
                if (m_pLastFeedback != null)
                {
                    m_pLastFeedback.Display = m_pActiveView.ScreenDisplay;
                }
            }
            else//若果命令正使用中
            {
                m_pLineFeed.Stop();
                m_pLineFeed.Start(pPoint);

                IPoint tempPoint = new PointClass();
                tempPoint.X = pPoint.X;
                tempPoint.Y = pPoint.Y;
                m_pRecordPointArray.Add(tempPoint);

                m_pLastPoint = tempPoint;

                CommonFunction.DisplaypSegmentColToScreen(m_MapControl, ref m_pRecordPointArray);//可以刷新屏幕了
            }
        }
Пример #25
0
 /// <summary>
 /// 鼠标落下时运行
 /// </summary>
 /// <param name="clickPT">地图点</param>
 public void OnMouseDownRun(IPoint clickPT)
 {
     if (lineFeedback == null)
     {
         lineFeedback         = new NewLineFeedbackClass();
         lineFeedback.Display = (mapControl.Map as IActiveView).ScreenDisplay;
         lineFeedback.Start(clickPT);
         // 长度计算
         currentLength = 0;
         totalLength   = 0;
     }
     else
     {
         lineFeedback.AddPoint(clickPT);
         // 长度计算
         totalLength += Math.Round(Math.Sqrt(Math.Pow(tempPT.X - clickPT.X, 2) + Math.Pow(tempPT.Y - clickPT.Y, 2)), 3);
     }
     tempPT = clickPT;
 }
Пример #26
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }

            m_bCreated        = false;
            m_lMouseDownCount = m_lMouseDownCount + 1;
            if (m_lMouseDownCount == 1)
            {
                m_pFirstPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                m_pFirstPoint = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_pFirstPoint);
                SetNewLineFeedBack();
                m_pLineFeedback.Start(m_pFirstPoint);
            }
            else if (m_lMouseDownCount == 2)
            {
                m_pSecondPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                m_pSecondPoint = GIS.GraphicEdit.SnapSetting.getSnapPoint(m_pSecondPoint);
            }
        }
Пример #27
0
        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);
            }
        }
Пример #28
0
        private void CalculateDistanceMouseDown(IPoint pPoint)
        {
            if (!m_bInUse)//如果命令没有使用
            {
                m_bInUse = true;

                m_pRecordPointArray.Add(pPoint);

                m_pLastPoint = pPoint;

                CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, pPoint);

                m_pFeedback = new NewLineFeedbackClass();
                m_pLineFeed = (INewLineFeedback)m_pFeedback;
                m_pLineFeed.Start(pPoint);
                if (m_pFeedback != null)
                {
                    m_pFeedback.Display = m_pActiveView.ScreenDisplay;
                }
            }
            else//若果命令正使用中
            {
                m_pLineFeed.Stop();
                m_pLineFeed.Start(pPoint);

                IPoint tempPoint = new PointClass();
                tempPoint.X = pPoint.X;
                tempPoint.Y = pPoint.Y;
                m_pRecordPointArray.Add(tempPoint);

                m_pLastPoint = tempPoint;

                m_dblDistance      = CommonFunction.GetDistance_P12((IPoint)m_pRecordPointArray.get_Element(m_pRecordPointArray.Count - 2), m_pLastPoint); //最后一段的长度
                m_dblTotalDistance = m_dblTotalDistance + m_dblDistance;                                                                                   //总长度

                CommonFunction.DisplaypSegmentColToScreen(m_MapControl, ref m_pRecordPointArray);                                                          //可以刷新屏幕了
            }
        }
Пример #29
0
        public override void OnKeyUp(int keyCode, int Shift)
        {
            if (Shift != 2 && keyCode != 90)
            {
                return;
            }
            if (m_pNewLineFeedback == null)
            {
                return;
            }
            IPolyline pPolyline = m_pNewLineFeedback.Stop();

            m_pNewLineFeedback = null;
            if (pPolyline == null)
            {
                return;
            }
            IPointCollection pntCol = pPolyline as IPointCollection;

            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(pntCol.get_Point(0));
            for (int i = 1; i < pntCol.PointCount - 1; i++)
            {
                m_pNewLineFeedback.AddPoint(pntCol.get_Point(i));
            }
        }
Пример #30
0
        public override void OnMouseDown(int button, int Shift, int x, int y)
        {
            if (button == 2)
            {
                return;
            }

            this._iPoint = (_context.ActiveView).ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            IActiveView focusMap = (IActiveView)_context.ActiveView;

            if (_lineFeedback == null)
            {
                _lineFeedback = new NewLineFeedback()
                {
                    Display = focusMap.ScreenDisplay
                };
                _lineFeedback.Start(_iPoint);
                this.m_cursor = this._cursor1;
                _inLine       = true;
                return;
            }
            if (this._inLine)
            {
                this.m_cursor = this._cursor;
                this._inLine  = false;
                if (this._lineFeedback != null)
                {
                    _lineFeedback.AddPoint(_iPoint);
                    IPolyline line = this._lineFeedback.Stop();
                    if (line.Length > 0)
                    {
                        //开始启动断面分析
                        _sectLine = line;
                        StartSection();
                    }
                }
            }
        }
        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;
        }
Пример #32
0
        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);
            }
        }
Пример #33
0
        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
        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);
        }
Пример #35
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();
        }