/// <summary> /// 文字比例尺 /// </summary> /// <returns></returns> public bool AddTxtSacleBar() { IStyleSelector pStyleSelector = new ScaleTextSelectorClass(); bool m_bOK = pStyleSelector.DoModal(0); if (m_bOK == true) { IScaleText pScaleText = pStyleSelector.GetStyle(0) as IScaleText; 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.Scaletext"; 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 = pScaleText 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); }
/// <summary> /// 文字比例尺 /// </summary> /// <returns></returns> public bool AddTxtSacleBar() { IStyleSelector pStyleSelector = new ScaleTextSelectorClass(); bool m_bOK = pStyleSelector.DoModal(0); if (m_bOK == true) { IScaleText pScaleText = pStyleSelector.GetStyle(0) as IScaleText; 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.Scaletext"; 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 = pScaleText 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; }