public void AddGraphicToMap(IMap map, IGeometry geometry, IRgbColor rgbColor, IRgbColor outlineRgbColor)
        {
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)map; // Explicit Cast
            IElement           element           = null;

            if ((geometry.GeometryType) == esriGeometryType.esriGeometryPoint)
            {
                // Marker symbols
                ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Color        = rgbColor;
                simpleMarkerSymbol.Outline      = true;
                simpleMarkerSymbol.OutlineColor = outlineRgbColor;
                simpleMarkerSymbol.Size         = 5;
                simpleMarkerSymbol.Style        = esriSimpleMarkerStyle.esriSMSCircle;

                IMarkerElement markerElement = new MarkerElementClass();
                markerElement.Symbol = simpleMarkerSymbol;
                element = (IElement)markerElement; // Explicit Cast
            }
            else if ((geometry.GeometryType) == esriGeometryType.esriGeometryPolyline)
            {
                //  Line elements
                ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
                simpleLineSymbol.Color = rgbColor;
                simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                simpleLineSymbol.Width = 5;

                ILineElement lineElement = new LineElementClass();
                lineElement.Symbol = simpleLineSymbol;
                element            = (IElement)lineElement; // Explicit Cast
            }
            else if ((geometry.GeometryType) == esriGeometryType.esriGeometryPolygon)
            {
                // Polygon elements
                ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
                simpleFillSymbol.Color = rgbColor;
                simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
                IFillShapeElement fillShapeElement = new PolygonElementClass();
                fillShapeElement.Symbol = simpleFillSymbol;
                element = (IElement)fillShapeElement; // Explicit Cast
            }
            if (!(element == null))
            {
                element.Geometry = geometry;
                graphicsContainer.AddElement(element, 0);
            }
        }
Ejemplo n.º 2
0
        private void DrawLineOnActiveView(int intFromLinkID, List <int> arrToLinks, double[,] arrXYCoord, IActiveView pActiveView)
        {
            try
            {
                IGraphicsContainer pGraphicContainer = pActiveView.GraphicsContainer;
                //pGraphicContainer.DeleteAllElements();

                IRgbColor pRgbColor = m_pSnippet.getRGB(0, 255, 255);

                ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
                pSimpleLineSymbol.Width = 2;
                pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                pSimpleLineSymbol.Color = pRgbColor;
                int intFromIdx = intFromLinkID;
                ESRI.ArcGIS.Geometry.IPoint FromP = new PointClass();
                FromP.X = arrXYCoord[intFromIdx, 0]; FromP.Y = arrXYCoord[intFromIdx, 1];

                int intArrLengthCnt = arrToLinks.Count;
                for (int i = 0; i < intArrLengthCnt; i++)
                {
                    int intToIdx = arrToLinks[i] - 1;

                    ESRI.ArcGIS.Geometry.IPoint ToP = new PointClass();
                    ToP.X = arrXYCoord[intToIdx, 0]; ToP.Y = arrXYCoord[intToIdx, 1];

                    IPolyline        polyline  = new PolylineClass();
                    IPointCollection pointColl = polyline as IPointCollection;
                    pointColl.AddPoint(FromP);
                    pointColl.AddPoint(ToP);

                    IElement     pElement     = new LineElementClass();
                    ILineElement pLineElement = (ILineElement)pElement;
                    pLineElement.Symbol = pSimpleLineSymbol;
                    pElement.Geometry   = polyline;

                    pGraphicContainer.AddElement(pElement, 0);
                }

                pActiveView.Refresh();
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Ejemplo n.º 3
0
        public static void DrawExtent(IEnvelope envelope, IMapControl2 mapControl)
        {
            IGraphicsContainer pGC = mapControl.Map as IGraphicsContainer;

            pGC.DeleteAllElements();

            IRgbColor fillColor    = CreateRgbColor(0, 0, 0, 0);
            IRgbColor outlineColor = CreateRgbColor(255, 0, 0);
            IElement  pElement     = new RectangleElementClass()
            {
                Geometry = envelope,
                Symbol   = CraeteSimpleFillSymbol(fillColor, outlineColor, 2)
            };

            pGC.AddElement(pElement, 0);
            mapControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtText.Text.Trim().Length == 0)
            {
                XtraMessageBox.Show("文本内容不能为空,请确认后再试!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //设置字体
            if (font == null)
            {
                FontDialog fontDialog = new FontDialog();
                font = fontDialog.Font;
            }
            IFontDisp fontDisp = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(font) as IFontDisp;

            textSymbol.Font = fontDisp;
            //设置颜色
            IColor color = new RgbColorClass();

            color.RGB        = (fontColor.B) * 65536 + (fontColor.G) * 256 + fontColor.R;
            textSymbol.Color = color;
            //添加或更新文本
            switch (textElementEditType)
            {
            case TextElementEditType.New:
                textElement        = new TextElementClass();
                textElement.Text   = txtText.Text;
                textElement.Symbol = textSymbol;

                IElement element = textElement as IElement;
                element.Geometry = textPoint;

                IGraphicsContainer graphicsContainer = activeView as IGraphicsContainer;
                graphicsContainer.AddElement(element, 0);
                break;

            case TextElementEditType.Modify:
                textElement.Text   = txtText.Text;
                textElement.Symbol = textSymbol;
                break;
            }
            //刷新
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 5
0
        public static void DrawPoint(IPoint point) // 主要用于示意学生位置
        {
            IGraphicsContainer pGC = m_pMapC2.Map as IGraphicsContainer;

            pGC.DeleteAllElements();
            pGC.AddElement(new MarkerElementClass()
            {
                Geometry         = point,
                SpatialReference = point.SpatialReference,
                Symbol           = new SimpleMarkerSymbolClass()
                {
                    Color = Func.CreateRgbColor(0, 0, 0),
                    Size  = 8
                }
            }, 0);
            m_pMapC2.Refresh(esriViewDrawPhase.esriViewGraphics);
        }
Ejemplo n.º 6
0
        public void AddCallout(IPoint pPoint, string strText)
        {
            DF2DApplication app = DF2DApplication.Application;

            m_ActiveView = app.Current2DMapControl.ActiveView;
            IGraphicsContainer pGraphicsContainer = m_ActiveView.GraphicsContainer;
            IPoint             pPointText         = new PointClass();

            pPointText.PutCoords(pPoint.X + 1.5, pPoint.Y + 1.5);

            ITextElement         pTextElement = new TextElementClass();
            IFormattedTextSymbol pTextSymbol  = new TextSymbolClass();

            IElement pElement = pTextElement as IElement;

            pTextElement.Text      = strText;
            pTextElement.ScaleText = true;
            pElement.Geometry      = pPointText;

            IRgbColor pRgbColor = GetRGBColor(255, 255, 0);

            ISimpleFillSymbol pSmplFill = new SimpleFillSymbolClass();

            pSmplFill.Color = pRgbColor;
            pSmplFill.Style = esriSimpleFillStyle.esriSFSHollow;

            IBalloonCallout pBalloonCallout = new BalloonCalloutClass();

            pBalloonCallout.Symbol          = pSmplFill;
            pBalloonCallout.Style           = esriBalloonCalloutStyle.esriBCSOval;
            pBalloonCallout.AnchorPoint     = pPointText;
            pBalloonCallout.LeaderTolerance = 5;

            pRgbColor = GetRGBColor(255, 0, 0);

            pTextSymbol.Background = pBalloonCallout as ITextBackground;
            pTextSymbol.Color      = pRgbColor;
            pTextSymbol.Size       = (app.Current2DMapControl.MapScale / 100) * 5;
            //pTextSymbol.Size = 25;
            pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;

            pTextElement.Symbol = pTextSymbol;


            pGraphicsContainer.AddElement(pElement, 1);
        }
        private void AddPolygonGraphic(IGeometry polyline, IGraphicsContainer graphics)
        {
            //ISimpleFillSymbol polygonSymbol = new SimpleFillSymbolClass();
            var polygonSymbol = (ISimpleFillSymbol)_objectFactory.Create("esriDisplay.SimpleFillSymbol");

            polygonSymbol.Color         = Defaults.PolygonFillColor.ToEsri(_objectFactory);
            polygonSymbol.Outline.Color = Defaults.PolygonOutlineColor.ToEsri(_objectFactory);
            polygonSymbol.Outline.Width = Defaults.PolygonOutlineWidth;
            //polygonSymbol.Style = esriSimpleFillStyle.esriSFSSolid;

            //IElement element = new PolygonElementClass();
            var element = (IElement)_objectFactory.Create("esriCarto.PolygonElement");

            ((IFillShapeElement)element).Symbol = polygonSymbol;
            element.Geometry = polyline;
            graphics.AddElement(element, 0);
        }
Ejemplo n.º 8
0
        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      = 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            = m_OperatePageLayout.GetRgbColor(0, 0, 0);
            pFillSymbol.Color            = m_OperatePageLayout.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 = false;
                pLegendItem.Columns          = 1;
                pLegendItem.ShowHeading      = true;
                pLegendItem.ShowLabels       = true;
                pLegend.AddItem(pLegendItem);//添加图例内容
            }
            pGraphicsContainer.AddElement(pElement, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Ejemplo n.º 9
0
        private void DrawLineInMap(List <TuLine> listDraw)
        {
            foreach (TuLine t in listDraw)
            {
                ILineElement pLineEle = new LineElementClass();
                pEle = pLineEle as IElement;
                ILineSymbol pLineSym = new SimpleLineSymbolClass();
                //pLineSym.Color = this.getRGBColor(0, 0, 255);
                pLineSym.Width  = 2;
                pLineEle.Symbol = pLineSym;
                //pFeat = new LineClass();
                //pFeat.Shape
                pEle.Geometry = CreatePolyline(t);;
                pGra.AddElement(pEle, 0);
                pAcitveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                //string PersionID = Guid.NewGuid().ToString();
                //string PersionName = PersionID;

                //IFeatureLayer pFeatureLyr = DrawnLayer as IFeatureLayer;
                //IFeatureClass pFeatCls = pFeatureLyr.FeatureClass;
                //IDataset pDataset = pFeatCls as IDataset;
                //IWorkspace pWS = pDataset.Workspace;
                //IWorkspaceEdit pWorkspaceEdit = pWS as IWorkspaceEdit;
                //pWorkspaceEdit.StartEditing(false);
                //pWorkspaceEdit.StartEditOperation();
                //IFeatureBuffer pFeatureBuffer;
                //IFeatureCursor pFeatureCuror;
                //IFeature pFeature;
                //IPolyline pPoint = CreatePolyline(t);
                //pFeatureBuffer = pFeatCls.CreateFeatureBuffer();
                //pFeatureCuror = pFeatCls.Insert(true);
                //pFeature = pFeatureBuffer as IFeature;

                //int field1 = pFeature.Fields.FindField("Name");
                //pFeature.set_Value(field1, PersionName);
                //field1 = pFeature.Fields.FindField("ID");
                //pFeature.set_Value(field1, PersionID);

                //IGeometry pPointGeo = pPoint as IGeometry;
                //pFeature.Shape = pPointGeo;
                //pFeatureCuror.InsertFeature(pFeatureBuffer);
                //pWorkspaceEdit.StopEditOperation();
                //pWorkspaceEdit.StopEditing(true);
            }
        }
Ejemplo n.º 10
0
        public static void DrawCenterPoint(IPoint point) // 绘制平均中心
        {
            IGraphicsContainer pGC = m_pMapC2.Map as IGraphicsContainer;

            pGC.AddElement(new MarkerElementClass()
            {
                Geometry         = point,
                SpatialReference = point.SpatialReference,
                Symbol           = new SimpleMarkerSymbolClass()
                {
                    Color = Func.CreateRgbColor(0, 0, 0),
                    Size  = 120,
                    Style = esriSimpleMarkerStyle.esriSMSCross
                }
            }, 0);
            m_pMapC2.Refresh(esriViewDrawPhase.esriViewGraphics);
        }
Ejemplo n.º 11
0
        private void textelementlable()
        {
            IFeatureLayer  pfl          = getlayerbyname(cbxLayer.SelectedItem.ToString());
            IFeatureClass  featureclass = pfl.FeatureClass;
            IFeatureCursor pFeatureCursor;

            pFeatureCursor = featureclass.Search(null, true);
            IFeature pFeat = pFeatureCursor.NextFeature();

            while (pFeat != null)
            {
                IFields   pFields = pFeat.Fields;
                int       i       = pFields.FindField(cbxField.SelectedItem.ToString());;
                IEnvelope pEnv    = pFeat.Extent;
                IPoint    pPoint  = new PointClass();
                pPoint.PutCoords(pEnv.XMin + pEnv.Width / 2, pEnv.YMin + pEnv.Height / 2);
                stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
                pFont.Name = comboBox2.SelectedItem.ToString();
                ITextSymbol pTextSymbol = new TextSymbolClass();

                pTextSymbol.Size = Convert.ToInt16(comboBox3.SelectedItem.ToString());
                pTextSymbol.Font = pFont;
                if (pRGB.NullColor)
                {
                    pRGB.Red   = 110;
                    pRGB.Blue  = 200;
                    pRGB.Green = 60;
                }
                pTextSymbol.Color = pRGB;

                ITextElement pTextEle = new TextElementClass();
                pTextEle.Text      = pFeat.get_Value(i).ToString();
                pTextEle.ScaleText = true;
                pTextEle.Symbol    = pTextSymbol;
                IElement pEle = pTextEle as IElement;
                pEle.Geometry = pPoint;
                IActiveView        pActiveView        = pMap as IActiveView;
                IGraphicsContainer pGraphicsContainer = pMap as IGraphicsContainer;
                pGraphicsContainer.AddElement(pEle, 0);
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                pPoint = null;
                pEle   = null;
                pFeat  = pFeatureCursor.NextFeature();
            }
        }
Ejemplo n.º 12
0
        private void dataGridViewX1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            pGra = AxMapCtrlHis.Map as IGraphicsContainer;
            if (pEleEnv != null)
            {
                try
                {
                    pGra.DeleteElement(pEleEnv);
                }
                catch { }
            }
            pEleEnv = null;
            DataGridViewRow row = dataGridViewX1.Rows[e.RowIndex];

            if (row == null)
            {
                return;
            }
            if (row.Tag == null)
            {
                return;
            }
            string sPrjID = row.Tag.ToString();

            m_sCurPrjName = row.Cells["ColPrjName"].Value.ToString();
            string sDataUpDate = Convert.ToDateTime(row.Cells["ColUpdateTime"].Value).ToString("yyyy-MM-dd HH:mm:ss");

            setMapLyrsDefinitionOfHPeriod(sPrjID, sDataUpDate);

            //ModHistory.ZoomToCaseArea(this.PrjEnvelope, AxMapCtrlHis.Map, sPrjID);

            pEleEnv = new LineElementClass();
            IGeometry            pGeo     = getEnvGeometry(sPrjID);
            ITopologicalOperator pTO      = pGeo as ITopologicalOperator;
            IGeometry            pOutLine = pTO.Boundary;

            if (pGeo == null)
            {
                return;
            }
            pEleEnv.Geometry = pOutLine;
            (pEleEnv as ILineElement).Symbol = getSymbol();
            pGra.AddElement(pEleEnv, 0);
            AxMapCtrlHis.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Ejemplo n.º 13
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            try
            {
                FrmCreatePicture frmCreatePicture = new FrmCreatePicture();
                if (frmCreatePicture.ShowDialog() == DialogResult.OK)
                {
                    string fileName = frmCreatePicture.FileName;
                    decimal size = frmCreatePicture.Size;

                    IPictureMarkerSymbol pPMS = new PictureMarkerSymbol();
                    pPMS.Size = (double)size;
                    string pictureType = fileName.Substring(fileName.LastIndexOf('.') + 1);
                    switch (pictureType.ToLower())
                    {
                        case "png":
                            pPMS.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, fileName);
                            break;
                        case "bmp":
                            pPMS.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);
                            break;
                        case "jpg":
                            pPMS.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureJPG, fileName);
                            break;
                    }

                    IMarkerElement pME = new MarkerElementClass();
                    pME.Symbol = pPMS as IMarkerSymbol;
                    IElement element = pME as IElement;

                    IPoint point = new PointClass();
                    point.PutCoords(mapX, mapY);

                    element.Geometry = point;

                    pGraphicsContainer.AddElement(element, 0);
                    m_ActiveView.Refresh();
                }
            }
            catch (System.Exception ex)
            {
            	
            }
           
        }
Ejemplo n.º 14
0
        public static void DrawLine(IPoint fromPoint, IPoint toPoint)
        {
            IPolyline pPolyline = new PolylineClass()
            {
                FromPoint = fromPoint,
                ToPoint   = toPoint
            };
            IRgbColor pColor = Func.CreateRgbColor(0, 0, 0);
            ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbolClass()
            {
                Cap   = esriLineCapStyle.esriLCSRound,
                Color = pColor,
                Width = 1
            };
            ILineProperties pLineProp = pCartoLineSymbol as ILineProperties;

            pLineProp.DecorationOnTop = true;
            ILineDecoration pLineDecoration = new LineDecorationClass();
            ISimpleLineDecorationElement pSimpleLineDecoElem = new SimpleLineDecorationElementClass()
            {
                MarkerSymbol = new ArrowMarkerSymbolClass()
                {
                    Size  = 16,
                    Color = pColor
                }
            };

            pSimpleLineDecoElem.AddPosition(1);
            pLineDecoration.AddElement(pSimpleLineDecoElem as ILineDecorationElement);
            pLineProp.LineDecoration = pLineDecoration;
            ILineSymbol pLineSymbol = pCartoLineSymbol as ILineSymbol;
            IElement    pElement    = new LineElementClass()
            {
                Symbol   = pLineSymbol,
                Geometry = pPolyline
            };
            IGraphicsContainer pGC = m_pMapC2.Map as IGraphicsContainer;

            pGC.AddElement(pElement, 0);
            IEnvelope pEnvelope = pPolyline.Envelope;

            pEnvelope.Expand(5, 5, true);
            m_pMapC2.Extent = pEnvelope;
            m_pMapC2.Refresh();
        }
Ejemplo n.º 15
0
        //获得三维视图的显示范围,并在二维地图上显示
        private void GlobeControl_DisplayEvents_AfterDraw(ISceneViewer pViewer)
        {
            IEnvelope      m_MapExtent     = new EnvelopeClass();
            IGlobeViewUtil m_GlobeViewUtil = axGlobeControl1.GlobeCamera as IGlobeViewUtil;

            m_GlobeViewUtil.QueryVisibleGeographicExtent(m_MapExtent);
            IGraphicsContainer pGra = axMapControl1.Map as IGraphicsContainer;
            IActiveView        pAv  = pGra as IActiveView;

            pGra.DeleteAllElements();

            IRectangleElement rec = new RectangleElementClass();
            IElement          ele = rec as IElement;

            ele.Geometry = m_MapExtent;

            IRgbColor pColor = new RgbColorClass();

            pColor.Red   = 255;
            pColor.Green = 0;
            pColor.Blue  = 0;

            ILineSymbol line = new SimpleLineSymbolClass();

            line.Color = pColor;
            line.Width = 2;

            pColor              = new RgbColorClass();
            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            pColor.Transparency = 0;

            IFillSymbol fill = new SimpleFillSymbolClass();

            fill.Outline = line;
            fill.Color   = pColor;

            IFillShapeElement pFillElement = ele as IFillShapeElement;

            pFillElement.Symbol = fill;

            pGra.AddElement((IElement)pFillElement, 0);
            pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Ejemplo n.º 16
0
        private void AddPointElement(IGeometry pGeom, IGraphicsContainer pGraphicsContainer)
        {
            ISimpleMarkerSymbol pSimpleSym = new SimpleMarkerSymbolClass();

            pSimpleSym.Style = esriSimpleMarkerStyle.esriSMSCross;
            pSimpleSym.Size  = 10;
            pSimpleSym.Color = getRGB(255, 0, 0);;

            IMarkerElement pMarkerElem = null;
            IElement       pElem;

            pElem              = new MarkerElementClass();
            pElem.Geometry     = pGeom as IPoint;
            pMarkerElem        = pElem as IMarkerElement;
            pMarkerElem.Symbol = pSimpleSym;
            pGraphicsContainer.AddElement(pElem, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 设置界址线标注
        /// </summary>
        /// <param name="map"></param>
        /// <param name="jzxs"></param>
        public static void SaveJZXBZMap(IMap map, IList <JZX> jzxs)
        {
            ITextSymbol        textSymbol = ArcGisUtils.CreateTextSymbol(10, "宋体");
            IGraphicsContainer pGraph     = map as IGraphicsContainer;

            foreach (JZX jzx in jzxs)
            {
                string bz = jzx.QLR + "\n" + jzx.BM;
                if (bz != null)
                {
                    bz = bz.Replace("成都高新区", "");
                    IPointCollection pc = jzx.Polyline as IPointCollection;
                    IPoint           pt = ArcGisUtils.GetPolyCore(pc);
                    var textELment      = ArcGisUtils.CreateTextElement(bz, pt, textSymbol);
                    pGraph.AddElement(textELment as IElement, 0);
                }
            }
        }
Ejemplo n.º 18
0
        private void Hawkeye_DrawExtent(IEnvelope envelope)
        {
            IGraphicsContainer pGC = axMapControl_hawkeye.Map as IGraphicsContainer;

            pGC.DeleteAllElements();
            IElement pElement = new RectangleElementClass()
            {
                Geometry = envelope,
                Symbol   = AeUtils.CreateSimpleFillSymbol(
                    AeUtils.CreateRgbColor(),          // 填充颜色 - 透明
                    AeUtils.CreateRgbColor(255, 0, 0), // 边框颜色 - 红色
                    2                                  // 边框大小
                    )
            };

            pGC.AddElement(pElement, 0);
            axMapControl_hawkeye.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 给多边形添加注记
        /// </summary>
        /// <param name="pGeometry"></param>
        /// <param name="pTextSymbol"></param>
        /// <param name="key"></param>
        public void AddTextElement(IGeometry pGeometry, ITextElement pTextElement, string key)
        {
            IActiveView        pActiveView        = mapControl.ActiveView;
            IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer;
            IEnvelope          envelope           = new EnvelopeClass();

            envelope = pGeometry.Envelope;
            IPoint pPoint = new PointClass();

            pPoint.PutCoords(envelope.XMin + envelope.Width * 0.5, envelope.YMin + envelope.Height * 0.5);
            IElement pElement = pTextElement as IElement;

            pElement.Geometry = pPoint;
            IElementProperties pElmentProperties = pElement as IElementProperties;

            pElmentProperties.Name = key;
            pGraphicsContainer.AddElement(pElement, 0);
        }
Ejemplo n.º 20
0
        private void GetFacilityInterdicted(IFeatureWorkspace featureWorkspace, int[] r)
        {
            int           p            = 22;
            IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("Hospitals");
            IFeature      pFeature;

            for (int i = 1; i <= p; i++)
            {
                pFeature = featureClass.GetFeature(i) as IFeature;
                IFeatureBuffer pFeatureBuffer = pFeature as IFeatureBuffer;
                pFeatureBuffer.set_Value(pFeature.Fields.FindField("interdicted"), r[i - 1]);
            }
            IMap pMap = this.axMapControl.Map;
            IGraphicsContainer pGraphicsContainerXL = pMap as IGraphicsContainer;

            //add interdicted points
            for (int i = 0; i < p; i++)
            {
                if (r[i] == 1)
                {
                    pFeature = featureClass.GetFeature(i) as IFeature;
                    IPoint       pPoint   = pFeature.Shape as IPoint;
                    ITextElement pTextEle = new TextElementClass();
                    IElement     pElement = pTextEle as IElement;
                    //text
                    pTextEle.Text      = "interdicted";
                    pTextEle.ScaleText = true;
                    pElement.Geometry  = pPoint;
                    //BalloonCallout
                    IBalloonCallout pBalloonCallout = new BalloonCalloutClass();
                    pBalloonCallout.Style       = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
                    pBalloonCallout.AnchorPoint = pPoint;
                    IFormattedTextSymbol pTextSymbol = new TextSymbolClass();
                    pTextSymbol.Background          = pBalloonCallout as ITextBackground;
                    pTextSymbol.Direction           = esriTextDirection.esriTDAngle;
                    pTextSymbol.Angle               = 15;
                    pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    pTextSymbol.VerticalAlignment   = esriTextVerticalAlignment.esriTVATop;
                    pTextEle.Symbol = pTextSymbol;
                    pGraphicsContainerXL.AddElement(pTextEle as IElement, 0);
                }
            }
            axMapControl.Refresh();
        }
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     // TODO:  Add AddBarriesTool.OnMouseDown implementation
     try
     {
         IPoint pStopsPoint = new PointClass();
         pStopsPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
         IFeature newPointFeature = pFeatureClass.CreateFeature();
         try
         {
             newPointFeature.Shape = pStopsPoint;
         }
         catch
         {
             IGeometry pGeo    = pStopsPoint;
             IZAware   pZAware = pGeo as IZAware;
             pZAware.ZAware        = false;
             newPointFeature.Shape = pGeo;
         }
         newPointFeature.Store();
         IGraphicsContainer pGrap = m_hookHelper.ActiveView as IGraphicsContainer;
         IColor             pColor;
         IRgbColor          pRgbColor = new RgbColorClass();
         pRgbColor.Red   = 255;
         pRgbColor.Green = 255;
         pRgbColor.Blue  = 255;
         pColor          = pRgbColor as IColor;
         IPictureMarkerSymbol pms = new PictureMarkerSymbolClass();
         pms.BitmapTransparencyColor = pColor;
         pms.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, @"C:\Users\Administrator\Desktop\突发环境事件应急资源调度系统\DynamicSchedulingofEmergencyResourceSystem\DynamicSchedulingofEmergencyResourceSystem\Resources\barries.png");
         pms.Size = 18;
         IMarkerElement pMarkerEle = new MarkerElementClass();
         pMarkerEle.Symbol            = pms as IMarkerSymbol;
         pStopsPoint.SpatialReference = m_hookHelper.ActiveView.FocusMap.SpatialReference;
         IElement pEle = pMarkerEle as IElement;
         pEle.Geometry = pStopsPoint;
         pGrap.AddElement(pEle, 1);
         m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
     }
 }
Ejemplo n.º 22
0
        private void DrawLineOnActiveView(List <int> lstIndices, double[][] arrValue, IActiveView pActiveView)
        {
            int intLstCnt = lstIndices.Count;

            IGraphicsContainer pGraphicContainer = pActiveView.GraphicsContainer;

            pGraphicContainer.DeleteAllElements();

            IRgbColor pRgbColor = m_pSnippet.getRGB(0, 255, 255);

            ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();

            pSimpleLineSymbol.Width = 2;
            pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            pSimpleLineSymbol.Color = pRgbColor;



            for (int i = 0; i < intLstCnt; i++)
            {
                int      intIdx      = lstIndices[i];
                double[] arrSelValue = arrValue[intIdx];
                //drawing a polyline
                IPoint FromP = new PointClass();
                FromP.X = arrSelValue[0]; FromP.Y = arrSelValue[1];

                IPoint ToP = new PointClass();
                ToP.X = arrSelValue[2]; ToP.Y = arrSelValue[3];

                IPolyline        polyline  = new PolylineClass();
                IPointCollection pointColl = polyline as IPointCollection;
                pointColl.AddPoint(FromP);
                pointColl.AddPoint(ToP);

                IElement     pElement     = new LineElementClass();
                ILineElement pLineElement = (ILineElement)pElement;
                pLineElement.Symbol = pSimpleLineSymbol;
                pElement.Geometry   = polyline;

                pGraphicContainer.AddElement(pElement, 0);
            }

            pActiveView.Refresh();
        }
Ejemplo n.º 23
0
        private void axMapControl_1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            //调动鹰眼图
            //定义边界对象
            IEnvelope        pEnv          = e.newEnvelope as IEnvelope;
            RectangleElement pRectangleEle = new RectangleElement();
            IElement         pEle          = pRectangleEle as IElement;

            pEle.Geometry = pEnv;

            //定义图像句柄指向鹰眼图
            IGraphicsContainer pGraphicsContainer = axMapControl_Eagle.Map as IGraphicsContainer;
            //获取鹰眼图地图数据的图形容器句柄
            IActiveView pActiveView = pGraphicsContainer as IActiveView;

            pGraphicsContainer.DeleteAllElements();

            //定义颜色
            IRgbColor pColor = new RgbColor();

            pColor.Red = 255;
            //定义线样式
            ILineSymbol pOutline = new SimpleLineSymbol();

            pOutline.Width = 2;
            pOutline.Color = pColor;
            //重新定义颜色
            pColor = new RgbColor();
            pColor.Transparency = 0;
            //定义填充样式
            IFillSymbol pFillSymbol = new SimpleFillSymbol();

            pFillSymbol.Color   = pColor;
            pFillSymbol.Outline = pOutline;
            //定义填充元素样式
            IFillShapeElement pFillshapeEle = pEle as IFillShapeElement;

            pFillshapeEle.Symbol = pFillSymbol;
            pEle = pFillshapeEle as IElement;

            //鹰眼图添加元素
            pGraphicsContainer.AddElement(pEle, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Ejemplo n.º 24
0
        private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            IEnvelope          pEnvelope          = (IEnvelope)e.newEnvelope;
            IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;
            IActiveView        pActiveView        = pGraphicsContainer as IActiveView;

            pGraphicsContainer.DeleteAllElements();
            IRectangleElement pRectangleEle = new RectangleElementClass();
            IElement          pElement      = pRectangleEle as IElement;

            pElement.Geometry = pEnvelope;
            IRgbColor pColor = new RgbColorClass();

            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            pColor.Transparency = 255;
            ILineSymbol pOutline = new SimpleLineSymbolClass();

            pOutline.Width = 3;
            pOutline.Color = pColor;
            //设置颜色属性
            pColor              = new RgbColorClass();
            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            pColor.Transparency = 0;

            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pFillSymbol.Color   = pColor;
            pFillSymbol.Outline = pOutline;
            IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;

            pFillShapeEle.Symbol = pFillSymbol;
            pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            IPoint ll, Ur;

            ll = axMapControl1.Extent.LowerLeft;
            Ur = axMapControl1.Extent.LowerRight;
            toolStripStatusLabel1.Text = "(" + Convert.ToString(ll.X) + "," + Convert.ToString(ll.Y) + ")";
        }
Ejemplo n.º 25
0
        private void AddSelectedElementByGraphicsSubLayer(string SubLayerName, IElement element)
        {
            IGraphicsLayer     sublayer = FindOrCreateGraphicsSubLayer(SubLayerName);
            IGraphicsContainer gc       = sublayer as IGraphicsContainer;

            gc.DeleteAllElements();
            gc.AddElement(element, 0);
            if (element.Geometry.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                IEnvelope pEnvelope = new EnvelopeClass();
                pEnvelope.XMin      = ((ESRI.ArcGIS.Geometry.IPoint)element.Geometry).X - 0.2;
                pEnvelope.XMax      = ((ESRI.ArcGIS.Geometry.IPoint)element.Geometry).X + 0.2;
                pEnvelope.YMin      = ((ESRI.ArcGIS.Geometry.IPoint)element.Geometry).Y - 0.2;
                pEnvelope.YMax      = ((ESRI.ArcGIS.Geometry.IPoint)element.Geometry).Y + 0.2;
                axMapControl.Extent = pEnvelope;
            }
            // axMapControl.FlashShape(element.Geometry);
            //axMapControl.Map.SelectByShape(element.Geometry, null, false);
        }
Ejemplo n.º 26
0
        private void AddLineElement(IGeometry pGeom, IGraphicsContainer pGraphicsContainer)
        {
            ISimpleLineSymbol pLineSym;

            pLineSym       = new SimpleLineSymbolClass();
            pLineSym.Color = getRGB(255, 0, 0);
            pLineSym.Width = 1;
            pLineSym.Style = esriSimpleLineStyle.esriSLSSolid;
            ILineElement plineEle;

            plineEle        = new LineElementClass();
            plineEle.Symbol = pLineSym;
            IElement pEles;

            pEles          = plineEle as IElement;
            pEles.Geometry = pGeom as IPolyline;
            pGraphicsContainer.AddElement(pEles, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
        public void AddMarker(IPoint pt)
        {
            IPictureMarkerSymbol pPicturemksb = new PictureMarkerSymbolClass();

            pPicturemksb.Size = 20;
            string picturePath = getPath(path1) + "\\Image\\周边1.png";

            pPicturemksb.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, picturePath);
            IMarkerElement pMarkerEle = new MarkerElement() as IMarkerElement;

            pMarkerEle.Symbol = pPicturemksb as IMarkerSymbol;
            IElement pEle = (IElement)pMarkerEle;

            pEle.Geometry = pt;
            IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer;

            pGraphicsContainer.AddElement(pEle, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Ejemplo n.º 28
0
        private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            //创建鹰眼中线框
            IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;
            IEnvelope          pEnv         = (IEnvelope)e.newEnvelope;
            IRectangleElement  pRectangeEle = new RectangleElementClass();
            IActiveView        pActiveView  = pGraphicsContainer as IActiveView;
            IElement           pEle         = pRectangeEle as IElement;

            pEle.Geometry = pEnv;
            //设置线框的边线对象,包括颜色和线宽
            IRgbColor pColor = new RgbColorClass();

            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            pColor.Transparency = 255;
            //产生一个线符号对象
            ILineSymbol pOutline = new SimpleLineSymbolClass();

            pOutline.Width = 1;
            pOutline.Color = pColor;
            //设置颜色属性
            pColor              = new RgbColorClass();
            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            pColor.Transparency = 0;
            //设置填充符号的属性
            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pFillSymbol.Color   = pColor;
            pFillSymbol.Outline = pOutline;
            IFillShapeElement pFillShapeEle = pEle as IFillShapeElement;

            pFillShapeEle.Symbol = pFillSymbol;
            //在绘制前,清楚axmapcontrol2中的任何图像
            pGraphicsContainer.DeleteAllElements();
            //鹰眼视图中添加线框
            pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0);
            //刷新地图
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 在屏幕中添加标记元素
        /// </summary>
        /// <param name="n"></param>
        private void drawElement(ExceptionsInfo n)
        {
            IFeature     pFeature;
            IQueryFilter pQFilter = new QueryFilter();

            pQFilter.WhereClause = "\"projectName\"='" + n.ProjectID + "'";
            IFeatureLayer      pFlayer        = LayerHelper.getFeatureLayerFromMap(axMapControl1.Map, "Cities"); //获取特定图层
            IFeatureCursor     pFtCursor      = pFlayer.Search(pQFilter, true);                                  //查找对应结果的要素
            IRgbColor          pColor1        = setRGBColor(255, 0, 0, 255);
            IRgbColor          pColor2        = setRGBColor(0, 255, 0, 255);
            IElement           ele            = createElement(pColor1, pColor2);
            IElementProperties pEleProperties = (IElementProperties)ele;

            pEleProperties.Name = n.ProjectID;                                                //设置element的Name属性方便查找
            IGraphicsContainer pGContainer = axMapControl1.Map as IGraphicsContainer;
            IActiveView        pView       = pGContainer as IActiveView;

            while ((pFeature = pFtCursor.NextFeature()) != null)
            {
                IPoint       pPoint = pFeature.Shape as IPoint;
                IElement     pEleTemp;
                IEnumElement pEnumEle = queryElementOnMap(pPoint, 0);
                if (pEnumEle != null)                                           //检查地图中是否已存在此元素
                {
                    while ((pEleTemp = pEnumEle.Next()) != null)
                    {
                        IElementProperties pEleProTemp = (IElementProperties)pEleTemp;
                        if (pEleProTemp.Name == n.ProjectID)
                        {
                            return;
                        }
                        //if (!pEleProTemp.Name.Contains(n.ProjectID))
                        //{
                        //    pEleProTemp.Name += "," + n.ProjectID;
                        //    pGContainer.UpdateElement((IElement)pEleProTemp);
                        //    return;
                        //}
                    }
                }
                ele.Geometry = pPoint;
                pGContainer.AddElement(ele, 0);
            }
        }
Ejemplo n.º 30
0
        public static void TextElementAdd(IPoint point, String content, System.Drawing.Font font, Color color, ref ITextElement textElementReturn)
        {
            ESRI.ArcGIS.Carto.ITextElement textElement = new TextElementClass();
            textElement.Text = content;

            ESRI.ArcGIS.Display.IRgbColor rgbColor = ColorToRgbColor(color);
            ITextSymbol textSymbol = SetUpTextSymbol(font, rgbColor);

            textElement.Symbol = textSymbol;
            IElement element = textElement as IElement;

            element.Geometry = point;

            IGraphicsContainer graphicsContainer = g_axPageLayoutControl.PageLayout as IGraphicsContainer;

            graphicsContainer.AddElement(element, 0);
            g_axPageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            textElementReturn = textElement;
        }
Ejemplo n.º 31
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if(pFlag==1)//缓冲区空间查询
               {
               IActiveView pActView = axMapControl1.Map as IActiveView;

               IPoint pPoint = pActView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

               ITopologicalOperator pTopo = pPoint as ITopologicalOperator;

               IGeometry pGeo = pTopo.Buffer(500);

               ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
               rgbColor.Red = 255;

               ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast
               ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
               simpleFillSymbol.Color = color;

               ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol;

               pActView.ScreenDisplay.SetSymbol(symbol);

               pActView.ScreenDisplay.DrawPolygon(pGeo);

               axMapControl1.Map.SelectByShape(pGeo, null, false);

               axMapControl1.FlashShape(pGeo, 1000, 2, symbol);

               axMapControl1.ActiveView.Refresh();
               }
               if (pFlag == 2)
               {
               pNetMap = axMapControl1.Map;

               pGC = pNetMap as IGraphicsContainer;

               IActiveView pActView = pNetMap as IActiveView;

               IPoint pPoint = pActView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

               object o = Type.Missing;
               object o1 = Type.Missing;

               pPointC.AddPoint(pPoint, ref o, ref o1);

               IElement Element;

               ITextElement Textelement = new TextElementClass();

               Element = Textelement as IElement;

               pClickedCount++;

               Textelement.Text = pClickedCount.ToString();

               Element.Geometry = pActView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

               pGC.AddElement(Element, 0);

               pActView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

               IFeatureClass pFeatureClass = pNaContext.NAClasses.get_ItemByName("Stops") as IFeatureClass;

               NASolve(pNaContext, pFeatureClass, pPointC, 5000);

               IGPMessages gpMessages = new GPMessagesClass();

               bool pBool = pNASolveClass.Solve(pNaContext, gpMessages, null);

               }

               if (pFlag == 3)//有向网络
               {
               IWorkspace pWs = GetMDBWorkspace(@".\data\Geometric.mdb");

               IFeatureWorkspace pFtWs = pWs as IFeatureWorkspace;

               IFeatureDataset pFtDataset = pFtWs.OpenFeatureDataset("work");

               double s = 0;

               IPolyline pPolyline = new PolylineClass();

               SolvePath(axMapControl1.Map, GetGeometricNetwork(pFtDataset, "TestGeometric"), "Weight", pPointC, 1000, ref pPolyline, ref s);

               IRgbColor pColor = new RgbColorClass();
               pColor.Red = 255;
               IElement pElement = new LineElementClass();
               ILineSymbol linesymbol = new SimpleLineSymbolClass();
               linesymbol.Color = pColor as IColor;
               linesymbol.Width = 100;

               pElement.Geometry = pPolyline;

               pGC.AddElement(pElement, 2);

               axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
               }
               if (pFlag == 4)
               {
               if(axMapControl1.Map.get_Layer(0)!=null)
               {
                   IRasterLayer pRasterLayer = axMapControl1.Map.get_Layer(0) as IRasterLayer;

                   IRasterSurface pRasterSurface = new RasterSurfaceClass();

                   pRasterSurface.PutRaster(pRasterLayer.Raster, 0);

                   ISurface pSurface = pRasterSurface as ISurface;

                  IPolyline pPolyline = axMapControl1.TrackLine() as  IPolyline;

                   IPoint pPoint =null ;

                    IPolyline pVPolyline =null;

                   IPolyline pInPolyline= null;

                   object pRef=0.13;

                   bool pBool =true;

                   double pZ1 = pSurface.GetElevation(pPolyline.FromPoint);

                   double pZ2= pSurface.GetElevation(pPolyline.ToPoint);

                   IPoint pPoint1 = new PointClass();

                   pPoint1.Z = pZ1;

                   pPoint1.X = pPolyline.FromPoint.X;

                   pPoint1.Y = pPolyline.FromPoint.Y;

                   IPoint pPoint2 = new PointClass();

                   pPoint2.Z = pZ2;

                   pPoint2.X = pPolyline.ToPoint.X;

                   pPoint2.Y = pPolyline.ToPoint.Y;

                   pSurface.GetLineOfSight(pPoint1, pPoint2, out pPoint, out pVPolyline,
                       out pInPolyline, out pBool, false, false, ref pRef);//大爷的,设置为true居然通不过bApplyCurvature和bApplyRefraction两项设置为true,surface必须定义成具有ZUnits的投影坐标

                   //This member should not be used in .NET. As a substitute, .NET developers must use IGeoDatabaseBridge2.GetLineOfSight.

                         //楼主,用IGeoDatabaseBridge2.GetLineOfSight.方法试试
                   if (pVPolyline != null)
                   {

                       IElement pLineElementV = new LineElementClass();

                       pLineElementV.Geometry = pVPolyline;

                       ILineSymbol pLinesymbolV = new SimpleLineSymbolClass();

                       pLinesymbolV.Width = 2;

                       IRgbColor pColorV = new RgbColorClass();

                       pColorV.Green =255;

                       pLinesymbolV.Color = pColorV;

                       ILineElement pLineV = pLineElementV as ILineElement;

                       pLineV.Symbol = pLinesymbolV;

                       axMapControl1.ActiveView.GraphicsContainer.AddElement(pLineElementV, 0);
                   }

                   if (pInPolyline != null)
                   {

                       IElement pLineElementIn = new LineElementClass();

                       pLineElementIn.Geometry = pInPolyline;

                       ILineSymbol pLinesymbolIn = new SimpleLineSymbolClass();

                       pLinesymbolIn.Width = 2;

                       IRgbColor pColorIn = new RgbColorClass();
                       pColorIn.Red = 255;

                       pLinesymbolIn.Color = pColorIn;
                       ILineElement pLineIn = pLineElementIn as ILineElement;

                       pLineIn.Symbol = pLinesymbolIn;

                       axMapControl1.ActiveView.GraphicsContainer.AddElement(pLineElementIn, 1);

                   }

                   axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                   axMapControl1.TrackCancel.Cancel();

               }
               }
        }
Ejemplo n.º 32
0
        /// <summary>
        /// 设置IGeometry的ISymbol
        /// </summary>
        /// <param name="pGeo"></param>
        /// 函数需要改进
        public static void SetGeoColor(IGeometry pGeo, IGraphicsContainer pGraphContainer, string strRasterName, ref Hashtable hashElementList)
        {
            IElement ipElement = GetElement(pGeo, strRasterName);

                ((IElementProperties)ipElement).Name = strRasterName;

                pGraphContainer.AddElement(ipElement, 0);

                if (!hashElementList.Contains(strRasterName))
                {
                    hashElementList.Add(strRasterName, ipElement);
                }
        }
Ejemplo n.º 33
0
        /// <summary>
        /// 设置IGeometry的ISymbol
        /// </summary>
        /// <param name="pGeo"></param>
        /// 函数需要改进
        public static void SetGeoColor(IGeometry pGeo, IGraphicsContainer pGraphContainer, string strElementName)
        {
            IElement ipElement = null;

            if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                ILineElement ipLineElement = new LineElementClass();
                RgbColor ipColor = new RgbColor();
                ipElement = (IElement)ipLineElement;
                ipElement.Geometry = pGeo;
                ISimpleFillSymbol ipFillSymbol = new SimpleFillSymbolClass();
                ILineSymbol ipLineSymbol = ipFillSymbol.Outline;
                ipLineSymbol.Width = 2.0;
                ipColor.Red = 0;
                ipColor.Blue = 0;
                ipColor.Green = 255;
                ipLineSymbol.Color = (IColor)ipColor;
                ipLineElement.Symbol = ipLineSymbol;
                ((IElementProperties)ipElement).Name = strElementName;
                pGraphContainer.AddElement(ipElement, 0);
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                RgbColor ipColor = new RgbColor();
                IPolygonElement ipPolygonElement = new PolygonElementClass();
                ipElement = (IElement)ipPolygonElement;
                ipElement.Geometry = pGeo;
                ISimpleFillSymbol ipFillSymbol = new SimpleFillSymbolClass();
                ILineSymbol ipLineSymbol = ipFillSymbol.Outline;
                ipLineSymbol.Width = 2.0;
                ipColor.Red = 0;
                ipColor.Blue = 0;
                ipColor.Green = 255;
                ipLineSymbol.Color = (IColor)ipColor;
                ipFillSymbol.Outline = ipLineSymbol;
                IFillShapeElement pFillElement = (IFillShapeElement)ipPolygonElement;
                ipFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
                pFillElement.Symbol = ipFillSymbol;
                ((IElementProperties)ipElement).Name = strElementName;
                pGraphContainer.AddElement(ipElement, 0);
            }
        }
Ejemplo n.º 34
0
 private void AddLineElement(IGeometry pGeom, IGraphicsContainer pGraphicsContainer)
 {
     ISimpleLineSymbol pLineSym;
     pLineSym = new SimpleLineSymbolClass();
     pLineSym.Color = getRGB(255, 0, 0);
     pLineSym.Width = 1;
     pLineSym.Style = esriSimpleLineStyle.esriSLSSolid;
     ILineElement plineEle;
     plineEle = new LineElementClass();
     plineEle.Symbol = pLineSym;
     IElement pEles;
     pEles = plineEle as IElement;
     pEles.Geometry = pGeom as IPolyline;
     pGraphicsContainer.AddElement(pEles, 0);
     pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
 }
Ejemplo n.º 35
0
        private void AddPointElement(IGeometry pGeom, IGraphicsContainer pGraphicsContainer)
        {
            ISimpleMarkerSymbol pSimpleSym = new SimpleMarkerSymbolClass();
            pSimpleSym.Style = esriSimpleMarkerStyle.esriSMSCross;
            pSimpleSym.Size = 10;
            pSimpleSym.Color = getRGB(255, 0, 0); ;

            IMarkerElement pMarkerElem = null;
            IElement pElem;
            pElem = new MarkerElementClass();
            pElem.Geometry = pGeom as IPoint;
            pMarkerElem = pElem as IMarkerElement;
            pMarkerElem.Symbol = pSimpleSym;
            pGraphicsContainer.AddElement(pElem, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
 /// <summary>
 ///     The draw aoi.
 /// </summary>
 /// <param name="graphicContainer">
 ///     The graphic container.
 /// </param>
 private void DrawAoi(IGraphicsContainer graphicContainer)
 {
     if (this.localElement != null)
     {
         graphicContainer.AddElement(this.localElement, 0);
     }
 }
Ejemplo n.º 37
0
        public IElement addTitleToLayout(IMxDocument pMxDoc,double S, double x, double y,  IGraphicsContainer pGc, bool b, string texto)
        {
            ITextElement pTxtElem;
            ITextSymbol pTxtSym = default(ITextSymbol);
            IRgbColor myColor = default(IRgbColor);
            stdole.IFontDisp myFont;
            IElement pElem;
            IEnvelope pEnv;
            IPoint pPoint = default(IPoint);
            try{
                // pGc.Reset()
                //Set the font and color properties
                //for the title
                myFont = (stdole.IFontDisp)new stdole.StdFont();
                myFont.Name = "Times New Roman";
                myFont.Bold = b;
               // myFont.Size = S;
                myColor = new RgbColor();
                myColor.Red = 0;
                myColor.Green = 0;
                myColor.Blue = 0;
                ///''''''''''''''''''''''''''''''
                //Create a text element
                pTxtElem = (ITextElement)new TextElement();

                //Create a text symbol
                pTxtSym = new TextSymbol();
                pTxtSym.Color = myColor;
                pTxtSym.Font = myFont;
                pTxtSym.Size = S;
                //Set symbol property
                pTxtElem.Symbol = pTxtSym;

                //set the text property to be the layer's name (Uppercase)
                pTxtElem.Text = texto;

                //Create an envelope for the TextElements Geometry
                pEnv = (IEnvelope)new Envelope();
                pPoint = new ESRI.ArcGIS.Geometry.Point();

                pPoint.X = x;
                pPoint.Y = y;
                pEnv.LowerLeft = pPoint;
                pPoint.X = 1;
                pPoint.Y = 1;
                pEnv.UpperRight = pPoint;
                //set the text elements geomtery
                pElem = (IElement)pTxtElem;
                pElem.Geometry = pEnv;

                //Add the element to the graphics container
                pGc.AddElement(pElem, 1);
                pMxDoc.ActiveView.Refresh();
                return (pElem);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "clsMapTools.addTitleToLayout");
                MessageBox.Show("Error: " + ex.StackTrace);
                return null ;
            }
        }
        /// <summary>
        ///     Draw the polygon contained within the properties.
        /// </summary>
        /// <param name="polyToBeDrawn">
        ///     The polygon to be drawn.
        /// </param>
        /// <param name="graphicContainer">
        ///     The graphic container.
        /// </param>
        private void DrawPoly(Properties polyToBeDrawn, IGraphicsContainer graphicContainer)
        {
            var poly = new PolygonClass();
            poly.Project(ArcMap.Document.ActiveView.Extent.SpatialReference);
            foreach (var pnt in polyToBeDrawn.Points)
            {
                var tempPoint = new PointClass();
                tempPoint.PutCoords(pnt.X, pnt.Y);
                tempPoint.SpatialReference = Jarvis.ProjectedCoordinateSystem;
                tempPoint.Project(ArcMap.Document.ActiveView.Extent.SpatialReference);
                poly.AddPoint(tempPoint);
            }

            IElement elm = new PolygonElementClass();
            elm.Geometry = poly;

            graphicContainer.AddElement(elm, 0);
        }