//添加指北针 private void 指北针ToolStripMenuItem_Click(object sender, EventArgs e) { tag = 3; FrmNorthArrow frmNorthArrow = new FrmNorthArrow(); frmNorthArrow.Owner = this; frmNorthArrow.ShowDialog(); }
private void CreateNorhtArrow() { //Create the form with the SymbologyControl FrmNorthArrow symbolForm = new FrmNorthArrow(null); //Get the IStyleGalleryItem if (symbolForm.ShowDialog() != DialogResult.OK) { return; } IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(); //Release the form symbolForm.Dispose(); if (styleGalleryItem == null) { return; } IGraphicsContainer pGraphicsContainer = m_hookHelper.ActiveView.GraphicsContainer; IMapFrame pMapFrame = pGraphicsContainer.FindFrame(m_hookHelper.ActiveView.FocusMap) as IMapFrame; if (pMapFrame == null) { return; } //Create a map surround frame IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass(); //Set its map frame and map surround pMapSurroundFrame.MapFrame = pMapFrame; pMapSurroundFrame.MapSurround = (IMapSurround)styleGalleryItem.Item; //显示结果大小 IEnvelope pEnv = new EnvelopeClass(); IActiveView pActiveView = m_hookHelper.ActiveView; IPageLayout pPageLayout = (IPageLayout)pActiveView; IPage pPage = pPageLayout.Page; double pWidth = pPage.PrintableBounds.XMax - 5; double pHeigth = pPage.PrintableBounds.YMax - 5; pEnv.PutCoords(pWidth, pHeigth, pWidth + 20, pHeigth + 20); IElement pElement = (IElement)pMapSurroundFrame; pElement.Geometry = (IGeometry)pEnv; //Add the element to the graphics container pGraphicsContainer.AddElement((IElement)pMapSurroundFrame, 0); //Refresh m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pMapSurroundFrame, null); }