Exemplo n.º 1
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            if (m_InUse == false)
            {
                return;
            }

            if (GetCapture() == m_HookHelper.ActiveView.ScreenDisplay.hWnd)
            {
                ReleaseCapture();
            }

            if (m_Feedback == null)
            {
                m_Feedback = null;
                m_InUse    = false;
                return;
            }
            IEnvelope envelope = m_Feedback.Stop();

            if ((envelope.IsEmpty) || (envelope.Width == 0) || (envelope.Height == 0))
            {
                m_Feedback = null;
                m_InUse    = false;
                return;
            }

            frmSymbolSelector symbolForm       = new frmSymbolSelector();
            IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassNorthArrows, null);

            symbolForm.Dispose();
            if (symbolForm.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (styleGalleryItem == null)
            {
                return;
            }
            IMapFrame mapFrame = (IMapFrame)m_HookHelper.ActiveView.GraphicsContainer.FindFrame(m_HookHelper.ActiveView.FocusMap);
            UID       vUid     = new UIDClass();

            vUid.Value = "{7A3F91DD-B9E3-11d1-8756-0000F8751720}";
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(vUid, (IMapSurround)styleGalleryItem.Item);

            IElement element = (IElement)mapSurroundFrame;

            element.Geometry = envelope;
            IElementProperties3 pep = element as IElementProperties3;

            pep.Name = "指北针";
            IGraphicsContainerSelect pGraphicsSel = m_HookHelper.ActiveView.GraphicsContainer as IGraphicsContainerSelect;

            pGraphicsSel.UnselectAllElements();
            pGraphicsSel.SelectElement(element);
            m_HookHelper.ActiveView.GraphicsContainer.AddElement(element, 0);
            m_HookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            if (m_HookHelper.Hook is IPageLayoutControl)
            {
                IPageLayoutControl pPLC = m_HookHelper.Hook as IPageLayoutControl;
                if (pPLC != null)
                {
                    ////初始化控件工具为选择元素工具
                    //string progID = "esriControls.ControlsSelectTool";
                    //int index = axToolbarControl1.Find(progID);
                    //if (index != -1)
                    //{
                    //    IToolbarItem toolItem = axToolbarControl1.GetItem(index);
                    //    ICommand _cmd = toolItem.Command;
                    //    ITool _tool = (ITool)_cmd;
                    //    pPLC.CurrentTool = _tool;
                    //}
                }
            }
            m_Feedback = null;
            m_InUse    = false;
        }
Exemplo n.º 2
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            if (m_InUse == false)
            {
                return;
            }

            //Stop capturing mouse events
            if (GetCapture() == m_HookHelper.ActiveView.ScreenDisplay.hWnd)
            {
                ReleaseCapture();
            }

            //If an envelope has not been tracked or its height/width is 0
            if (m_Feedback == null)
            {
                m_Feedback = null;
                m_InUse    = false;
                return;
            }
            IEnvelope envelope = m_Feedback.Stop();

            if ((envelope.IsEmpty) || (envelope.Width == 0) || (envelope.Height == 0))
            {
                m_Feedback = null;
                m_InUse    = false;
                return;
            }

            frmSymbolSelector symbolForm       = new frmSymbolSelector();
            IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassScaleTexts, null);

            //Release the form
            symbolForm.Dispose();
            if (symbolForm.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (styleGalleryItem == null)
            {
                return;
            }

            //Get the map frame of the focus map
            IMapFrame mapFrame = (IMapFrame)m_HookHelper.ActiveView.GraphicsContainer.FindFrame(m_HookHelper.ActiveView.FocusMap);

            //Create a map surround frame
            UID vUid = new UIDClass();

            vUid.Value = "{7A3F91DC-B9E3-11d1-8756-0000F8751720}";
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(vUid, (IMapSurround)styleGalleryItem.Item);

            IElement element = (IElement)mapSurroundFrame;

            element.Geometry = envelope;
            IElementProperties3 pep = element as IElementProperties3;

            pep.Name = "比例尺";
            IGraphicsContainerSelect pGraphicsSel = m_HookHelper.ActiveView.GraphicsContainer as IGraphicsContainerSelect;

            pGraphicsSel.UnselectAllElements();
            pGraphicsSel.SelectElement(element);
            m_HookHelper.ActiveView.GraphicsContainer.AddElement(element, 0);
            //Refresh
            m_HookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            m_Feedback = null;
            m_InUse    = false;
        }
Exemplo n.º 3
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            if (m_InUse == false)
            {
                return;
            }

            if (GetCapture() == m_HookHelper.ActiveView.ScreenDisplay.hWnd)
            {
                ReleaseCapture();
            }

            if (m_Feedback == null)
            {
                m_Feedback = null;
                m_InUse    = false;
                return;
            }
            IEnvelope envelope = m_Feedback.Stop();

            if ((envelope.IsEmpty) || (envelope.Width == 0) || (envelope.Height == 0))
            {
                m_Feedback = null;
                m_InUse    = false;
                return;
            }

            frmSymbolSelector symbolForm       = new frmSymbolSelector();
            IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassScaleBars, null);

            symbolForm.Dispose();
            if (symbolForm.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (styleGalleryItem == null)
            {
                return;
            }

            IMapFrame mapFrame = (IMapFrame)m_HookHelper.ActiveView.GraphicsContainer.FindFrame(m_HookHelper.ActiveView.FocusMap);
            UID       vUid     = new UIDClass();

            vUid.Value = "{6589F143-F7F7-11d2-B872-00600802E603}";
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(vUid, (IMapSurround)styleGalleryItem.Item);

            if (mapSurroundFrame.MapSurround is IScaleBar)
            {
                IScaleBar pScalbeBar = (IScaleBar)mapSurroundFrame.MapSurround;
                pScalbeBar.Units = mapFrame.Map.MapUnits;
                switch (pScalbeBar.Units)
                {
                case esriUnits.esriMeters:
                    pScalbeBar.UnitLabel = "米";
                    break;

                case esriUnits.esriKilometers:
                    pScalbeBar.UnitLabel = "公里";
                    break;

                case esriUnits.esriMiles:
                    pScalbeBar.UnitLabel = "英里";
                    break;

                case esriUnits.esriDecimalDegrees:
                    pScalbeBar.UnitLabel = "度";
                    break;
                }
            }


            IElement element = (IElement)mapSurroundFrame;

            element.Geometry = envelope;
            IElementProperties3 pep = element as IElementProperties3;

            pep.Name = "比例尺";

            IGraphicsContainerSelect pGraphicsSel = m_HookHelper.ActiveView.GraphicsContainer as IGraphicsContainerSelect;

            pGraphicsSel.UnselectAllElements();
            pGraphicsSel.SelectElement(element);
            m_HookHelper.ActiveView.GraphicsContainer.AddElement(element, 0);
            m_HookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            m_Feedback = null;
            m_InUse    = false;
        }