public override void OnClick() { LegendWizard legendWizard = new LegendWizard(); legendWizard.StyleGallery = this._context.StyleGallery; IGraphicsContainer graphicsContainer = this._context.ActiveView as IGraphicsContainer; IMapFrame mapFrame = graphicsContainer.FindFrame(this._context.FocusMap) as IMapFrame; IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(new UID { Value = "esriCarto.Legend" }, null); legendWizard.InitialLegendFrame = mapSurroundFrame; legendWizard.FocusMap = this._context.FocusMap; legendWizard.ShowDialog(); IEnvelope envelope = new Envelope() as IEnvelope; envelope.PutCoords(0.0, 0.0, 5.0, 10.0); IEnvelope envelope2 = new Envelope() as IEnvelope; mapSurroundFrame.MapSurround.QueryBounds(this._context.ActiveView.ScreenDisplay, envelope, envelope2); (mapSurroundFrame as IElement).Geometry = envelope2; INewElementOperation newElementOperation = new NewElementOperation(); newElementOperation.ActiveView = this._context.ActiveView; newElementOperation.Element = (mapSurroundFrame as IElement); this._context.OperationStack.Do(newElementOperation); }
/// <summary> /// 图例 /// </summary> /// <returns></returns> public bool AddLegend() { IGraphicsContainer pGraphicsContainer; pGraphicsContainer = mainPage.PageLayout as IGraphicsContainer; IMapFrame pFocusMapFrame; pFocusMapFrame = pGraphicsContainer.FindFrame(mainPage.ActiveView.FocusMap) as IMapFrame; UID u = new UIDClass(); u.Value = "esriCarto.Legend"; IMapSurroundFrame pLegendFrame; pLegendFrame = pFocusMapFrame.CreateSurroundFrame(u, null); IEnvelope pEnvelope; pEnvelope = new EnvelopeClass(); pEnvelope.PutCoords(3, 3, 6, 8); IElement pElement; pElement = pLegendFrame as IElement; pElement.Geometry = pEnvelope; ILegendWizard pLegendWizard; pLegendWizard = new LegendWizard(); pLegendWizard.PageLayout = mainPage.PageLayout; pLegendWizard.InitialLegendFrame = pLegendFrame; bool bOk = pLegendWizard.DoModal(mainPage.hWnd); if (bOk == true) { IElement ele = pLegendWizard.LegendFrame as IElement; pGraphicsContainer.AddElement(ele, 0); mainPage.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } return(true); }
/// <summary> /// 图例 /// </summary> /// <returns></returns> public bool AddLegend() { IGraphicsContainer pGraphicsContainer; pGraphicsContainer = mainPage.PageLayout as IGraphicsContainer; IMapFrame pFocusMapFrame; pFocusMapFrame = pGraphicsContainer.FindFrame(mainPage.ActiveView.FocusMap) as IMapFrame; UID u = new UIDClass(); u.Value = "esriCarto.Legend"; IMapSurroundFrame pLegendFrame; pLegendFrame = pFocusMapFrame.CreateSurroundFrame(u, null); IEnvelope pEnvelope; pEnvelope = new EnvelopeClass(); pEnvelope.PutCoords(3, 3, 6, 8); IElement pElement; pElement = pLegendFrame as IElement; pElement.Geometry = pEnvelope; ILegendWizard pLegendWizard; pLegendWizard = new LegendWizard(); pLegendWizard.PageLayout = mainPage.PageLayout; pLegendWizard.InitialLegendFrame = pLegendFrame; bool bOk = pLegendWizard.DoModal(mainPage.hWnd); if (bOk == true) { IElement ele = pLegendWizard.LegendFrame as IElement; pGraphicsContainer.AddElement(ele, 0); mainPage.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } return true; }