public static void AddNorthArrow(AxPageLayoutControl pageLayoutControl, IEnvelope envelope) { IUID uid = new UIDClass() { Value = "esriCarto.MarkerNorthArrow" }; IFrameElement frameElement = (pageLayoutControl.PageLayout as IGraphicsContainer) .FindFrame(pageLayoutControl.ActiveView.FocusMap); IMapFrame mapFrame = frameElement as IMapFrame; IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as UID, null); // Dynamic Cast IElement element = mapSurroundFrame as IElement; // Dynamic Cast element.Geometry = envelope; element.Activate(pageLayoutControl.ActiveView.ScreenDisplay); (pageLayoutControl.PageLayout as IGraphicsContainer).AddElement(element, 0); IMapSurround mapSurround = mapSurroundFrame.MapSurround; // Change out the default north arrow IMarkerNorthArrow markerNorthArrow = mapSurround as IMarkerNorthArrow; // Dynamic Cast IMarkerSymbol markerSymbol = markerNorthArrow.MarkerSymbol; ICharacterMarkerSymbol characterMarkerSymbol = markerSymbol as ICharacterMarkerSymbol; // Dynamic Cast characterMarkerSymbol.CharacterIndex = 202; markerNorthArrow.MarkerSymbol = characterMarkerSymbol; }
/// <summary> /// Gets the GPS photo symbol. /// </summary> /// <returns>ISymbol for GPS Locations</returns> private ISymbol GetGPSPhotoSymbol() { IMultiLayerMarkerSymbol multiLayerMarkerSymbol = new MultiLayerMarkerSymbolClass(); ICharacterMarkerSymbol viewshedSymbol = this.GetGPSPhotoViewshedSymbol(); multiLayerMarkerSymbol.AddLayer(viewshedSymbol); ICharacterMarkerSymbol charSymbol = new CharacterMarkerSymbol(); // IFontDisp fontDisp = (IFontDisp)(new StdFont()); IRgbColor rgbColor = new RgbColor(); // Define the color we want to use rgbColor.Red = 255; rgbColor.Green = 0; rgbColor.Blue = 0; // Define the Font we want to use charSymbol.Font = ESRI.ArcGIS.Utility.Converter.ToStdFont(new System.Drawing.Font("ESRI Default Marker", 30f)); // Set the CharacterMarkerSymbols Properties charSymbol.Size = 8; charSymbol.Angle = 0; charSymbol.CharacterIndex = 34; charSymbol.Color = rgbColor; charSymbol.XOffset = 0; charSymbol.YOffset = 0; multiLayerMarkerSymbol.AddLayer(charSymbol); return((ISymbol)multiLayerMarkerSymbol); }
public void AddNorthArrow(IPageLayout pageLayout, IMap map, double posX, double posY, double division) { try { if (pageLayout == null || map == null) { return; } IEnvelope envelope = new EnvelopeClass(); envelope.PutCoords(posX - division, posY - division, posX, posY); // Specify the location and size of the north arrow ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass(); uid.Value = "esriCarto.MarkerNorthArrow"; // Create a Surround. Set the geometry of the MapSurroundFrame to give it a location // Activate it and add it to the PageLayout's graphics container IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer; // Dynamic Cast IActiveView activeView = pageLayout as IActiveView; // Dynamic Cast IFrameElement frameElement = graphicsContainer.FindFrame(map); IMapFrame mapFrame = frameElement as IMapFrame; // Dynamic Cast IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null); // Dynamic Cast IElement element = mapSurroundFrame as IElement; // Dynamic Cast element.Geometry = envelope; element.Activate(activeView.ScreenDisplay); graphicsContainer.AddElement(element, 0); IMapSurround mapSurround = mapSurroundFrame.MapSurround; // Change out the default north arrow IMarkerNorthArrow markerNorthArrow = mapSurround as IMarkerNorthArrow; // Dynamic Cast IMarkerSymbol markerSymbol = markerNorthArrow.MarkerSymbol; ICharacterMarkerSymbol characterMarkerSymbol = markerSymbol as ICharacterMarkerSymbol; // Dynamic Cast characterMarkerSymbol.CharacterIndex = 174; // change the symbol for the North Arrow markerNorthArrow.MarkerSymbol = characterMarkerSymbol; } catch (Exception ex) { frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog(); return; } }
private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) { button2.Enabled = true; m_pStyleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; if (m_pStyleGalleryItem == null) { return; } //获取新的指北针 pMarkerNorthArrow = m_pStyleGalleryItem.Item as IMarkerNorthArrow; if (pMarkerNorthArrow == null) { return; } pCharacterMarkerSymbol = pMarkerNorthArrow.MarkerSymbol as ICharacterMarkerSymbol; pCharacterMarkerSymbol.Size = 100; System.Drawing.Image image = PageLayoutInsert.CreatePictureFromSymbol((ISymbol)this.pCharacterMarkerSymbol, this.picBoxPreview.Width, this.picBoxPreview.Height, 0); this.picBoxPreview.Image = image; textBoxSize.Text = pCharacterMarkerSymbol.Size.ToString(); textBoxAngle.Text = pCharacterMarkerSymbol.Angle.ToString(); }