コード例 #1
0
        /// <summary>
        /// 图形比例尺
        /// </summary>
        /// <returns></returns>
        public bool AddImgScaleBar()
        {
            IStyleSelector pStyleSelector = new ScaleBarSelectorClass();
            bool m_bOK = pStyleSelector.DoModal(0);
            if (m_bOK == true)
            {
                IScaleBar pScaleBar = pStyleSelector.GetStyle(0) as IScaleBar;

                IEnvelope envelope = new EnvelopeClass();
                envelope.PutCoords(0.2, 0.2, 5, 1);
                ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
                uid.Value = "esriCarto.Scalebar";
                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);
                IMapSurround mapsurround = pScaleBar as IMapSurround;
                mapSurroundFrame.MapSurround = mapsurround;
                IElement element = mapSurroundFrame as IElement;
                element.Geometry = envelope;
                element.Activate(activeView.ScreenDisplay);
                graphicsContainer.AddElement(element, 0);
                IMapSurround mapSurround = mapSurroundFrame.MapSurround;
            }
            return true;
        }
コード例 #2
0
        /// <summary>
        /// 图形比例尺
        /// </summary>
        /// <returns></returns>
        public bool AddImgScaleBar()
        {
            IStyleSelector pStyleSelector = new ScaleBarSelectorClass();
            bool           m_bOK          = pStyleSelector.DoModal(0);

            if (m_bOK == true)
            {
                IScaleBar pScaleBar = pStyleSelector.GetStyle(0) as IScaleBar;

                IEnvelope envelope = new EnvelopeClass();
                envelope.PutCoords(0.2, 0.2, 5, 1);
                ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
                uid.Value = "esriCarto.Scalebar";
                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);
                IMapSurround       mapsurround       = pScaleBar as IMapSurround;
                mapSurroundFrame.MapSurround = mapsurround;
                IElement element = mapSurroundFrame as IElement;
                element.Geometry = envelope;
                element.Activate(activeView.ScreenDisplay);
                graphicsContainer.AddElement(element, 0);
                IMapSurround mapSurround = mapSurroundFrame.MapSurround;
            }
            return(true);
        }