Пример #1
0
        /// <添加指北针>
        ///
        /// </添加指北针>
        /// <returns></returns>
        public bool AddNorthArrow()
        {
            IStyleSelector pStyleSelector = new NorthArrowSelectorClass();
            bool           m_bOK          = pStyleSelector.DoModal(0);

            if (m_bOK == true)
            {
                IMarkerNorthArrow pMarkerNorthArrow = pStyleSelector.GetStyle(0) as IMarkerNorthArrow;

                IEnvelope envelope = new EnvelopeClass();
                envelope.PutCoords(0.2, 0.2, 5, 5);
                ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
                uid.Value = "esriCarto.MarkerNorthArrow";
                IMap pMap = mainPage.ActiveView.FocusMap;
                IGraphicsContainer graphicsContainer = mainPage.ActiveView as IGraphicsContainer;
                IActiveView        activeView        = mainPage.ActiveView as IActiveView;
                IFrameElement      frameElement      = graphicsContainer.FindFrame(pMap);
                IMapFrame          mapFrame          = frameElement as IMapFrame;
                IMapSurroundFrame  mapSurroundFrame  = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null);
                IElement           element           = mapSurroundFrame as IElement;
                element.Geometry = envelope;
                element.Activate(activeView.ScreenDisplay);
                graphicsContainer.AddElement(element, 0);
                IMapSurround mapSurround = mapSurroundFrame.MapSurround;

                IMarkerNorthArrow markerNorthArrow = mapSurround as IMarkerNorthArrow;
                markerNorthArrow.MarkerSymbol = pMarkerNorthArrow.MarkerSymbol;
            }
            return(true);
        }
Пример #2
0
        /// <添加指北针>
        /// 
        /// </添加指北针>
        /// <returns></returns>
        public bool AddNorthArrow()
        {
            IStyleSelector pStyleSelector = new NorthArrowSelectorClass();
            bool m_bOK = pStyleSelector.DoModal(0);
            if (m_bOK == true)
            {
                IMarkerNorthArrow pMarkerNorthArrow = pStyleSelector.GetStyle(0) as IMarkerNorthArrow;

                IEnvelope envelope = new EnvelopeClass();
                envelope.PutCoords(0.2, 0.2, 5, 5);
                ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
                uid.Value = "esriCarto.MarkerNorthArrow";
                IMap pMap = mainPage.ActiveView.FocusMap;
                IGraphicsContainer graphicsContainer = mainPage.ActiveView as IGraphicsContainer;
                IActiveView activeView = mainPage.ActiveView as IActiveView;
                IFrameElement frameElement = graphicsContainer.FindFrame(pMap);
                IMapFrame mapFrame = frameElement as IMapFrame;
                IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null);
                IElement element = mapSurroundFrame as IElement;
                element.Geometry = envelope;
                element.Activate(activeView.ScreenDisplay);
                graphicsContainer.AddElement(element, 0);
                IMapSurround mapSurround = mapSurroundFrame.MapSurround;

                IMarkerNorthArrow markerNorthArrow = mapSurround as IMarkerNorthArrow;
                markerNorthArrow.MarkerSymbol = pMarkerNorthArrow.MarkerSymbol;
            }
            return true;
        }