Exemplo n.º 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);
        }
Exemplo n.º 2
0
 private void openSHp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     String[] shpFile = GisClass.OpenShapeFile();
     if (shpFile != null)
     {
         this.axMapControl1.AddShapeFile(shpFile[0], shpFile[1]);
     }
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        private void AttrForm_Load(object sender, EventArgs e)
        {
            DataTable dt = GisClass.fillTable(pLayer, pLayer.Name);

            this.gridControl1.DataSource = dt;
        }
Exemplo n.º 7
0
 private void openGDB_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     IWorkspace workSpace = GisClass.GetFGDBWorkspace("aaa");
 }
Exemplo n.º 8
0
        /// <summary>
        /// 显示每日疫情
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //查询每日疫情
            ArrayList arr = new ArrayList();

            //获取日期
            if (this.selectedDate.EditValue == null)
            {
                MessageBox.Show("请选择日期");
                return;
            }
            arr.Add("YMD:'" + this.selectedDate.EditValue + "'");
            DataTable dt = OperateDatabase.select("data", arr);

            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("当日无数据");
                return;
            }
            //为当前图层添加字段
            IFeatureLayer layer = null;

            //遍历,寻找市域图层
            for (int i = 0; i < this.axMapControl1.Map.LayerCount; i++)
            {
                ILayer layer1 = this.axMapControl1.Map.get_Layer(i);
                if (layer1.Name == "市域")
                {
                    layer = layer1 as IFeatureLayer;
                    break;
                }
            }
            if (layer == null)
            {
                MessageBox.Show("请打开市域图层");
                return;
            }
            //获取图层字段,没有则添加一个num字段
            IFeatureClass featureClass = layer.FeatureClass;
            int           isExist      = featureClass.FindField("num");

            if (isExist == -1)
            {
                //添加一个字段
                IFields     pFields     = featureClass.Fields;
                IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
                IField      fld         = new FieldClass();
                IFieldEdit2 fldE        = fld as IFieldEdit2;
                fldE.Name_2      = "num";
                fldE.AliasName_2 = "数量";
                fldE.Type_2      = esriFieldType.esriFieldTypeSingle;
                featureClass.AddField(fld);
            }
            //给字段赋值
            IFeatureCursor pFtCursor     = featureClass.Search(null, false);
            IFeature       pFt           = pFtCursor.NextFeature();
            int            index1        = pFt.Fields.FindField("num");
            IDataset       dataset       = (IDataset)featureClass;
            IWorkspace     workspace     = dataset.Workspace;
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();
            while (pFt != null)
            {
                int    index = pFt.Fields.FindField("code");
                String code  = pFt.get_Value(index).ToString();

                DataRow[] drs   = dt.Select("CODE=" + code);
                DataTable dtNew = dt.Clone();
                for (int i = 0; i < drs.Length; i++)
                {
                    dtNew.ImportRow(drs[i]);
                }
                String num = dtNew.Rows[0]["AllConfiemed"].ToString();
                if (num == "")
                {
                    num = "0";
                }

                pFt.set_Value(index1, Convert.ToInt32(num));
                pFt.Store();
                pFt = pFtCursor.NextFeature();
            }
            GisClass.ClassRender(this.axMapControl1.ActiveView, layer, 6, "num");
            //GisClass.UniqueValueRender(this.axMapControl1.ActiveView,layer,10,"num");
        }
Exemplo n.º 9
0
        /// <summary>
        /// 打开mxd
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openMxd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            String MxdPath = GisClass.OpenMxd();

            axMapControl1.LoadMxFile(MxdPath);
        }