Пример #1
0
        /// <summary>
        /// 获取经纬网,并设置属性
        /// </summary>
        /// <returns></returns>
        public static IGraticule GetGraticuleAndSetProperty()
        {
            IGraticule pGraticule = new GraticuleClass();

            pGraticule.Name = "Map Grid";
            //设置网格线的符号样式
            ICartographicLineSymbol pLineSymbol = GetLineSymbol();

            pGraticule.LineSymbol = pLineSymbol;
            //设置网格的边框样式
            pGraticule.Border = (IMapGridBorder)GetMapGridBorder();
            //设置网格的主刻度的样式和可见性
            pGraticule.TickLength     = 15;
            pGraticule.TickMarkSymbol = null;
            pGraticule.TickLineSymbol = pLineSymbol;
            //设置网格的次级刻度的样式和可见性
            pGraticule.SubTickCount      = 5;
            pGraticule.SubTickLength     = 10;
            pGraticule.SubTickLineSymbol = pLineSymbol;
            pGraticule.SetSubTickVisibility(true, true, true, true);
            //设置网格的标签的样式和可见性
            pGraticule.LabelFormat.Font = MappingHelper.GetFont("Arial") as IFontDisp;
            pGraticule.Visible          = true;
            return(pGraticule);
        }
Пример #2
0
        public void CreateGrid(IActiveView activeView, IPageLayout pageLayout)
        {
            IMapGrid mapGrid = new GraticuleClass();

            mapGrid.Name = "Map Grid";
            IColor color = new RgbColorClass(); color.RGB = 0XBBBBBB;

            ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass();

            cartographicLineSymbol.Cap   = esriLineCapStyle.esriLCSButt;
            cartographicLineSymbol.Color = color; cartographicLineSymbol.Width = 2;
            mapGrid.LineSymbol           = (ILineSymbol)cartographicLineSymbol;
            mapGrid.Border     = null;
            mapGrid.TickLength = 15;

            cartographicLineSymbol       = new CartographicLineSymbolClass();
            cartographicLineSymbol.Cap   = esriLineCapStyle.esriLCSButt;
            cartographicLineSymbol.Color = color; cartographicLineSymbol.Width = 1;
            mapGrid.TickLineSymbol       = (ILineSymbol)cartographicLineSymbol;
            mapGrid.TickMarkSymbol       = null; mapGrid.SubTickCount = 5; mapGrid.SubTickLength = 10;

            cartographicLineSymbol       = new CartographicLineSymbolClass();
            cartographicLineSymbol.Cap   = esriLineCapStyle.esriLCSButt;
            cartographicLineSymbol.Color = color; cartographicLineSymbol.Width = 0.2;
            mapGrid.SubTickLineSymbol    = (ILineSymbol)cartographicLineSymbol;

            IGridLabel gridLabel = mapGrid.LabelFormat;

            gridLabel.LabelOffset = 15;
            mapGrid.SetTickVisibility(true, true, true, true);
            mapGrid.SetSubTickVisibility(true, true, true, true);
            mapGrid.SetLabelVisibility(true, true, true, true);
            mapGrid.Visible = true;
            IMeasuredGrid measuredGrid = mapGrid as IMeasuredGrid;

            measuredGrid.FixedOrigin   = true;
            measuredGrid.XIntervalSize = 10;
            measuredGrid.XOrigin       = 5;  //Shift grid 5
            measuredGrid.YIntervalSize = 10; //Parallel interval.
            measuredGrid.YOrigin       = 5;  //Shift grid 5

            IMap map = activeView.FocusMap;
            IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer;
            IFrameElement      frameElement      = graphicsContainer.FindFrame(map);
            IMapFrame          mapFrame          = frameElement as IMapFrame;
            IMapGrids          mapGrids          = null;

            mapGrids = mapFrame as IMapGrids;
            mapGrids.AddMapGrid(mapGrid);

            activeView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
        }