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); }