private void Btn_AddNorthArrow_Click(object sender, EventArgs e) { FormSymbologySelector formSymbologySelector = new FormSymbologySelector(RequestResponder, esriSymbologyStyleClass.esriStyleClassNorthArrows); formSymbologySelector.ShowDialog(); IGraphicsContainer pGraphicsContainer = Ctrl_PageLayout.ActiveView.GraphicsContainer; IMapFrame pMapFrame = (IMapFrame)pGraphicsContainer.FindFrame(Ctrl_PageLayout.ActiveView.FocusMap); if (pMapFrame == null) { return; } UID uid = new UIDClass { Value = "esriCarto.MarkerNorthArrow" }; IMapSurroundFrame pMapSurroundFrame = pMapFrame.CreateSurroundFrame(uid, null); if (pMapSurroundFrame == null || pMapSurroundFrame.MapSurround == null) { return; } INorthArrow pNorthArrow = m_pStyleGalleryItem.Item as INorthArrow; pNorthArrow.Size = m_pEnvelopDrawed.Width * 100; pMapSurroundFrame.MapSurround = pNorthArrow; IElement pElement = (IElement)pMapSurroundFrame; pElement.Geometry = m_pEnvelopDrawed; if (m_pNorthArrowElement != null) { Ctrl_PageLayout.ActiveView.GraphicsContainer.DeleteElement(m_pNorthArrowElement); } Ctrl_PageLayout.ActiveView.GraphicsContainer.AddElement(pElement, 0); m_pNorthArrowElement = pElement; Ctrl_PageLayout.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void Btn_AddScaleBar_Click(object sender, EventArgs e) { FormSymbologySelector formSymbologySelector = new FormSymbologySelector(RequestResponder, esriSymbologyStyleClass.esriStyleClassScaleBars); formSymbologySelector.ShowDialog(); IActiveView pActiveView = Ctrl_PageLayout.ActiveView; IMap pMap = Ctrl_PageLayout.ActiveView.FocusMap; IMapFrame pMapFrame = (IMapFrame)Ctrl_PageLayout.ActiveView.GraphicsContainer.FindFrame(pMap); IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass { MapFrame = pMapFrame, MapSurround = (IMapSurround)m_pStyleGalleryItem.Item }; IElement pElement = (IElement)pMapSurroundFrame; pElement.Geometry = m_pEnvelopDrawed; if (m_pScaleBarElement != null) { pActiveView.GraphicsContainer.DeleteElement(m_pScaleBarElement); } pActiveView.GraphicsContainer.AddElement(pElement, 0); m_pScaleBarElement = pElement; pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pMapSurroundFrame, null); }