Пример #1
0
        private void 添加标注ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IRgbColor rgb = GisClass.GetRgbColor(0, 0, 0);

            GisClass.EnableFeatureLayerLabel(pCurrentLayer, "NAME", rgb, 10, "");
            axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
        }
Пример #2
0
        private void route_Search_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (this.start_time.EditValue == "" || this.end_time.EditValue == "")
            {
                MessageBox.Show("请选择起止日期");
                return;
            }
            SqlHelper           help = new SqlHelper();
            String              sql  = "select * from route where tm between '" + this.start_time.EditValue + "' and '" + this.end_time.EditValue + "'";
            DataTable           dt   = help.getMySqlRead(sql);
            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol();

            simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            IColor color = GisClass.GetRgbColor(0, 255, 0);

            simpleMarkerSymbol.Color = color;
            ILineElement       lineElement = new LineElementClass();
            IElement           ele1        = lineElement as IElement;
            ISegment           pSegment;
            ILine              pLine = null;
            object             o     = Type.Missing;
            ISegmentCollection pPath = new PathClass();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                IMarkerElement markerEle = new MarkerElementClass();
                IElement       ele       = markerEle as IElement;
                IPoint         point     = new PointClass();
                markerEle.Symbol = simpleMarkerSymbol;
                point.PutCoords(Double.Parse(dt.Rows[i]["x"].ToString()), Double.Parse(dt.Rows[i]["y"].ToString()));
                ele.Geometry = point;
                pGraphicsContainer.AddElement(ele, 0);
                //逐段添加线
                if (i > 0 && i < dt.Rows.Count)
                {
                    IPoint point1 = new PointClass();
                    point1.PutCoords(Double.Parse(dt.Rows[i - 1]["x"].ToString()), Double.Parse(dt.Rows[i - 1]["y"].ToString()));
                    pLine = new LineClass();
                    pLine.PutCoords(point1, point);
                    pSegment = pLine as ISegment;
                    pPath.AddSegment(pSegment, ref o, ref o);
                }


                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
            }
            IGeometryCollection pPolyline = new PolylineClass();

            pPolyline.AddGeometry(pPath as IGeometry, ref o, ref o);
            IPolyline polyline = pPolyline as IPolyline;
            //获取范围
            IEnvelope ev = polyline.Envelope;

            this.axMapControl1.ActiveView.Extent = ev;
            ele1.Geometry = pPolyline as IPolyline;
            pGraphicsContainer.AddElement(ele1, 0);
        }
Пример #3
0
        /// <summary>
        /// 添加图例
        /// </summary>
        /// <param name="activeView"></活动窗口>
        /// <param name="pageLayout"></布局窗口>
        /// <param name="pEnv"></包络线>
        private void MakeLegend(IActiveView pActiveView, IPageLayout pPageLayout, IEnvelope pEnv)
        {
            UID pID = new UID();

            pID.Value = "esriCarto.Legend";
            IGraphicsContainer pGraphicsContainer = pPageLayout as IGraphicsContainer;
            IMapFrame          pMapFrame          = pGraphicsContainer.FindFrame(pActiveView.FocusMap) as IMapFrame;
            IMapSurroundFrame  pMapSurroundFrame  = pMapFrame.CreateSurroundFrame(pID, null);              //根据唯一标示符,创建与之对应MapSurroundFrame
            IElement           pDeletElement      = this.axPageLayoutControl1.FindElementByName("Legend"); //获取PageLayout中的图例元素

            if (pDeletElement != null)
            {
                pGraphicsContainer.DeleteElement(pDeletElement);  //如果已经存在图例,删除已经存在的图例
            }
            //设置MapSurroundFrame背景
            ISymbolBackground pSymbolBackground = new SymbolBackgroundClass();
            IFillSymbol       pFillSymbol       = new SimpleFillSymbolClass();
            ILineSymbol       pLineSymbol       = new SimpleLineSymbolClass();

            pLineSymbol.Color            = GisClass.GetRgbColor(0, 0, 0);
            pFillSymbol.Color            = GisClass.GetRgbColor(240, 240, 240);
            pFillSymbol.Outline          = pLineSymbol;
            pSymbolBackground.FillSymbol = pFillSymbol;
            pMapSurroundFrame.Background = pSymbolBackground;
            //添加图例
            IElement pElement = pMapSurroundFrame as IElement;

            pElement.Geometry = pEnv as IGeometry;
            IMapSurround pMapSurround = pMapSurroundFrame.MapSurround;
            ILegend      pLegend      = pMapSurround as ILegend;

            pLegend.ClearItems();
            pLegend.Title = "图例";
            for (int i = 0; i < pActiveView.FocusMap.LayerCount; i++)
            {
                ILegendItem pLegendItem = new HorizontalLegendItemClass();
                pLegendItem.Layer            = pActiveView.FocusMap.get_Layer(i);//获取添加图例关联图层
                pLegendItem.ShowDescriptions = true;
                pLegendItem.Columns          = 1;
                pLegendItem.ShowHeading      = true;
                pLegendItem.ShowLabels       = true;
                pLegend.AddItem(pLegendItem);//添加图例内容
            }
            pGraphicsContainer.AddElement(pElement, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Пример #4
0
        private void drawCircle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.type = 3;
            ICircleElement circleEle = new CircleElementClass();

            pElement = circleEle as IElement;
            SimpleFillSymbol simpleFill = new SimpleFillSymbolClass();

            simpleFill.Style = esriSimpleFillStyle.esriSFSNull;
            simpleFill.Color = GisClass.GetRgbColor(255, 0, 0);
            //设置边线颜色
            ILineSymbol lineSymbol = new SimpleLineSymbol();

            lineSymbol.Color = GisClass.GetRgbColor(255, 0, 0);
            IFillShapeElement shapeEle = pElement as IFillShapeElement;

            simpleFill.Outline = lineSymbol;
            shapeEle.Symbol    = simpleFill;
            pGraphicsContainer.AddElement(pElement, 0);
        }