private void method_0() { IMapGrid grid = new MeasuredGridClass(); if (this.MapFrame != null) { grid.SetDefaults(this.MapFrame); } (grid as IMeasuredGrid).XOrigin = 0.0; (grid as IMeasuredGrid).Units = esriUnits.esriMeters; (grid as IMeasuredGrid).YOrigin = 0.0; (grid as IMeasuredGrid).XIntervalSize = 200.0; (grid as IMeasuredGrid).YIntervalSize = 200.0; (grid as IMeasuredGrid).FixedOrigin = true; IGridLabel labelFormat = grid.LabelFormat; ITextSymbol symbol = new TextSymbolClass { Font = labelFormat.Font, Color = labelFormat.Color, Text = labelFormat.DisplayName, VerticalAlignment = esriTextVerticalAlignment.esriTVABottom }; labelFormat.Font = symbol.Font; labelFormat.Color = symbol.Color; labelFormat.LabelOffset = 6.0; grid.LabelFormat = labelFormat; if (labelFormat is IMixedFontGridLabel2) { (labelFormat as IMixedFontGridLabel2).NumGroupedDigits = 0; } this.MapTemplate.MapGrid = grid; }
public IMapGrid CreateMapGrid(int int_0) { IMapGrid grid = null; switch (int_0) { case 0: grid = new GraticuleClass(); break; case 1: grid = new MeasuredGridClass(); break; case 2: grid = new IndexGridClass(); break; } if (grid == null) { return(null); } grid.SetDefaults(this.m_pMapFrame); grid.LineSymbol = null; IMarkerSymbol symbol = new SimpleMarkerSymbolClass(); (symbol as ISimpleMarkerSymbol).Style = esriSimpleMarkerStyle.esriSMSCross; grid.TickMarkSymbol = symbol; if (grid is IMeasuredGrid) { IFormattedGridLabel label = new FormattedGridLabelClass(); INumericFormat format = new NumericFormatClass { AlignmentOption = esriNumericAlignmentEnum.esriAlignLeft, AlignmentWidth = 0, RoundingOption = esriRoundingOptionEnum.esriRoundNumberOfDecimals, RoundingValue = 3, ShowPlusSign = true, UseSeparator = true, ZeroPad = true }; label.Format = format as INumberFormat; (label as IGridLabel).LabelOffset = 6.0; grid.LabelFormat = label as IGridLabel; IEnvelope mapBounds = this.m_pMapFrame.MapBounds; (grid as IMeasuredGrid).FixedOrigin = true; (grid as IMeasuredGrid).XOrigin = mapBounds.XMin + 500.0; (grid as IMeasuredGrid).YOrigin = mapBounds.YMin + 500.0; grid.SetTickVisibility(false, false, false, false); grid.SetSubTickVisibility(false, false, false, false); } return(grid); }
public IMapGrid CreateMapGrid() { int selectedIndex = this.radioMapGridType.SelectedIndex; IMapGrid grid = null; switch (selectedIndex) { case 0: grid = new GraticuleClass(); break; case 1: grid = new MeasuredGridClass(); break; case 2: grid = new IndexGridClass(); break; } if (grid == null) { return(null); } grid.SetDefaults(this.m_pMapFrame); grid.Name = this.txtMapGridName.Text; if (grid is IMeasuredGrid) { try { double mapScale = this.m_pMapFrame.Map.MapScale; } catch { } IEnvelope extent = (this.m_pMapFrame.Map as IActiveView).Extent; (grid as IMeasuredGrid).XOrigin = extent.XMin; (grid as IMeasuredGrid).YOrigin = extent.YMin; (grid as IMeasuredGrid).FixedOrigin = true; } return(grid); }