Exemplo n.º 1
1
        private void axSceneControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ISceneControlEvents_OnMouseDownEvent e)
        {
            IPoint pPoint = null;
            object objOwner = null;
            object objObject = null;

            axSceneControl1.SceneGraph.Locate(axSceneControl1.SceneViewer, e.x, e.y, esriScenePickMode.esriScenePickGeography, true, out pPoint, out objOwner, out objObject);

            ITextElement pTextElement = new TextElementClass();
            pTextElement.Text = "dddddd";

            IGraphicsContainer3D pGCon3D = axSceneControl1.Scene.BasicGraphicsLayer as IGraphicsContainer3D;
            IElement  pElement = new MarkerElementClass();
            IMarkerElement pPointElement = pElement as MarkerElementClass;
            ILineElement pLineElement = pElement as ILineElement;
            ISimpleLineSymbol pLSymbol = new SimpleLineSymbolClass();
            ISimpleMarkerSymbol pMSym = new SimpleMarkerSymbolClass();
            IColor pFromColor = new RgbColorClass();
            IRgbColor pRgbColor = pFromColor as IRgbColor;
            pRgbColor.Red = 255;
            pRgbColor.Green = 0;
            pRgbColor.Blue = 0;
            pMSym.Size = 10;
            pMSym.Color = pFromColor;
            pMSym.Style = esriSimpleMarkerStyle.esriSMSDiamond;
            pPointElement.Symbol = pMSym;
            pLSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            pElement.Geometry = pPoint;

            pGCon3D.AddElement(pElement as IElement );
            axSceneControl1.Scene.SceneGraph.RefreshViewers();
            IDisplay3D pIDisplay3D = axSceneControl1.Scene.SceneGraph as IDisplay3D ;
            pIDisplay3D.FlashLocation(pPoint);
        }
		private void DisplayAgentLocation(AGENT_IN_FIELD agent)
		{
			//Create a point and get the IPoint interface
			IPoint point = new PointClass();
			//Set the points x and y coordinates
			point.PutCoords(agent.Longitude, agent.Latitude);
			//Set the points spatial reference - WHERE the point is coming FROM
			point.SpatialReference = m_GeographicCoordinateSystem;
			//Project the point onto the displays current spatial reference - WHERE the point is going TO
			point.Project(m_ProjectedCoordinateSystem);

			//Create a marker element and get the IElement interface
			IElement element = new MarkerElementClass();
			//Set the elements geometry
			element.Geometry = point;

			//QI for the IMarkerElement interface from the IElement interface
			IMarkerElement markerElement = (IMarkerElement) element;
			//Set the marker symbol
			markerElement.Symbol = GetMarkerSymbol(agent.Located);

			//QI for the IElementProperties interface from the IMarkerElement interface
			IElementProperties elementProperties = (IElementProperties) markerElement;
			elementProperties.Name = agent.Located.ToString();

			//Add the element to the graphics container
			m_GraphicsContainer.AddElement(element, 0);
		}
Exemplo n.º 3
0
        private void DrawTraceRsult(IEnumNetEID JunctionEIDs, IEnumNetEID EdgEIDs)
        {
            if (JunctionBarrierEIDs == null || EdgEIDs == null)
            {
                return;
            }
            INetElements netElements = m_GeometryNetwork.Network as INetElements;
            int          userClssID  = -1;
            int          userID      = -1;
            int          userSubID   = -1;
            int          eid         = -1;
            //
            IFeatureClass fteClss;
            IFeature      feature;
            //设置管点和管线显示的Symbol
            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();

            simpleMarkerSymbol.Color = Method.Getcolor(255, 0, 0);
            simpleMarkerSymbol.Size  = 6;
            simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();

            simpleLineSymbol.Color = Method.Getcolor(255, 0, 0);
            simpleLineSymbol.Width = 2;
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            IElement element;

            //获取管点结果
            for (int i = 0; i < JunctionEIDs.Count; i++)
            {
                eid = JunctionEIDs.Next();
                netElements.QueryIDs(eid, esriElementType.esriETJunction, out userClssID, out userID, out userSubID);
                fteClss = GetFteClssByID(userClssID, this.Mapcontrol.Map);
                if (fteClss != null)
                {
                    feature          = fteClss.GetFeature(userID);
                    element          = new MarkerElementClass();
                    element.Geometry = feature.Shape;
                    ((IMarkerElement)element).Symbol   = simpleMarkerSymbol;
                    ((IElementProperties)element).Name = "Result";
                    this.Mapcontrol.ActiveView.GraphicsContainer.AddElement(element, 0);
                }
            }
            //获取管线结果
            for (int j = 0; j < EdgEIDs.Count; j++)
            {
                eid = EdgEIDs.Next();
                netElements.QueryIDs(eid, esriElementType.esriETEdge, out userClssID, out userID, out userSubID);
                fteClss = GetFteClssByID(userClssID, this.Mapcontrol.Map);
                if (fteClss != null)
                {
                    feature          = fteClss.GetFeature(userID);
                    element          = new LineElementClass();
                    element.Geometry = feature.Shape;
                    ((ILineElement )element).Symbol    = simpleLineSymbol;
                    ((IElementProperties)element).Name = "Result";
                    this.Mapcontrol.ActiveView.GraphicsContainer.AddElement(element, 0);
                }
            }
        }
Exemplo n.º 4
0
        public static IElement ConstructPointElement(IGeometry geometry, IColor color, esriSimple3DMarkerStyle style, double size)
        {
            ISimpleMarker3DSymbol simpleMarker3DSymbol = new SimpleMarker3DSymbolClass();

            simpleMarker3DSymbol.Style             = style;
            simpleMarker3DSymbol.ResolutionQuality = HighResolution;

            IMarkerSymbol markerSymbol = simpleMarker3DSymbol as IMarkerSymbol;

            markerSymbol.Color = color;
            markerSymbol.Size  = size;

            IMarker3DPlacement marker3DPlacement = markerSymbol as IMarker3DPlacement;

            marker3DPlacement.Units = Units;

            IMarkerElement markerElement = new MarkerElementClass();

            markerElement.Symbol = markerSymbol;

            IElement element = markerElement as IElement;

            element.Geometry = geometry;

            return(element);
        }
Exemplo n.º 5
0
        public void DisplaySymbol()
        {
            IGraphicsLayer layer;

            if (this.axSceneControl1.SceneGraph.Scene.LayerCount == 0)
            {
                layer = new GraphicsLayer3DClass();
                this.axSceneControl1.SceneGraph.Scene.AddLayer(layer as ILayer, false);
            }
            else
            {
                layer = this.axSceneControl1.SceneGraph.Scene.get_Layer(0) as IGraphicsLayer;
            }
            IGraphicsContainer3D containerd = layer as IGraphicsContainer3D;

            containerd.DeleteAllElements();
            if (this.m_pCharacterMarker3DSymbol != null)
            {
                IPoint  point = new PointClass();
                IZAware aware = point as IZAware;
                aware.ZAware = true;
                point.X      = 0.0;
                point.Y      = 0.0;
                point.Z      = 0.0;
                IElement       element  = new MarkerElementClass();
                IMarkerElement element2 = element as IMarkerElement;
                element2.Symbol  = this.m_pCharacterMarker3DSymbol;
                element.Geometry = point;
                containerd.AddElement(element);
            }
            this.axSceneControl1.SceneGraph.RefreshViewers();
        }
Exemplo n.º 6
0
        /// <summary>
        /// 通过添加Element方式高亮显示错误要素(解决点在特定比例尺中未显示问题)
        /// </summary>
        /// <param name="pGra"></param>
        /// <param name="in_fea"></param>
        private void MakeSymbol(IGraphicsContainer pGra, IFeature in_fea)
        {
            if (in_fea == null)
            {
                return;
            }
            pGra.DeleteAllElements();
            IActiveView pAcitveView = pGra as IActiveView;
            IElement    pEle;
            IRgbColor   pColor = new RgbColorClass();

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

            if (in_fea.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                IMarkerElement pMakEle = new MarkerElementClass();
                pEle = pMakEle as IElement;
                IMarkerSymbol pMakSym = new SimpleMarkerSymbolClass();
                pMakSym.Color  = pColor;
                pMakEle.Symbol = pMakSym;
                pEle.Geometry  = in_fea.Shape as ESRI.ArcGIS.Geometry.IGeometry;
                pGra.AddElement(pEle, 0);
                pAcitveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
        }
Exemplo n.º 7
0
        private void DisplayAgentLocation(AGENT_IN_FIELD agent)
        {
            //Create a point and get the IPoint interface
            IPoint point = new PointClass();

            //Set the points x and y coordinates
            point.PutCoords(agent.Longitude, agent.Latitude);
            //Set the points spatial reference - WHERE the point is coming FROM
            point.SpatialReference = m_GeographicCoordinateSystem;
            //Project the point onto the displays current spatial reference - WHERE the point is going TO
            point.Project(m_ProjectedCoordinateSystem);

            //Create a marker element and get the IElement interface
            IElement element = new MarkerElementClass();

            //Set the elements geometry
            element.Geometry = point;

            //QI for the IMarkerElement interface from the IElement interface
            IMarkerElement markerElement = (IMarkerElement)element;

            //Set the marker symbol
            markerElement.Symbol = GetMarkerSymbol(agent.Located);

            //QI for the IElementProperties interface from the IMarkerElement interface
            IElementProperties elementProperties = (IElementProperties)markerElement;

            elementProperties.Name = agent.Located.ToString();

            //Add the element to the graphics container
            m_GraphicsContainer.AddElement(element, 0);
        }
Exemplo n.º 8
0
        public void SelectPoint(string X, string Y, int CheckIfMapLoaded)
        {
            if (CheckIfMapLoaded == 0)
            {
                toolStripStatusLabel1.Text = "Map X Y";
            }
            else
            {
                toolStripStatusLabel1.Text = "X=" + X + "," + "Y=" + Y;

                int                 ConstantNum           = 255;
                IMarkerElement      MyIMarkerElement      = new MarkerElementClass();
                ISimpleMarkerSymbol MyISimpleMarkerSymbol = new SimpleMarkerSymbolClass();
                IRgbColor           MyIRGBColor           = new RgbColorClass();
                MyIRGBColor.Blue            = ConstantNum;
                MyISimpleMarkerSymbol.Color = MyIRGBColor;
                MyISimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCross;
                MyIMarkerElement.Symbol     = MyISimpleMarkerSymbol;
                IPoint MyIPoint = new PointClass();
                MyIPoint.X = double.Parse(X);
                MyIPoint.Y = double.Parse(Y);
                IElement MyIElement = MyIMarkerElement as IElement;
                MyIElement.Geometry = MyIPoint;
                axMapControl1.ActiveView.GraphicsContainer.AddElement(MyIElement, 0);
                axMapControl1.ActiveView.Refresh();

                ISpatialFilter MyISpatialFilter = new SpatialFilterClass();
                MyISpatialFilter.Geometry   = MyIPoint;
                MyISpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin;
                IFeatureLayer     SelectedLayer       = axMapControl1.ActiveView.FocusMap.get_Layer(comboBox13.SelectedIndex) as IFeatureLayer;
                IFeatureSelection MyIFeatureSelection = SelectedLayer as IFeatureSelection;
                MyIFeatureSelection.SelectFeatures(MyISpatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
                axMapControl1.ActiveView.Refresh();
            }
        }
Exemplo n.º 9
0
        public static void AddPointElement(IGraphicsContainer pGraphicsContainer,
                                           int intRed = 0, int intGreen = 0, int intBlue = 0)
        {
            IPoint ipt = new PointClass();

            ipt.PutCoords(10, 10);

            ISimpleMarkerSymbol pSimpleSym = new SimpleMarkerSymbolClass();

            pSimpleSym.Style = esriSimpleMarkerStyle.esriSMSCross;
            pSimpleSym.Size  = 10;
            pSimpleSym.Color = CHelpFunc.GenerateIRgbColor(intRed, intGreen, intBlue) as IColor;

            IMarkerElement pMarkerElem = null;
            IElement       pElem;

            pElem              = new MarkerElementClass();
            pElem.Geometry     = ipt;
            pMarkerElem        = pElem as IMarkerElement;
            pMarkerElem.Symbol = pSimpleSym;
            pGraphicsContainer.AddElement(pElem, 0);


            //pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 10
0
        private IElement GetElement(IGeometry geometry, double size, esriSimple3DMarkerStyle simple3DMarkerStyle)
        {
            IElement element;

            IMarkerElement markerElement = new MarkerElementClass();

            element = markerElement as IElement;

            ISimpleMarker3DSymbol simpleMarker3DSymbol = new SimpleMarker3DSymbolClass();

            simpleMarker3DSymbol.Style             = simple3DMarkerStyle;
            simpleMarker3DSymbol.ResolutionQuality = GetResolutionQuality();

            IMarkerSymbol markerSymbol = simpleMarker3DSymbol as IMarkerSymbol;

            markerSymbol.Color = ColorSelection.GetColor();
            markerSymbol.Size  = size;

            IMarker3DPlacement marker3DPlacement = markerSymbol as IMarker3DPlacement;

            SetMarker3DPlacement(marker3DPlacement, markerSymbol.Size);

            element.Geometry = geometry;

            markerElement.Symbol = markerSymbol;

            return(element);
        }
Exemplo n.º 11
0
        private void AddElement(IMap map, IPoint point)
        {
            IGraphicsContainer graphicsContainer = map as IGraphicsContainer;
            IRgbColor          color             = new RgbColorClass();

            color.Green = 80;
            color.Red   = 22;
            color.Blue  = 68;

            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol();

            simpleMarkerSymbol.Color = color;
            simpleMarkerSymbol.Size  = 15;
            simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;

            IElement element = null;

            IMarkerElement markerElement = new MarkerElementClass();

            markerElement.Symbol = simpleMarkerSymbol;
            element = markerElement as IElement;

            if (element != null)
            {
                element.Geometry = point;
            }
            graphicsContainer.AddElement(element, 0);

            //Flag the new text to invalidate.
            IActiveView activeView = map as IActiveView;

            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 12
0
        private void CreatePoint(double x, double y)
        {
            IPoint             pPoint      = new PointClass();
            IMap               pMap        = axMapControl.Map;
            IActiveView        pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement           pElement = new MarkerElementClass();

            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol     = new TextSymbolClass();
            IBalloonCallout      pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor            pColor          = new RgbColorClass();

            pColor.Red        = 150;
            pColor.Green      = 0;
            pColor.Blue       = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;

            pTextBackground                 = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background          = pTextBackground;
            ((ITextElement)pElement).Symbol = pTextSymbol;
            ((ITextElement)pElement).Text   = "测试";
            pPoint.X          = x;
            pPoint.Y          = y;
            pElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 13
0
        //ÉÁ˸µã
        private static void FlashPoint(IActiveView pActiveView, IGeometry pGeometry, int interval)
        {
            IScreenDisplay      pDisplay = pActiveView.ScreenDisplay;
            ISimpleMarkerSymbol pMarkerSymbol;
            ISymbol             pSymbol;
            IRgbColor           pRGBColor;

            pMarkerSymbol       = new SimpleMarkerSymbolClass();
            pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;

            pRGBColor       = new RgbColorClass();
            pRGBColor.Green = 148;
            pRGBColor.Red   = 32;
            pRGBColor.Blue  = 0;

            pSymbol      = pMarkerSymbol as ISymbol;
            pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
            pDisplay.SetSymbol(pSymbol);
            pDisplay.DrawPoint(pGeometry);
            System.Threading.Thread.Sleep(interval);
            pDisplay.DrawPoint(pGeometry);
            IElement pEle = new MarkerElementClass();//yjl¸ßÁÁÏÔʾ

            pEle.Geometry = pGeometry;
            (pEle as IMarkerElement).Symbol   = pSymbol as ISimpleMarkerSymbol;
            (pEle as IElementProperties).Name = _FlashTagName;
            (pActiveView as IGraphicsContainer).AddElement(pEle, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pEle, null);
            //pActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, pEle, null);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 创建几何图形对应的用于高亮显示的元素
        /// </summary>
        /// <param name="geometry"></param>
        /// <returns></returns>
        private static IElement CreateHightLightElement(IGeometry geometry)
        {
            IElement element   = null;
            IColor   redcolor  = ColorCreate.GetIColor(255, 0, 0, 50);
            IColor   bluecolor = ColorCreate.GetIColor(0, 0, 255);

            switch (geometry.GeometryType)
            {
            case esriGeometryType.esriGeometryLine:
            case esriGeometryType.esriGeometryPolyline:
                element          = new LineElementClass();
                element.Geometry = geometry;
                ((ILineElement)element).Symbol = SymbolCreate.GetSimpleLineSymbol(redcolor);
                break;

            case esriGeometryType.esriGeometryPolygon:
                element          = new PolygonElementClass();
                element.Geometry = geometry;
                ((PolygonElementClass)element).Symbol = SymbolCreate.GetSimpleFillSymbol(redcolor, bluecolor);
                break;

            case esriGeometryType.esriGeometryPoint:
                element          = new MarkerElementClass();
                element.Geometry = geometry;
                IMarkerSymbol pisymbol = new SimpleMarkerSymbolClass();
                pisymbol.Color = (IColor)redcolor;
                pisymbol.Size  = 6;
                ((MarkerElementClass)element).Symbol = pisymbol;
                break;
            }
            return(element);
        }
Exemplo n.º 15
0
        public void CreateTextElment(double x, double y, int index)
        {
            IMxDocument doc = ArcMap.Document;
            IMap        map = doc.FocusMap;

            IPoint pPoint = new PointClass();
            //IMap pMap = axMapControl.Map;
            IMap               pMap        = doc.FocusMap;
            IActiveView        pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement           pElement  = new MarkerElementClass();
            IElement           pTElement = new TextElementClass();

            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol     = new TextSymbolClass();
            IBalloonCallout      pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor            pColor          = new RgbColorClass();

            pColor.Red        = 150;
            pColor.Green      = 0;
            pColor.Blue       = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;

            pTextBackground                  = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background           = pTextBackground;
            ((ITextElement)pTElement).Symbol = pTextSymbol;
            ((ITextElement)pTElement).Text   = index.ToString();
            pPoint.X = x + 420;
            pPoint.Y = y + 420;
            //axMapControl.CenterAt(pPoint);
            pTElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pTElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 16
0
        //更新车辆的位置
        private void MovePointUpdateElement(IPoint point)
        {
            try
            {
                IGraphicsContainer pGraphicsContainer = Variable.pMapFrm.mainMapControl.ActiveView as IGraphicsContainer;
                //pGraphicsContainer.DeleteAllElements();
                IMarkerElement pMarkerElement = new MarkerElementClass();
                //ISimpleMarkerSymbol来设置点的属性
                ISimpleMarkerSymbol pSymbol   = new SimpleMarkerSymbolClass();
                IRgbColor           pRGBcolor = new RgbColorClass();
                pRGBcolor.Red   = 255;
                pRGBcolor.Green = 0;
                pRGBcolor.Blue  = 0;

                IPictureMarkerSymbol pms = new PictureMarkerSymbolClass();
                pms.BitmapTransparencyColor = pRGBcolor;
                pms.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, @"C:\Users\Administrator\Desktop\突发环境事件应急资源调度系统\DynamicSchedulingofEmergencyResourceSystem\DynamicSchedulingofEmergencyResourceSystem\Resources\vehicle.png");
                pms.Size = 6;
                pMarkerElement.Symbol = pms as IMarkerSymbol;

                //pSymbol.Color = pRGBcolor;
                //pMarkerElement.Symbol = pSymbol;
                Variable.PElement          = pMarkerElement as IElement;
                Variable.PElement.Geometry = point;
                pGraphicsContainer.AddElement(Variable.PElement, 0);
                //pGraphicsContainer.UpdateElement(Variable.PElement);
                //Variable.pMapFrm.mainMapControl.CenterAt(point);
                Variable.pMapFrm.mainMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                //Variable.pMapFrm.mainMapControl.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Draw a specified graphic on the map using the supplied colors.
        /// </summary>
        /// <param name="map">
        /// An IMap interface.
        /// </param>
        /// <param name="geometry">
        /// An IGeometry interface. It can be of the geometry type: esriGeometryPoint, esriGeometryPolyline, or esriGeometryPolygon.
        /// </param>
        /// <param name="rgbColor">
        /// An IRgbColor interface. The color to draw the geometry.
        /// </param>
        /// <param name="outlineRgbColor">
        /// An IRgbColor interface. For those geometry's with an outline it will be this color.
        /// </param>
        /// <remarks>
        /// Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh.
        /// </remarks>
        /// <returns>
        /// The <see cref="IElement"/>.
        /// </returns>
        private static IElement AddGraphicToMap(
            IMap map,
            IGeometry geometry,
            IRgbColor rgbColor,
            IRgbColor outlineRgbColor)
        {
            var      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         = 15;
                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
                ILineSymbol lineSymbol = new SimpleLineSymbolClass();
                lineSymbol.Color = rgbColor;
                lineSymbol.Width = 2.0;

                ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
                simpleFillSymbol.Color   = rgbColor;
                simpleFillSymbol.Style   = esriSimpleFillStyle.esriSFSNull;
                simpleFillSymbol.Outline = lineSymbol;

                IFillShapeElement fillShapeElement = new PolygonElementClass();
                fillShapeElement.Symbol = simpleFillSymbol;
                element = (IElement)fillShapeElement; // Explicit Cast
            }

            if (element != null)
            {
                element.Geometry = geometry;
                graphicsContainer.AddElement(element, 0);
            }

            return(element);
        }
Exemplo n.º 18
0
        internal void AddPPGeocodedPoint(double lat, double lng)
        {
            // Set the coordinate system of the data frame.
            ArcMap.Document.ActiveView.FocusMap.SpatialReference = DefineGCS();
            ArcMap.Document.ActiveView.Refresh();

            IPoint iPoint = new PointClass();

            // Set the coordinate system of your point to match your data frame
            iPoint.SpatialReference = DefineGCS();
            iPoint.X = lng;
            iPoint.Y = lat;

            IMap map = ArcMap.Document.ActiveView as IMap;
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)map; // Explicit Cast
            IElement           element           = null;

            // set the point color
            IColor pointColor = new RgbColor();

            //pointColor.RGB = 255255255;
            pointColor.RGB = 255000000;

            // Marker symbols
            ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
            simpleMarkerSymbol.Color        = pointColor;
            simpleMarkerSymbol.Outline      = true;
            simpleMarkerSymbol.OutlineColor = pointColor;
            simpleMarkerSymbol.Size         = 10;
            simpleMarkerSymbol.Style        = esriSimpleMarkerStyle.esriSMSCircle;

            // Marker element
            IMarkerElement markerElement = new MarkerElementClass();

            markerElement.Symbol       = simpleMarkerSymbol;
            markerElement.Symbol.Color = pointColor;

            element = (IElement)markerElement; // Explicit Cast

            // set the element name
            IElementProperties3 elemProperties = element as IElementProperties3;

            elemProperties.Name        = string.Concat(lng, " ,", lat);
            elemProperties.AnchorPoint = esriAnchorPointEnum.esriCenterPoint;

            // Add the element to a graphics container and refresh the ActiveView
            if (!(element == null))
            {
                element.Geometry = iPoint;
                graphicsContainer.AddElement(element, 0);
                IEnvelope envelope = new EnvelopeClass();
                envelope = ArcMap.Document.ActiveView.Extent;
                envelope.CenterAt(iPoint);
                //ArcMap.Document.ActiveView.Extent = envelope;
                //map.MapScale = 2400;
                map.MapScale = 5000;
                ArcMap.Document.ActiveView.Refresh();
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// 根据IGeometry 生成一个Element,显示在地图上
        /// </summary>
        /// <param name="pGC3D">element的容器</param>
        /// <param name="pGeom">element的几何信息</param>
        /// <param name="pSym">符号</param>
        /// <param name="sElementName">element的名称</param>
        public static void AddGraphics(IGraphicsContainer pGC, IGeometry pGeom, ISymbol pSym, string sElementName)
        {
            if (pGeom.IsEmpty)
            {
                return;
            }

            IElementProperties pElemProps;
            IElement           pElement = null;
            IFillShapeElement  pFillElement;

            //Point Type
            if (pGeom.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                pElement = new MarkerElementClass();
                IMarkerElement pPointElement;
                pPointElement        = (IMarkerElement)pElement;
                pPointElement.Symbol = (IMarkerSymbol)pSym;
                pElement.Geometry    = pGeom;
            }
            //Polyline Type
            else if (pGeom.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                pElement = new LineElementClass();
                ILineElement pLineElement;
                pLineElement        = (ILineElement)pElement;
                pLineElement.Symbol = (ILineSymbol)pSym;
                pElement.Geometry   = pGeom;
            }
            //Polygon Type
            else if (pGeom.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                pElement            = new PolygonElementClass();
                pFillElement        = (IFillShapeElement)pElement;
                pFillElement.Symbol = (IFillSymbol)pSym;
                pElement.Geometry   = pGeom;
            }
            //MultiPatch Type
            else if (pGeom.GeometryType == esriGeometryType.esriGeometryMultiPatch)
            {
                pElement            = new MultiPatchElementClass();
                pFillElement        = (IFillShapeElement)pElement;
                pFillElement.Symbol = (IFillSymbol)pSym;
                pElement.Geometry   = pGeom;
            }
            if (pElement == null)
            {
                //Console.WriteLine("添加element时Element为null!");
                return;
            }
            if (sElementName != "")
            {
                pElemProps      = (IElementProperties)pElement;
                pElemProps.Name = sElementName;
            }

            pGC.AddElement(pElement, 1);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 在图形容器中创建元素
        /// </summary>
        /// <param name="graphicsContainer">图形容器,新建的元素将添加到该图形容器中</param>
        /// <param name="geometry">几何图形</param>
        /// <param name="eType">元素类型(点、线、面、文本等)</param>
        /// <returns></returns>
        public static IElement CreateElement(this IGraphicsContainer graphicsContainer, IGeometry geometry, EDrawElementType eType)
        {
            IElement element = null;

            switch (eType)
            {
            case EDrawElementType.Point:
                if (!(geometry is IPoint))
                {
                    throw new ArgumentException($"参数{nameof(geometry)}不是点({typeof(IPoint)}),无法由此创建点元素");
                }
                element = new MarkerElementClass();
                break;

            case EDrawElementType.Polyline:
                if (!(geometry is IPolyline))
                {
                    throw new ArgumentException($"参数{nameof(geometry)}不是折线({typeof(IPolyline)}),无法由此创建线元素");
                }
                element = new LineElementClass();
                break;

            case EDrawElementType.Polygon:
                if (!(geometry is IPolygon))
                {
                    throw new ArgumentException($"参数{nameof(geometry)}不是多边形({typeof(IPolygon)}),无法由此创建多边形元素");
                }
                element = new PolygonElementClass();
                break;

            case EDrawElementType.Circle:
                if (!(geometry is IPolygon))
                {
                    throw new ArgumentException($"参数{nameof(geometry)}不是多边形({typeof(IPolygon)}),无法由此创建圆形元素");
                }
                element = new PolygonElementClass();
                break;

            case EDrawElementType.Rectangle:
                if (!(geometry is IEnvelope))
                {
                    throw new ArgumentException($"参数{nameof(geometry)}不是矩形框({typeof(IEnvelope)}),无法由此创建矩形元素");
                }
                element = new RectangleElementClass();
                break;

            case EDrawElementType.Text:
                if (!(geometry is IPoint))
                {
                    throw new ArgumentException($"参数{nameof(geometry)}不是点({typeof(IPoint)}),无法由此创建文本元素");
                }
                element = new TextElementClass();
                break;
            }
            element.Geometry = geometry;
            graphicsContainer.AddElement(element, 0);
            return(element);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 根据输入的要素在SceneControl中绘制元素     张琪   20110621
        /// </summary>
        /// <param name="pSceneControl"></param>
        /// <param name="pGeom">几何要素</param>
        /// <param name="pSym"></param>
        public void AddGraphic(ISceneControl pSceneControl, IGeometry pGeom, ISymbol pSym)
        {
            if (pGeom == null)
            {
                return;
            }
            IElement pElement = null;

            switch (pGeom.GeometryType.ToString())
            {
            case "esriGeometryPoint":    //点要素
                pElement = new MarkerElementClass();
                IMarkerElement pPointElement = pElement as IMarkerElement;
                if (pSym != null)
                {
                    IMarkerSymbol pMarker3DSymbol = pSym as IMarkerSymbol;
                    pPointElement.Symbol = pMarker3DSymbol as IMarkerSymbol;
                }
                break;

            case "esriGeometryPolyline":    //线要素
                pElement = new LineElementClass();
                ILineElement pLineElement = pElement as ILineElement;
                if (pSym != null)
                {
                    ILineSymbol pLineSymbol = pSym as ILineSymbol;
                    pLineElement.Symbol = pLineSymbol;
                }
                break;

            case "esriGeometryPolygon":    //面要素
                pElement = new PolygonElementClass();
                IFillShapeElement pFillElement = pElement as IFillShapeElement;
                if (pSym != null)
                {
                    IFillSymbol pFillSymbol = pSym as IFillSymbol;
                    pFillElement.Symbol = pFillSymbol;
                }
                break;

            case "esriGeometryMultiPatch":    //多面体要素
                pElement = new MultiPatchElementClass();
                IFillShapeElement pMultiPatchElement = pElement as IFillShapeElement;
                if (pSym != null)
                {
                    IFillSymbol pFillSymbol = pSym as IFillSymbol;
                    pMultiPatchElement.Symbol = pFillSymbol as IFillSymbol;
                }
                break;
            }
            pElement.Geometry = pGeom;
            IGraphicsContainer3D pGCon3D = pSceneControl.Scene.BasicGraphicsLayer as IGraphicsContainer3D;

            pGCon3D.AddElement(pElement);//在SceneControl中绘制要素
            IGraphicsSelection pGS = pGCon3D as IGraphicsSelection;

            pSceneControl.Scene.SceneGraph.RefreshViewers();
        }
        public void Update(double newvalue, int row, int column)//x,y一起修改
        {
            IPoint ipoint = (IPoint)pointCollection.Point[row];

            switch (column)
            {
            case 0:
                break;

            case 1:
                ipoint.X = newvalue;
                break;

            case 2:
                ipoint.Y = newvalue;
                break;
            }
            //对于pointCollection进行修改
            pointCollection.UpdatePoint(row, ipoint);
            //清空图像容器
            pGraphicsContainer.DeleteAllElements();

            IGeometry       polygon        = pointCollection as IGeometry;
            IPolygonElement polygonElement = new PolygonElementClass();
            IElement        polyElement    = polygonElement as IElement;

            polyElement.Geometry = polygon;
            pGraphicsContainer.AddElement((IElement)polygonElement, 0);
            m_form.axMapControl1.ActiveView.Refresh();

            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass();
                //markerSymbol的类型和分辨率
                ((ISimpleMarker3DSymbol)markerSymbol).Style             = esriSimple3DMarkerStyle.esriS3DMSSphere;
                ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0;

                //markerSymbol的颜色和大小
                IRgbColor color = new RgbColorClass();
                color.Red   = 255;
                color.Green = 0;
                color.Blue  = 0;

                markerSymbol.Size  = 5;
                markerSymbol.Color = color as IColor;

                IElement pElement = new MarkerElementClass();
                ((IMarkerElement)pElement).Symbol = markerSymbol;
                pElement.Geometry = pointCollection.Point[i];
                pGraphicsContainer.AddElement(pElement, 0);

                /*IElement pElement=new MarkerElementClass();
                *  pElement.Geometry = pointCollection.Point[i];
                *  pGraphicsContainer.AddElement(pElement, 0);*/
            }
            m_form.axMapControl1.ActiveView.Refresh();
        }
Exemplo n.º 23
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.º 24
0
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     // TODO:  Add AddNetStopsTool.OnMouseDown implementation
     try
     {
         //根据人为用鼠标在地图上单击的点的坐标新建站点要素
         IPoint pStopsPoint = new PointClass();
         //将鼠标在屏幕上点击的一点的坐标转换为地图上的坐标,并赋给pStopsPoint
         pStopsPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
         IFeature newPointFeature = inputFClass.CreateFeature();//创建新的障碍点要素
         try
         {
             pStopsPoint.Z         = 0;
             newPointFeature.Shape = pStopsPoint;      //将pStopsPoint赋给新要素的Shape属性
             IZAware pZAware = pStopsPoint as IZAware; //Z值为高程
             IMAware pMAware = pStopsPoint as IMAware; //M值是用来储存其他属性信息,如温度、浓度
             pZAware.ZAware = true;
             pMAware.MAware = true;
         }
         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;
         string picturePath = NetWorkAnalysClass.getPath(path) + "\\data\\Img\\stops.bmp";
         //添加自定义站点图片
         pms.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, picturePath);
         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
     {
         MessageBox.Show("添加站点失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
 }
Exemplo n.º 25
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add AddNetStopsTool.OnMouseDown implementation
            try
            {
                IPoint pStopsPoint = new PointClass();
                pStopsPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                IFeature newPointFeature = inputFClass.CreateFeature();
                try
                {
                    pStopsPoint.Z         = 0;
                    newPointFeature.Shape = pStopsPoint;
                    IZAware pZAware = pStopsPoint as IZAware;
                    IMAware pMAware = pStopsPoint as IMAware;
                    pZAware.ZAware = true;
                    pMAware.MAware = true;
                }
                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;

                string picturePath = ApplicationV.Data_ImgPath + "\\stops.bmp";

                //添加自定义站点图片
                pms.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, picturePath);
                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
            {
                MessageBox.Show("添加站点失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// 在图形容器中创建点元素
        /// </summary>
        /// <param name="graphicsContainer">图形容器,新建的元素将添加到该图形容器中</param>
        /// <param name="point">点图形,用于创建点元素</param>
        /// <returns></returns>
        public static IMarkerElement CreatePointElement(this IGraphicsContainer graphicsContainer, IPoint point)
        {
            IMarkerElement markerElement = new MarkerElementClass();
            IElement       element       = (IElement)markerElement;

            element.Geometry = point;

            graphicsContainer.AddElement(element, 0);
            return(markerElement);
        }
Exemplo n.º 27
0
        private void btn2D_Click(object sender, EventArgs e)
        {
            try
            {
                IGraphicsContainer pGraphicsContainer = pPageLayoutControl.ActiveView.GraphicsContainer as IGraphicsContainer;
                IMarkerElement     pMarkerElement     = new MarkerElementClass();

                //////正北方向
                //IPictureMarkerSymbol pPMarkerNorth = new PictureMarkerSymbolClass();
                //string MarkerNorthPath = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\BMP\NorthArrow.emf";
                //pPMarkerNorth.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureEMF, MarkerNorthPath);
                //pPMarkerNorth.Angle = 0;
                //pPMarkerNorth.Size = 100;

                ////太阳方向
                IPictureMarkerSymbol pPMarkerSun = new PictureMarkerSymbolClass();
                string MarkerSunPath             = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\BMP\SunArrow.emf";
                pPMarkerSun.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureEMF, MarkerSunPath);
                pPMarkerSun.Angle = (-1) * SunAzimuth.Value;
                pPMarkerSun.Size  = 100;

                ////地球方向
                IPictureMarkerSymbol pPMarkerEarth = new PictureMarkerSymbolClass();
                string MarkerEarthPath             = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\BMP\EarthArrow.emf";
                pPMarkerEarth.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureEMF, MarkerEarthPath);
                pPMarkerEarth.Angle = (-1) * EarAzimuth.Value;
                pPMarkerEarth.Size  = 100;


                IMultiLayerMarkerSymbol pMultiLayerMarkerSymbol = new MultiLayerMarkerSymbolClass();
                //pMultiLayerMarkerSymbol.AddLayer(pPMarkerNorth);
                pMultiLayerMarkerSymbol.AddLayer(pPMarkerSun);
                pMultiLayerMarkerSymbol.AddLayer(pPMarkerEarth);

                pMarkerElement.Symbol = pMultiLayerMarkerSymbol;
                IElement    pElement    = pMarkerElement as IElement;
                IActiveView pActiveView = pPageLayoutControl.ActiveView;
                IPageLayout pPageLayout = (IPageLayout)pActiveView;
                IPage       pPage       = pPageLayout.Page;
                double      pWidth      = pPage.PrintableBounds.XMin + 3;
                double      pHeigth     = pPage.PrintableBounds.YMax - 5;
                IPoint      pPoint      = new PointClass();
                pPoint.PutCoords(pWidth, pHeigth);
                pElement.Geometry = (IGeometry)pPoint;
                pGraphicsContainer.AddElement(pElement, 0);

                pPageLayoutControl.ActiveView.Refresh();
            }
            catch
            {
                MessageBox.Show(e.ToString());
            }

            this.Close();
        }
Exemplo n.º 28
0
        internal void AddPPGeocodedPoint(double lat, double lng)
        {
            // Set the coordinate system of the data frame.
            ArcMap.Document.ActiveView.FocusMap.SpatialReference = DefineGCS(); 
            ArcMap.Document.ActiveView.Refresh();

            IPoint iPoint = new PointClass();
            // Set the coordinate system of your point to match your data frame
            iPoint.SpatialReference = DefineGCS();
            iPoint.X = lng;
            iPoint.Y = lat;

            IMap map = ArcMap.Document.ActiveView as IMap;
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)map; // Explicit Cast
            IElement element = null;

            // set the point color
            IColor pointColor = new RgbColor();
            //pointColor.RGB = 255255255;
            pointColor.RGB = 255000000;

            // Marker symbols
            ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
            simpleMarkerSymbol.Color = pointColor;
            simpleMarkerSymbol.Outline = true;
            simpleMarkerSymbol.OutlineColor = pointColor;
            simpleMarkerSymbol.Size = 10;
            simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;

            // Marker element
            IMarkerElement markerElement = new MarkerElementClass();
            markerElement.Symbol = simpleMarkerSymbol;
            markerElement.Symbol.Color = pointColor;

            element = (IElement)markerElement; // Explicit Cast

            // set the element name
            IElementProperties3 elemProperties = element as IElementProperties3;
            elemProperties.Name = string.Concat(lng, " ,", lat);
            elemProperties.AnchorPoint = esriAnchorPointEnum.esriCenterPoint;

            // Add the element to a graphics container and refresh the ActiveView
            if (!(element == null))
            {
                element.Geometry = iPoint;
                graphicsContainer.AddElement(element, 0);
                IEnvelope envelope = new EnvelopeClass();
                envelope = ArcMap.Document.ActiveView.Extent;
                envelope.CenterAt(iPoint);
                //ArcMap.Document.ActiveView.Extent = envelope;
                //map.MapScale = 2400;
                map.MapScale = 5000;
                ArcMap.Document.ActiveView.Refresh();
            }
        }
Exemplo n.º 29
0
        private void miGeometry_Click(object sender, EventArgs e)
        {
            DataOperator dataoperator = new DataOperator(axMapControl1.Map);
            //ILayer layer;
            //layer = dataoperator.GetLayerByName("DLTB");
            //IFeatureLayer featureLayer = layer as IFeatureLayer;
            //IFeatureCursor featureCursor = featureLayer.Search(null, false);
            //IFeature feature = featureCursor.NextFeature();
            IGeometry geometry = new PolygonClass();

            geometry = m_polygon;

            IPointCollection pointCollection = (Polygon)geometry;
            DataTable        dataTable       = new DataTable();
            DataColumn       dataColumn      = new DataColumn();//创建列

            dataColumn            = new DataColumn();
            dataColumn.ColumnName = "number";//设置第一列,表示用户指定的列名
            dataColumn.DataType   = System.Type.GetType("System.String");
            dataTable.Columns.Add(dataColumn);

            dataColumn            = new DataColumn();
            dataColumn.ColumnName = "X";//设置第二列为在目标图层类作为分类标准的属性
            dataColumn.DataType   = System.Type.GetType("System.String");
            dataTable.Columns.Add(dataColumn);

            dataColumn            = new DataColumn();
            dataColumn.ColumnName = "Y";//设置第三列为在目标图层类作为分类标准的属性
            dataColumn.DataType   = System.Type.GetType("System.String");
            dataTable.Columns.Add(dataColumn);


            IGraphicsContainer pGraphicsContainer = axMapControl1.Map as IGraphicsContainer;
            DataRow            dataRow;

            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                dataRow    = dataTable.NewRow();
                dataRow[0] = i;
                dataRow[1] = pointCollection.Point[i].X;
                dataRow[2] = pointCollection.Point[i].Y;//将统计结果添加到第三列
                dataTable.Rows.Add(dataRow);
                IMarkerElement pMarkerElement = new MarkerElementClass();
                IElement       pElement       = pMarkerElement as IElement;
                pElement.Geometry = pointCollection.Point[i];
                pGraphicsContainer.AddElement((IElement)pMarkerElement, 0);
            }
            axMapControl1.ActiveView.Refresh();

            DataBoard dataBoard = new DataBoard("Position", dataTable);

            dataBoard.Show();
        }
Exemplo n.º 30
0
        /// <summary>
        /// 创建文本提示框
        /// </summary>
        /// <param name="x">提示框标识的位置X坐标</param>
        /// <param name="y">提示框标识的位置Y坐标</param>
        public void CreateTextElment(AxMapControl axMapControl1, double x, double y, string strText)
        {
            IPoint             pPoint      = new PointClass();
            IMap               pMap        = axMapControl1.Map;
            IActiveView        pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement           pElement  = new MarkerElementClass();
            IElement           pTElement = new TextElementClass();

            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol     = new TextSymbolClass();
            IBalloonCallout      pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor            pColor          = new RgbColorClass();

            pColor.Red        = 150;
            pColor.Green      = 0;
            pColor.Blue       = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;

            pTextBackground                  = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background           = pTextBackground;
            ((ITextElement)pTElement).Symbol = pTextSymbol;
            ((ITextElement)pTElement).Text   = strText;

            IPoint p = new PointClass();

            //设置点的坐标
            p.PutCoords(x, y);
            IElementProperties   ipElemProp;
            IMarkerElement       ipMarkerElement = new MarkerElementClass();
            IPictureMarkerSymbol ipPicMarker     = new PictureMarkerSymbolClass();

            ipPicMarker.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, "D:\\pro\\ArcGisView\\ArcGisView\\1.bmp");
            ipPicMarker.Size = 24;
            IRgbColor ipRGBTrans = new RgbColorClass();

            ipRGBTrans.RGB = 0xffffff;
            ipPicMarker.BitmapTransparencyColor = ipRGBTrans as IColor;
            ipMarkerElement.Symbol = ipPicMarker as IMarkerSymbol;
            IElement ipElement = ipMarkerElement as IElement;

            ipElement.Geometry = p as IGeometry;
            axMapControl1.ActiveView.GraphicsContainer.AddElement(ipElement, 0);

            pPoint.X           = x + 42;
            pPoint.Y           = y + 42;
            pTElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pTElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 31
0
        /// <summary>
        /// 高亮显示选择
        /// </summary>
        /// <returns>选择的要素高亮显示</returns>
        public static void ShowSelectionFeature(IMapControl2 pMapControl, IFeature pFeature)
        {
            //分点、线、面,给新的symbol
            if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                IMarkerSymbol pSymbol = new SimpleMarkerSymbolClass();
                pSymbol = (IMarkerSymbol)GetDefaultSymbol(pFeature.Shape.GeometryType);

                IElement pElement = new MarkerElementClass();
                pElement.Geometry = pFeature.Shape;

                IMarkerElement pMarkerElement;
                pMarkerElement        = (IMarkerElement)pElement;
                pMarkerElement.Symbol = pSymbol;

                pMapControl.ActiveView.GraphicsContainer.AddElement(pElement, 0);
            }
            else if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                ILineSymbol pSymbol = new SimpleLineSymbolClass();
                pSymbol = (ILineSymbol)GetDefaultSymbol(pFeature.Shape.GeometryType);

                IElement pElement = new LineElementClass();
                pElement.Geometry = pFeature.Shape;

                ILineElement pLineElement;
                pLineElement        = (ILineElement)pElement;
                pLineElement.Symbol = pSymbol;

                pMapControl.ActiveView.GraphicsContainer.AddElement(pElement, 0);
            }
            else if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                IElement  pElement = new LineElementClass();
                IPolyline pLine;
                pLine             = GetPolygonBoundary((IPolygon)pFeature.Shape);
                pElement.Geometry = pLine;

                ILineSymbol pSymbol = new SimpleLineSymbolClass();
                pSymbol = (ILineSymbol)GetDefaultSymbol(pLine.GeometryType);

                ILineElement pLineElement;
                pLineElement        = (ILineElement)pElement;
                pLineElement.Symbol = pSymbol;

                pMapControl.ActiveView.GraphicsContainer.AddElement(pElement, 0);
            }

            pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, pMapControl.ActiveView.Extent);//视图刷新
        }
Exemplo n.º 32
0
        /// <summary>
        /// Adds a sphere element to the given graphics layer at the specified position
        /// </summary>
        /// <param name="globeGraphicsLayer"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        private int AddTrackElement(IGlobeGraphicsLayer globeGraphicsLayer, esriGpsPositionInfo position)
        {
            if (null == globeGraphicsLayer)
            {
                return(-1);
            }

            //create a new point at the given position
            IPoint point = new PointClass();

            ((IZAware)point).ZAware = true;
            point.X = position.longitude;
            point.Y = position.latitude;
            point.Z = 0.0;

            //set the color for the element (red)
            IRgbColor color = new RgbColorClass();

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

            //create a new 3D marker symbol
            IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass();

            //set the marker symbol's style and resolution
            ((ISimpleMarker3DSymbol)markerSymbol).Style             = esriSimple3DMarkerStyle.esriS3DMSSphere;
            ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0;

            //set the symbol's size and color
            markerSymbol.Size  = 700;
            markerSymbol.Color = color as IColor;

            //crate the graphic element
            IElement trackElement = new MarkerElementClass();

            //set the element's symbol and geometry (location and shape)
            ((IMarkerElement)trackElement).Symbol = markerSymbol;
            trackElement.Geometry = point as IPoint;


            //add the element to the graphics layer
            int elemIndex = 0;

            ((IGraphicsContainer)globeGraphicsLayer).AddElement(trackElement, 0);

            //get the element's index
            globeGraphicsLayer.FindElementIndex(trackElement, out elemIndex);
            return(elemIndex);
        }
Exemplo n.º 33
0
        private void AddElement(IMap map, IGeometry geom)
        {
            IGraphicsContainer graphicsContainer = map as IGraphicsContainer;
            IRgbColor          color             = new RgbColorClass();

            color.Green = 80;
            color.Red   = 22;
            color.Blue  = 68;

            IElement element = null;

            if (geom is IPoint)
            {
                ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol();
                simpleMarkerSymbol.Color = color;
                simpleMarkerSymbol.Size  = 15;
                simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;

                IMarkerElement markerElement = new MarkerElementClass();

                markerElement.Symbol = simpleMarkerSymbol;
                element = markerElement as IElement;

                if (element != null)
                {
                    element.Geometry = geom;
                }
            }
            else if (geom is IPolygon)
            {
                var temp = new SimpleLineSymbol();
                temp.Color = color;
                temp.Style = esriSimpleLineStyle.esriSLSSolid;
                temp.Width = 2;
                var s = new SimpleFillSymbol();
                s.Color   = color;
                s.Outline = temp;
                s.Style   = esriSimpleFillStyle.esriSFSBackwardDiagonal;

                var pe = new PolygonElementClass();
                element = pe as IElement;
                var fill = pe as IFillShapeElement;
                fill.Symbol      = s;
                element.Geometry = geom;
            }
            graphicsContainer.AddElement(element, 0);
            IActiveView activeView = map as IActiveView;

            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
        private IElement GetElement(IGeometry geometry, double size, IStyleGalleryItem styleGalleryItem)
        {
            IElement element;

            IMarkerElement markerElement = new MarkerElementClass();
            element = markerElement as IElement;

            IMarkerSymbol markerSymbol = styleGalleryItem.Item as IMarkerSymbol;
            markerSymbol.Size = size;

            element.Geometry = geometry;

            markerElement.Symbol = markerSymbol;

            return element;
        }
Exemplo n.º 35
0
        ///<summary>Draw a specified graphic on the map using the supplied colors.</summary>
        ///      
        ///<param name="map">An IMap interface.</param>
        ///<param name="geometry">An IGeometry interface. It can be of the geometry type: esriGeometryPoint, esriGeometryPolyline, or esriGeometryPolygon.</param>
        ///<param name="rgbColor">An IRgbColor interface. The color to draw the geometry.</param>
        ///<param name="outlineRgbColor">An IRgbColor interface. For those geometry's with an outline it will be this color.</param>
        ///      
        ///<remarks>Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh.</remarks>
        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 = 15;
                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.esriSFSForwardDiagonal;
                IFillShapeElement fillShapeElement = new PolygonElementClass();
                fillShapeElement.Symbol = simpleFillSymbol;
                element = (IElement)fillShapeElement; // Explicit Cast
            }
            if (!(element == null))
            {
                element.Geometry = geometry;
                graphicsContainer.AddElement(element, 0);
            }
        }
        private IElement GetElement(IGeometry geometry, double size, esriSimpleMarkerStyle simpleMarkerStyle)
        {
            IElement element;

            IMarkerElement markerElement = new MarkerElementClass();
            element = markerElement as IElement;

            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
            simpleMarkerSymbol.Style = simpleMarkerStyle;
            simpleMarkerSymbol.Color = ColorSelection.GetColor();
            simpleMarkerSymbol.Size = size;

            element.Geometry = geometry;

            markerElement.Symbol = simpleMarkerSymbol;

            return element;
        }
        private IElement GetElement(IGeometry geometry, double size, esriSimple3DMarkerStyle simple3DMarkerStyle)
        {
            IElement element;

            IMarkerElement markerElement = new MarkerElementClass();
            element = markerElement as IElement;

            ISimpleMarker3DSymbol simpleMarker3DSymbol = new SimpleMarker3DSymbolClass();
            simpleMarker3DSymbol.Style = simple3DMarkerStyle;
            simpleMarker3DSymbol.ResolutionQuality = GetResolutionQuality();

            IMarkerSymbol markerSymbol = simpleMarker3DSymbol as IMarkerSymbol;
            markerSymbol.Color = ColorSelection.GetColor();
            markerSymbol.Size = size;

            IMarker3DPlacement marker3DPlacement = markerSymbol as IMarker3DPlacement;
            SetMarker3DPlacement(marker3DPlacement, markerSymbol.Size);

            element.Geometry = geometry;

            markerElement.Symbol = markerSymbol;

            return element;
        }
        private void OnFlashPointCommand(object obj)
        {
            if(amCoordGetter != null && amCoordGetter.Point != null)
            {
                IGeometry address = amCoordGetter.Point;

                // Map und View
                IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument;
                IActiveView activeView = mxdoc.ActivatedView;
                IMap map = mxdoc.FocusMap;
                IEnvelope envelope = activeView.Extent;

                ClearGraphicsContainer(map);

                IScreenDisplay screenDisplay = activeView.ScreenDisplay;
                short screenCache = Convert.ToInt16(esriScreenCache.esriNoScreenCache);

                ISpatialReference outgoingCoordSystem = map.SpatialReference;
                address.Project(outgoingCoordSystem);

                IRgbColor color = new RgbColorClass();
                color.Green = 80;
                color.Red = 22;
                color.Blue = 68;

                ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol();
                simpleMarkerSymbol.Color = color;
                simpleMarkerSymbol.Size = 15;
                simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;

                IElement element = null;

                IMarkerElement markerElement = new MarkerElementClass();

                markerElement.Symbol = simpleMarkerSymbol;
                element = markerElement as IElement;

                IPolygon poly = null;
                if (InputCoordinateType == CoordinateType.MGRS || InputCoordinateType == CoordinateType.USNG)
                {
                    poly = GetMGRSPolygon(address as IPoint);
                }

                if (poly != null)
                {
                    address = poly;
                }
                var av = mxdoc.FocusMap as IActiveView;
                FlashGeometry(address, color, av.ScreenDisplay, 500);

                AddElement(map, address);

                // do not center if in layout view
                if (mxdoc.ActiveView is IMap)
                {
                    if (poly != null && !poly.IsEmpty && (poly as IArea) != null)
                        envelope.CenterAt((poly as IArea).Centroid);
                    else
                        envelope.CenterAt(amCoordGetter.Point);

                    activeView.Extent = envelope;
                    activeView.Refresh();
                }
            }
        }
        private void AddElement(IMap map, IGeometry geom)
        {
            IGraphicsContainer graphicsContainer = map as IGraphicsContainer;
            IRgbColor color = new RgbColorClass();
            color.Green = 80;
            color.Red = 22;
            color.Blue = 68;

            IElement element = null;

            if (geom is IPoint)
            {
                ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol();
                simpleMarkerSymbol.Color = color;
                simpleMarkerSymbol.Size = 15;
                simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;

                IMarkerElement markerElement = new MarkerElementClass();

                markerElement.Symbol = simpleMarkerSymbol;
                element = markerElement as IElement;

                if (element != null)
                {
                    element.Geometry = geom;
                }
            }
            else if(geom is IPolygon)
            {
                var temp = new SimpleLineSymbol();
                temp.Color = color;
                temp.Style = esriSimpleLineStyle.esriSLSSolid;
                temp.Width = 2;
                var s = new SimpleFillSymbol();
                s.Color = color;
                s.Outline = temp;
                s.Style = esriSimpleFillStyle.esriSFSBackwardDiagonal;

                var pe = new PolygonElementClass();
                element = pe as IElement;
                var fill = pe as IFillShapeElement;
                fill.Symbol = s;
                element.Geometry = geom;
            }
            graphicsContainer.AddElement(element, 0);
            IActiveView activeView = map as IActiveView;
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 40
0
        private void CreatePoint(double x, double y)
        {
            IPoint pPoint = new PointClass();
            IMap pMap = axMapControl.Map;
            IActiveView pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement pElement = new MarkerElementClass();

            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol = new TextSymbolClass();
            IBalloonCallout pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor pColor = new RgbColorClass();
            pColor.Red = 150;
            pColor.Green = 0;
            pColor.Blue = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;
            pTextBackground = (ITextBackground)pBalloonCallout;
            //pTextSymbol.Background = pTextBackground;
            //((ITextElement)pElement).Symbol = pTextSymbol;
            //((ITextElement)pElement).Text = "测试";
            pPoint.X = x + 42;
            pPoint.Y = y + 42;

            pPoint.PutCoords(x, y);
            ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
            pPoint.SpatialReference = pSRF.CreateProjectedCoordinateSystem(2414);
            pPoint.Project(pSRF.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_Beijing1954));

            pElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 41
0
        /// <summary>
        /// ���Ƽ���ͼ��
        /// </summary>
        /// <params name="geoType"></params>
        /// <params name="geometry"></params>
        /// <returns></returns>
        ESRI.ArcGIS.Carto.IElement createElement_x(ESRI.ArcGIS.Geometry.IGeometry geometry)
        {
            IElement element = null;
            try
            {
                switch (geometry.GeometryType)
                {
                    case esriGeometryType.esriGeometryPolyline://Polyline��
                        ISimpleLineSymbol simpleLineSymbol = m_NewLineFeedback.Symbol as ISimpleLineSymbol;

                        ILineElement lineElement = new LineElementClass();
                        lineElement.Symbol = simpleLineSymbol as ILineSymbol;
                        element = lineElement as IElement;
                        element.Geometry = geometry;
                        break;
                    case esriGeometryType.esriGeometryPoint:
                        //���ý�����
                        IRgbColor pRGB = new RgbColorClass();
                        pRGB.Red = 255;
                        pRGB.Green = 0;
                        pRGB.Blue = 0;

                        ISimpleMarkerSymbol pSimpleMarkSymbol = new SimpleMarkerSymbolClass();
                        pSimpleMarkSymbol.Color = pRGB as IColor;
                        pSimpleMarkSymbol.Size = 2;
                        pSimpleMarkSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare;

                        IMarkerElement pMarkerElement = new MarkerElementClass();
                        pMarkerElement.Symbol = pSimpleMarkSymbol as IMarkerSymbol;
                        element = pMarkerElement as IElement;
                        element.Geometry = geometry as IGeometry;
                        break;
                }
            }
            catch
            { }
            return element;
        }
Exemplo n.º 42
0
        ///<summary>Draw a specified graphic on the map using the supplied colors.</summary>
        ///<param name="map">An IMap interface.</param>
        ///<param name="geometry">An IPoint interface. It can be of the geometry type esriGeometryPoint</param>
        ///<param name="rgbColor">An IRgbColor interface. The color to draw the geometry.</param>
        ///<param name="outlineRgbColor">An IRgbColor interface. For marker anfd polygons the outline it will be this color, for lines this is ignored</param>
        ///<param name="size">size in pixel as integer linewidth of outLine or of intire marker if point</param>
        ///<param name="userLock">locked from editing by user?</param>
        public static IElement AddGraphicToMap(IMap map, IGeometry geometry, IRgbColor rgbColor, IRgbColor outlineRgbColor, int size = 5, bool userLock = false)
        {
            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 = size;
                simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;

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

                ILineElement lineElement = new LineElementClass();
                lineElement.Symbol = simpleLineSymbol;
                element = (IElement)lineElement; // Explicit Cast
            }
            else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
            {
                // Polygon elements
                ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
                simpleLineSymbol.Color = outlineRgbColor;
                simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                simpleLineSymbol.Width = size;

                ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
                simpleFillSymbol.Color = rgbColor;
                simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSForwardDiagonal;
                simpleFillSymbol.Outline = simpleLineSymbol;

                IFillShapeElement fillShapeElement = new PolygonElementClass();
                fillShapeElement.Symbol = simpleFillSymbol;

                element = (IElement)fillShapeElement; // Explicit Cast
            }
            if (!(element == null))
            {
                element.Geometry = geometry;
                element.Locked = userLock;
                graphicsContainer.AddElement(element, 0);
            }
            return element;
        }
        private IElement OSMGeometryToGraphicElement(IGeometry featureGeometry, IColor featureColor)
        {
            IElement graphicElement = null;

            switch (featureGeometry.GeometryType)
            {
                case esriGeometryType.esriGeometryAny:
                    break;
                case esriGeometryType.esriGeometryBag:
                    break;
                case esriGeometryType.esriGeometryBezier3Curve:
                    break;
                case esriGeometryType.esriGeometryCircularArc:
                    break;
                case esriGeometryType.esriGeometryEllipticArc:
                    break;
                case esriGeometryType.esriGeometryEnvelope:
                    break;
                case esriGeometryType.esriGeometryLine:
                    break;
                case esriGeometryType.esriGeometryMultiPatch:
                    break;
                case esriGeometryType.esriGeometryMultipoint:
                    break;
                case esriGeometryType.esriGeometryNull:
                    break;
                case esriGeometryType.esriGeometryPath:
                    break;
                case esriGeometryType.esriGeometryPoint:
                    graphicElement = new MarkerElementClass() as IElement;

                    graphicElement.Geometry = featureGeometry;

                    IMarkerSymbol markerSymbol = null;
                    if (m_documentDefaultSymbols == null)
                    {
                        // create a symbology for a point geometry
                        ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
                        simpleMarkerSymbol.Color = featureColor;
                        simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
                        simpleMarkerSymbol.Size = 18;

                        markerSymbol = simpleMarkerSymbol;
                    }
                    else
                    {
                        markerSymbol = m_documentDefaultSymbols.MarkerSymbol;
                        markerSymbol.Color = featureColor;
                    }

                    ((IMarkerElement)graphicElement).Symbol = markerSymbol;

                    break;
                case esriGeometryType.esriGeometryPolygon:
                    graphicElement = new PolygonElementClass() as IElement;

                    graphicElement.Geometry = featureGeometry;

                    //
                    IFillSymbol fillSymbol = null;
                    if (m_documentDefaultSymbols == null)
                    {
                        ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
                        simpleFillSymbol.Color = featureColor;

                        ILineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
                        simpleLineSymbol.Color = featureColor;
                        simpleLineSymbol.Width = 1;
                        simpleFillSymbol.Outline = simpleLineSymbol;
                        simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;

                        fillSymbol = simpleFillSymbol;
                    }
                    else
                    {
                        fillSymbol = m_documentDefaultSymbols.FillSymbol;
                        fillSymbol.Color = featureColor;

                    }
                    ((IFillShapeElement)graphicElement).Symbol = fillSymbol;

                    break;
                case esriGeometryType.esriGeometryPolyline:
                    graphicElement = new LineElementClass() as IElement;

                    graphicElement.Geometry = featureGeometry;

                    ILineSymbol lineSymbol = null;
                    if (m_documentDefaultSymbols == null)
                    {
                        lineSymbol = new SimpleLineSymbolClass();
                        lineSymbol.Color = featureColor;
                        lineSymbol.Width = 3;
                    }
                    else
                    {
                        lineSymbol = m_documentDefaultSymbols.LineSymbol;
                        lineSymbol.Color = featureColor;
                    }

                    ((ILineElement)graphicElement).Symbol = lineSymbol;

                    break;
                case esriGeometryType.esriGeometryRay:
                    break;
                case esriGeometryType.esriGeometryRing:
                    break;
                case esriGeometryType.esriGeometrySphere:
                    break;
                case esriGeometryType.esriGeometryTriangleFan:
                    break;
                case esriGeometryType.esriGeometryTriangleStrip:
                    break;
                case esriGeometryType.esriGeometryTriangles:
                    break;
                default:
                    break;
            }

            return graphicElement;
        }
        public static void AddFlagsForSewerProfile(IApplication app, double snapTol, List<ProfileGraphDetails> ProfileGraph)
        {
            IFeatureCursor pFeatCursor = null;
            IMxDocument pMxDoc = null;

            IPoint pTracePoint = null;
            ISpatialFilter pSpatialFilter = null;
            // set the symbol for the flag, red circle
            IMarkerSymbol pMarkerSym = null;
            IRgbColor pRGBColor = null;

            IFeatureLayer pManholeLayer = null;
            IFeatureLayer pMainLayer = null;
            IFeatureLayer pTapLayer = null;
            IGraphicsContainer gc = null;

            IElement pProfileElemFirst = null;
            IElementProperties3 pProfileElemPropFirst = null;

            IElement element = null;
            IElementProperties3 elementProp = null;
            ITopologicalOperator pTopoOp = null;

            IFeature pFeature = null;
            double snapdistnet; // NetworkExt search tolerance
            IPolygon pBuffGeometry = null;
            IMarkerElement markerelem = null;
            IGeometricNetwork gn = null;

            IEnumNetEID juncEIDs = null;
            IEnumNetEID edgeEIDs = null;
            try
            {
                pMxDoc = ((IMxDocument)app.Document);

                pTracePoint = pMxDoc.CurrentLocation;

                pMarkerSym = Globals.FindMarkerSym("Esri.style", "Default", "Circle 2", pMxDoc);
                pRGBColor = Globals.GetColor(255, 0, 0);

                pMarkerSym.Color = pRGBColor;
                pMarkerSym.Size = 11;

                gc = pMxDoc.FocusMap as IGraphicsContainer;

                pProfileElemFirst = null;
                pProfileElemPropFirst = null;

                gc.Reset();
                element = gc.Next();

                while (element != null)
                {
                    elementProp = element as IElementProperties3;
                    if (elementProp.Name.Contains("ProfileGraphFlag"))
                    {
                        if (pProfileElemFirst == null)
                        {
                            pProfileElemFirst = element;
                            pProfileElemPropFirst = elementProp;
                            break;
                        }

                    }
                    element = gc.Next();
                }

                for (int i = 0; i < ProfileGraph.Count; i++)
                {
                    if (pProfileElemFirst != null)
                    {
                        if (!pProfileElemPropFirst.Name.Contains(ProfileGraph[i].Network_Name))
                        {
                            //MessageBox.Show("The network (" + ProfileGraph[i].Network_Name + ") was not found, please update the config to make the name of the layer in the mxd");

                            continue;
                        }

                    }
                    bool FCorLayerManhole = true;
                    pManholeLayer = (IFeatureLayer)Globals.FindLayer(pMxDoc.FocusMap, ProfileGraph[i].Point_LayerName, ref FCorLayerManhole);

                    if (pManholeLayer == null)
                    {
                       // MessageBox.Show("The point layer (" + ProfileGraph[i].Point_LayerName + ") was not found, please update the config to make the name of the layer in the mxd");

                        continue;
                    }
                    bool FCorLayerMain = true;
                    pMainLayer = (IFeatureLayer)Globals.FindLayer(pMxDoc.FocusMap, ProfileGraph[i].Line_LayerName, ref FCorLayerMain);
                    if (pMainLayer == null)
                    {
                       // MessageBox.Show("The Main layer (" + ProfileGraph[i].Line_LayerName + ") was not found, please update the config to make the name of the layer in the mxd");

                        continue;
                    }
                    bool FCorLayerTap = true;
                    if (ProfileGraph[i].PointAlong_LayerName != "")
                    {
                        pTapLayer = (IFeatureLayer)Globals.FindLayer(pMxDoc.FocusMap, ProfileGraph[i].PointAlong_LayerName, ref FCorLayerTap);

                    }
                    else
                        pTapLayer = null;
                    // make sure a manhole was selected
                    // buffer the point by the snap tolerance, this is faster than checking
                    //the flag to see if it is on a manhole

                    pTopoOp = (ITopologicalOperator)pTracePoint;  // QI
                    snapdistnet = Globals.ConvertPixelsToMap(snapTol, pMxDoc.FocusMap);
                    pBuffGeometry = (IPolygon)pTopoOp.Buffer(snapdistnet);

                    // get the feature the user clicked to be sure it's a manhole

                    pSpatialFilter = new SpatialFilterClass();
                    pSpatialFilter.Geometry = pBuffGeometry;
                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;
                    pFeatCursor = pManholeLayer.Search(pSpatialFilter, true);

                    // there is a layer definition set to show only manholes, cursor
                    // will return nothing if user didn't click on a manhole
                    pFeature = pFeatCursor.NextFeature();

                    if (pFeature != null)
                    {
                        pMxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, pBuffGeometry.Envelope);

                        markerelem = new MarkerElementClass();
                        markerelem.Symbol = pMarkerSym;
                        element = (IElement)markerelem;
                        element.Geometry = pFeature.ShapeCopy;
                        elementProp = element as IElementProperties3;
                        elementProp.Name = "ProfileGraphFlag-" + ProfileGraph[i].Network_Name;

                        elementProp.ReferenceScale = pMxDoc.FocusMap.ReferenceScale;
                        gc.AddElement(element, 0);

                        if (pProfileElemFirst == null)
                            return;
                        else
                        {
                            ESRI.ArcGIS.esriSystem.IStatusBar statusBar = null;
                            ESRI.ArcGIS.esriSystem.IAnimationProgressor animationProgressor = null;
                            ESRI.ArcGIS.esriSystem.ITrackCancel trackCancel = null;
                            ESRI.ArcGIS.Framework.IProgressDialogFactory progressDialogFactory = null;
                            ESRI.ArcGIS.esriSystem.IStepProgressor stepProgressor = null;
                            ESRI.ArcGIS.Framework.IProgressDialog2 progressDialog2 = null;

                            statusBar = app.StatusBar;
                            animationProgressor = statusBar.ProgressAnimation;

                            animationProgressor.Show();
                            animationProgressor.Play(0, -1, -1);

                            statusBar.set_Message(0, A4LGSharedFunctions.Localizer.GetString("GeoNetToolsProc_19a"));

                            // Create a CancelTracker
                            trackCancel = new ESRI.ArcGIS.Display.CancelTrackerClass();

                            progressDialogFactory = new ESRI.ArcGIS.Framework.ProgressDialogFactoryClass();

                            // Set the properties of the Step Progressor
                            System.Int32 int32_hWnd = app.hWnd;
                            stepProgressor = progressDialogFactory.Create(trackCancel, int32_hWnd);
                            stepProgressor.MinRange = 0;
                            stepProgressor.MaxRange = 3;
                            stepProgressor.StepValue = 1;
                            stepProgressor.Message = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsDesc_19a");

                            // Create the ProgressDialog. This automatically displays the dialog
                            progressDialog2 = (ESRI.ArcGIS.Framework.IProgressDialog2)stepProgressor; // Explict Cast

                            // Set the properties of the ProgressDialog
                            progressDialog2.CancelEnabled = true;
                            progressDialog2.Description = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsDesc_19a");
                            progressDialog2.Title = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsTitle_19a");
                            progressDialog2.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;

                            // Step. Do your big process here.
                            System.Boolean boolean_Continue = false;
                            boolean_Continue = true;

                            stepProgressor.Step();

                            GeoNetTools.TracePath(new double[] { (pProfileElemFirst.Geometry as IPoint).X, (element.Geometry as IPoint).X },
                                new double[] { (pProfileElemFirst.Geometry as IPoint).Y, (element.Geometry as IPoint).Y },
                                ProfileGraph[i].Network_Name, app, pMxDoc.FocusMap, true, snapTol, true, out juncEIDs, out edgeEIDs, out gn);
                            boolean_Continue = trackCancel.Continue();
                            if (!boolean_Continue)
                            {
                                return;
                            }
                            stepProgressor.Step();
                            stepProgressor.Message = A4LGSharedFunctions.Localizer.GetString("GeoNetToolsProc_19a");
                            if (juncEIDs != null && edgeEIDs != null)
                            {
                                GeoNetTools.ProfileGetRelatedElevData(app, ProfileGraph, gn, edgeEIDs, juncEIDs, i, ref pManholeLayer, ref pMainLayer, ref pTapLayer);
                            }
                            else
                            {

                            }

                            //ProfileFindPath();

                            // unpress the UIToolControl button
                            app.CurrentTool = null;
                            app.RefreshWindow();
                            progressDialog2.HideDialog();
                            progressDialog2 = null;
                            return;
                        }

                    }
                    else//Next Layer in the config
                    {
                    }

                }

                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("GeoNetToolsError_19a"));

            }
            catch (Exception Ex)
            {
                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + "AddFlagsForSewerProfile " + Ex.Message);
            }
            finally
            {
                if (pFeatCursor != null)
                {
                    Marshal.ReleaseComObject(pFeatCursor);

                }
                pMxDoc.ActiveView.Refresh();
                pFeatCursor = null;
                pMxDoc = null;

                pTracePoint = null;
                pSpatialFilter = null;
                // set the symbol for the flag, red circle
                pMarkerSym = null;
                pRGBColor = null;

                pManholeLayer = null;
                pMainLayer = null;
                pTapLayer = null;
                gc = null;

                pProfileElemFirst = null;
                pProfileElemPropFirst = null;

                element = null;
                elementProp = null;
                pTopoOp = null;

                pFeature = null;

                pBuffGeometry = null;
                markerelem = null;
                gn = null;

                juncEIDs = null;
                edgeEIDs = null;
            }
        }
Exemplo n.º 45
0
        private List<string> ExportSymbol(IStyleGallery sg,string symbolType, int col, int row, int size,int width, int labelsize, int label_h, int size_w, int size_h, double height, string cat, IPageLayout3 layout)
        {
            List<string> pdfpages = new List<string>();
            IGraphicsContainer con = layout as IGraphicsContainer;
            IPage page = layout.Page;
            int r = 0;
            int c = 0;
            int p = 0;
            IEnumStyleGalleryItem items = sg.get_Items(symbolType, "", cat);
            IStyleGalleryItem item = items.Next();
            while (item != null)
            {
                #region Symbol
                if (symbolType == "Marker Symbols")
                {
                    IMarkerElement mele = new MarkerElementClass();
                    IPoint ptn = new PointClass();
                    ptn.PutCoords(c * size_w + size / 2, height - (r * size_h + size / 2));
                    IElement ele_i = mele as IElement;
                    ele_i.Geometry = ptn;
                    IMarkerSymbol sym_m = item.Item as IMarkerSymbol;
                    sym_m.Size = size;
                    mele.Symbol = sym_m;
                    con.AddElement(ele_i, 0);
                }
                else if (symbolType == "Line Symbols")
                {
                    ILineElement lele = new LineElementClass();
                    IPolyline line = new PolylineClass();
                    IPoint ptn_f = new PointClass();
                    ptn_f.PutCoords(c * size_w + size / 4, height - (r * size_h + size * 3 / 4));
                    IPoint ptn_t = new PointClass();
                    ptn_t.PutCoords(c * size_w + size * 3 / 4, height - (r * size_h + size / 4));
                    line.FromPoint = ptn_f;
                    line.ToPoint = ptn_t;
                    IElement ele_i = lele as IElement;
                    ele_i.Geometry = line;
                    ILineSymbol sym_l = item.Item as ILineSymbol;
                    sym_l.Width = width;
                    lele.Symbol = sym_l;
                    con.AddElement(ele_i, 0);
                }
                else if (symbolType == "Fill Symbols")
                {
                    IRectangleElement fele = new RectangleElementClass();
                    IFillShapeElement fsele = fele as IFillShapeElement;
                    IEnvelope env_f = new EnvelopeClass();
                    env_f.PutCoords(c * size_w + size / 4, height - (r * size_h + size * 3 / 4), c * size_w + size * 3 / 4, height - (r * size_h + size / 4));
                    IElement ele_i = fele as IElement;
                    ele_i.Geometry = env_f;
                    IFillSymbol sym_f = item.Item as IFillSymbol;
                    fsele.Symbol = sym_f;
                    con.AddElement(ele_i, 0);
                }

                #endregion

                if (cbGrid.Checked)
                {
                    #region Grid
                    IEnvelope env_g = new EnvelopeClass();
                    env_g.PutCoords(c * size_w, height - r * size_h, c * size_w + size_w, height - r * size_h - size_h);
                    IRectangleElement gele = new RectangleElementClass();
                    IElement ele_g = gele as IElement;
                    ele_g.Geometry = env_g;
                    IFillSymbol sym_g = new SimpleFillSymbolClass();
                    IRgbColor color_g = new RgbColorClass();
                    color_g.NullColor = true;
                    sym_g.Color = color_g;
                    IFillShapeElement fshp_g = ele_g as IFillShapeElement;
                    fshp_g.Symbol = sym_g;
                    con.AddElement(ele_g, 0);
                    #endregion
                }

                #region Label
                ITextElement tele = new ParagraphTextElementClass();
                IElement ele_t = tele as IElement;
                tele.Text = item.Name;
                IEnvelope env_l = new EnvelopeClass();
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                ele_t.Geometry = env_l;
                ITextSymbol sym_label = new TextSymbolClass();
                sym_label.Size = labelsize/2;
                IRgbColor color = new RgbColorClass();
                color.NullColor = true;
                ISimpleLineSymbol sym_border = new SimpleLineSymbolClass();
                sym_border.Color = color;
                ISymbolBorder border = new SymbolBorderClass();
                border.LineSymbol = sym_border;
                IFrameProperties fp = ele_t as IFrameProperties;
                fp.Border = border;
                con.AddElement(ele_t, 0);
                #endregion

                if (c < col - 1)
                {
                    c++;
                }
                else
                {
                    c = 0;
                    if (r < row - 1)
                    {
                        r++;
                    }
                    else
                    {
                        IActiveView av = layout as IActiveView;
                        string temp_pdf = System.IO.Path.GetTempFileName() + ".pdf";
                        ExportPDF(av, temp_pdf);
                        pdfpages.Add(temp_pdf);
                        con.DeleteAllElements();
                        r = 0;
                        c = 0;
                        p++;
                    }
                }
                item = items.Next();
            }
            if (con.Next() != null)
            {
                IActiveView av = layout as IActiveView;
                string temp_pdf = System.IO.Path.GetTempFileName() + ".pdf";
                ExportPDF(av, temp_pdf);
                pdfpages.Add(temp_pdf);
                con.DeleteAllElements();
            }
            return pdfpages;
        }
Exemplo n.º 46
0
        /// <summary>
        /// ���Ƽ���ͼ��
        /// </summary>
        /// <params name="geoType"></params>
        /// <params name="geometry"></params>
        /// <returns></returns>
        ESRI.ArcGIS.Carto.IElement createElement_x(ESRI.ArcGIS.Geometry.IGeometry geometry)
        {
            IElement element = null;
            try
            {
                switch (geometry.GeometryType)
                {
                    case esriGeometryType.esriGeometryPolygon:
                        IFillShapeElement pPolygonElement;
                        ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
                        IPolygon pPolygon = new PolygonClass();
                        IRubberBand pRubberBand = new RubberPolygonClass();
                        ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
                        pPolygonElement = new PolygonElementClass();

                        //if (e.button == 1)
                        //{
                        //   pPolygon=(IPolygon) pRubberBand.TrackNew(axMapControl1.ActiveView.ScreenDisplay, null);
                        //}
                        pSimpleLineSymbol.Width = 2;
                        pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                        pSimpleLineSymbol.Color = TransColorToAEColor(Color.Blue);

                        //pSimpleFillSymbol.Color = GetRGBColor(11, 200, 145);
                        pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSNull;
                        pSimpleFillSymbol.Outline = pSimpleLineSymbol;
                        IElement pElement = (IElement)pPolygonElement;
                        pElement.Geometry = geometry;
                        pPolygonElement.Symbol = pSimpleFillSymbol;

                        element = (IElement)pPolygonElement;
                        break;
                    case esriGeometryType.esriGeometryPolyline://Polyline��
                        ISimpleLineSymbol simpleLineSymbol = m_NewPolygonFeedback.Symbol as ISimpleLineSymbol;

                        ILineElement lineElement = new LineElementClass();
                        lineElement.Symbol = simpleLineSymbol as ILineSymbol;
                        element = lineElement as IElement;
                        element.Geometry = geometry;
                        break;
                    case esriGeometryType.esriGeometryPoint:
                        //���ý�����
                        IRgbColor pRGB = new RgbColorClass();
                        pRGB.Red = 255;
                        pRGB.Green = 0;
                        pRGB.Blue = 0;

                        ISimpleMarkerSymbol pSimpleMarkSymbol = new SimpleMarkerSymbolClass();
                        pSimpleMarkSymbol.Color = pRGB as IColor;
                        pSimpleMarkSymbol.Size = 2;
                        pSimpleMarkSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare;

                        IMarkerElement pMarkerElement = new MarkerElementClass();
                        pMarkerElement.Symbol = pSimpleMarkSymbol as IMarkerSymbol;
                        element = pMarkerElement as IElement;
                        element.Geometry = geometry as IGeometry;
                        break;
                }
            }
            catch
            { }
            return element;
        }
Exemplo n.º 47
0
        /// <summary>
        /// �����ı���ʾ��
        /// </summary>
        /// <param name="x">��ʾ���ʶ��λ��X����</param>
        /// <param name="y">��ʾ���ʶ��λ��Y����</param>
        public void CreateTextElment(AxMapControl axMapControl1, double x, double y, string strText)
        {
            IPoint pPoint = new PointClass();
            IMap pMap = axMapControl1.Map;
            IActiveView pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement pElement = new MarkerElementClass();
            IElement pTElement = new TextElementClass();
            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol = new TextSymbolClass();
            IBalloonCallout pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor pColor = new RgbColorClass();
            pColor.Red = 150;
            pColor.Green = 0;
            pColor.Blue = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;
            pTextBackground = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background = pTextBackground;
            ((ITextElement)pTElement).Symbol = pTextSymbol;
            ((ITextElement)pTElement).Text = strText;

            IPoint p = new PointClass();
            //���õ������
            p.PutCoords(x, y);
            IElementProperties ipElemProp;
            IMarkerElement ipMarkerElement = new MarkerElementClass();
            IPictureMarkerSymbol ipPicMarker = new PictureMarkerSymbolClass();
            ipPicMarker.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, "D:\\pro\\ArcGisView\\ArcGisView\\1.bmp");
            ipPicMarker.Size = 24;
            IRgbColor ipRGBTrans = new RgbColorClass();
            ipRGBTrans.RGB = 0xffffff;
            ipPicMarker.BitmapTransparencyColor = ipRGBTrans as IColor;
            ipMarkerElement.Symbol = ipPicMarker as IMarkerSymbol;
            IElement ipElement = ipMarkerElement as IElement;
            ipElement.Geometry = p as IGeometry;
            axMapControl1.ActiveView.GraphicsContainer.AddElement(ipElement, 0);

            pPoint.X = x + 42;
            pPoint.Y = y + 42;
            pTElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pTElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 48
0
        public void CreateTextElment(double x, double y)
        {
            IPoint pPoint = new PointClass();
            IMap pMap = axMapControl.Map;
            IActiveView pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement pElement = new MarkerElementClass();
            IElement pTElement = new TextElementClass();
            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol = new TextSymbolClass();
            IBalloonCallout pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor pColor = new RgbColorClass();
            pColor.Red = 150;
            pColor.Green = 0;
            pColor.Blue = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;
            pTextBackground = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background = pTextBackground;
            ((ITextElement)pTElement).Symbol = pTextSymbol;
            ((ITextElement)pTElement).Text = "测试";
            pPoint.X = x + 42;
            pPoint.Y = y + 42;

            //axMapControl.CenterAt(pPoint);
            pTElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pTElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 49
0
        /// <summary>
        /// 聚焦到目标地物
        /// </summary>
        /// <param name="pActiveView">地图视图</param>
        /// <param name="pFtLayer">图层</param>
        /// <param name="nOID">地物ID</param>
        public static void AddElement(IActiveView pActiveView, IFeatureLayer pFtLayer, int nOID)
        {
            IFeatureClass pFtCls = pFtLayer.FeatureClass;
            IFeature pFt = pFtCls.GetFeature(nOID);
            if (pFt == null)
            {
                return;
            }
            IGeometry pGeo = pFt.Shape;
            if (pGeo == null)
            {
                return;
            }
            IEnvelope pEnvelope = pGeo.Envelope;

            IGraphicsContainer pGraphContainer = pActiveView.GraphicsContainer;
            //根据拓扑错误图形的几何类型,来创建相应的element
            IElement ipElement = null;
            RgbColor ipColor = new RgbColor();
            if (pGeo.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                IMarkerElement ipMarkElement = new MarkerElementClass();
                ipElement = (IElement)ipMarkElement;
                ipElement.Geometry = pGeo;
                ISimpleMarkerSymbol ipMarkerSymbol = new SimpleMarkerSymbolClass();
                ipColor.Red = 255;
                ipColor.Blue = 0;
                ipColor.Green = 0;
                ipMarkerSymbol.Color = (IColor)ipColor;
                ipMarkElement.Symbol = ipMarkerSymbol;
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                ILineElement ipLineElement = new LineElementClass();
                ipElement = (IElement)ipLineElement;
                ipElement.Geometry = pGeo;
                ISimpleLineSymbol ipLineSymbol = new SimpleLineSymbolClass();
                ipColor.Red = 255;
                ipColor.Blue = 0;
                ipColor.Green = 0;
                ipLineSymbol.Color = (IColor)ipColor;
                ipLineSymbol.Width = 2.0;
                ipLineElement.Symbol = ipLineSymbol;
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                IPolygonElement ipPolygonElement = new PolygonElementClass();
                ipElement = (IElement)ipPolygonElement;
                ipElement.Geometry = pGeo;

                ISimpleFillSymbol ipFillSymbol = new SimpleFillSymbolClass();
                ILineSymbol ipLineSymbol = ipFillSymbol.Outline;
                ipLineSymbol.Width = 2.0;
                ipColor.Red = 255;
                ipColor.Blue = 0;
                ipColor.Green = 0;
                ipLineSymbol.Color = (IColor)ipColor;
                ipFillSymbol.Outline = ipLineSymbol;
                IFillShapeElement pFillElement = (IFillShapeElement)ipPolygonElement;
                ipFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
                pFillElement.Symbol = ipFillSymbol;
            }

            pGraphContainer.DeleteAllElements();
            pGraphContainer.AddElement(ipElement, 0);

            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            pActiveView.ScreenDisplay.UpdateWindow();
        }
Exemplo n.º 50
0
        protected override void OnClick()
        {
            ArcMap.Application.CurrentTool = null;
            IEnumLayer enLyr = ArcMap.Document.FocusMap.get_Layers(null, true);
            enLyr.Reset();
            ILayer lyr = enLyr.Next();
            IFeatureClass trailFC = null;
            IFeatureClass waypointFC = null;
            while (lyr != null)
            {
                if(lyr.Name == "Trail")
                {
                    trailFC = ((IFeatureLayer)lyr).FeatureClass;
                }
                if(lyr.Name == "Waypoint")
                {
                    waypointFC = ((IFeatureLayer)lyr).FeatureClass;
                }
                lyr = enLyr.Next();
            }
            IQueryFilter qf2 = new QueryFilterClass();
            qf2.WhereClause = "OBJECTID > 0";// "OBJECTID = 203";
            IFeatureCursor feCur = trailFC.Search(qf2, false);
            IFeature trailFe = feCur.NextFeature();
            List<int> oids = new List<int>();
            while (trailFe != null)
            {
                oids.Add(trailFe.OID);
                if(trailFe.OID == 203)
                {

                }
                IPointCollection pc = (IPointCollection)trailFe.ShapeCopy;
                List<IPoint> firstLastPoint = new List<IPoint>();
                firstLastPoint.Add(pc.get_Point(0));
                firstLastPoint.Add(pc.get_Point(pc.PointCount - 1));
                foreach (IPoint pnt in firstLastPoint)
                {
                    ISpatialFilter sf = new SpatialFilterClass();
                    sf.Geometry = pnt;
                    sf.GeometryField = waypointFC.ShapeFieldName;
                    sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    IFeatureCursor waypointFeCur = waypointFC.Search(sf, false);
                    IFeature waypoint1 = waypointFeCur.NextFeature();
                    IFeature waypoint2 = null;
                    if (waypoint1 != null)
                    {
                        waypoint2 = waypointFeCur.NextFeature();

                    }
                    if(waypoint2 != null || waypoint1 == null)
                    {
                        IElement me = new MarkerElementClass();
                        me.Geometry = pnt;
                        ISimpleMarkerSymbol ms = new SimpleMarkerSymbolClass();
                        ms.Size = 18;
                        ms.Style = esriSimpleMarkerStyle.esriSMSCircle;
                        IRgbColor rgbCol = new RgbColorClass();
                        rgbCol.Red = 255;
                        ms.Color = rgbCol;
                        ((IMarkerElement)me).Symbol = ms;
                        (ArcMap.Document.FocusMap as IGraphicsContainer).AddElement(me,0);

                    }
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(waypointFeCur);

                }
                trailFe = feCur.NextFeature();
            }
            System.Runtime.InteropServices.Marshal.FinalReleaseComObject(feCur);
            IQueryFilter qf = new QueryFilterClass();
            qf.WhereClause = "SUBTYPE = 0";
            IFeatureCursor wpFeCur = waypointFC.Search(qf, false);
            IFeature wpFE = wpFeCur.NextFeature();
            while (wpFE != null)
            {
                ISpatialFilter sf = new SpatialFilterClass();
                sf.Geometry = wpFE.ShapeCopy;
                sf.GeometryField = trailFC.ShapeFieldName;
                sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                IFeatureCursor trFeCur = trailFC.Search(sf, false);
                IFeature t1 = trFeCur.NextFeature();
                IFeature t2 = trFeCur.NextFeature();
                if (t1 == null || t2 == null)
                {
                    IElement me = new MarkerElementClass();
                    me.Geometry = wpFE.ShapeCopy;
                    ISimpleMarkerSymbol ms = new SimpleMarkerSymbolClass();
                    ms.Size = 18;
                    ms.Style = esriSimpleMarkerStyle.esriSMSCircle;
                    IRgbColor rgbCol = new RgbColorClass();
                    rgbCol.Blue = 255;
                    ms.Color = rgbCol;
                    ((IMarkerElement)me).Symbol = ms;
                    (ArcMap.Document.FocusMap as IGraphicsContainer).AddElement(me, 0);

                }
                 wpFE = wpFeCur.NextFeature();
            }
            System.Runtime.InteropServices.Marshal.FinalReleaseComObject(wpFeCur);
        }
        private void AddElement(IMap map, IPoint point)
        {
            IGraphicsContainer graphicsContainer = map as IGraphicsContainer;
            IRgbColor color = new RgbColorClass();
            color.Green = 80;
            color.Red = 22;
            color.Blue = 68;

            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol();
            simpleMarkerSymbol.Color = color;
            simpleMarkerSymbol.Size = 15;
            simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;

            IElement element = null;

            IMarkerElement markerElement = new MarkerElementClass();

            markerElement.Symbol = simpleMarkerSymbol;
            element = markerElement as IElement;

            if (element != null)
            {
                element.Geometry = point;
            }
            graphicsContainer.AddElement(element, 0);

            //Flag the new text to invalidate.
            IActiveView activeView = map as IActiveView;
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 52
0
        /// <summary>
        /// ��ӵ�
        /// </summary>
        public void AddPoint(AxMapControl axMapControl1, double x, double y)
        {
            try
            {
                //����SimpleMarkerSymbolClass����
                ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();
                //����RgbColorClass����ΪpSimpleMarkerSymbol������ɫ
                IRgbColor pRgbColor = new RgbColorClass();
                pRgbColor.Red = 255;
                pSimpleMarkerSymbol.Color = pRgbColor as IColor;
                //����pSimpleMarkerSymbol����ķ������ͣ�ѡ����ʯ
                pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;
                //����pSimpleMarkerSymbol�����С������Ϊ��
                pSimpleMarkerSymbol.Size = 5;
                //��ʾ�����
                pSimpleMarkerSymbol.Outline = true;
                //Ϊ�����������ɫ
                IRgbColor pLineRgbColor = new RgbColorClass();
                pLineRgbColor.Green = 255;
                pSimpleMarkerSymbol.OutlineColor = pLineRgbColor as IColor;
                //��������ߵĿ��
                pSimpleMarkerSymbol.OutlineSize = 1;

                string AppPath = Application.StartupPath;
                IPoint Pt = new PointClass();
                Pt.PutCoords(x, y);

                IMarkerElement ipMarkerElement = new MarkerElementClass();
                ipMarkerElement.Symbol = pSimpleMarkerSymbol as IMarkerSymbol;
                IElement ipElement = ipMarkerElement as IElement;
                ipElement.Geometry = Pt as IGeometry;
                axMapControl1.ActiveView.GraphicsContainer.AddElement(ipElement, 0);
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, ipElement, null);
            }
            catch
            {

            }
        }
Exemplo n.º 53
0
 //
 //
 //
 public static void drawPointToGraphicLayer(IActiveView pActiveView, IPoint pGeom, IMarkerSymbol pSym)
 {
     try
     {
         IGraphicsContainer iGC = pActiveView as IGraphicsContainer;
         IElement pEle;
         IMarkerElement pLE;
         if (pGeom != null)
         {
             pEle = new MarkerElementClass() as IElement;
             pLE = pEle as IMarkerElement;
             pLE.Symbol = pSym;
             pEle.Geometry = pGeom;
             iGC.AddElement(pEle, 0);
         }
         pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Type.Missing, pActiveView.Extent);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Exemplo n.º 54
0
        /// <summary>
        /// 聚焦到目标地物
        /// </summary>
        /// <param name="pMapCtrl">地图控件control</param>
        /// <param name="pFt">地物</param>
        public static void ZoomToElement(AxMapControl pMapCtrl, IGeometry pGeo)
        {
            if (pGeo == null || pGeo.IsEmpty)
            {
                return;
            }
            IEnvelope pEnvelope = pGeo.Envelope;

            IGraphicsContainer pGraphContainer = pMapCtrl.ActiveView.GraphicsContainer;
            //根据拓扑错误图形的几何类型,来创建相应的element
            IElement ipElement = null;
            RgbColor ipColor = new RgbColor();
            if (pGeo.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                IMarkerElement ipMarkElement = new MarkerElementClass();
                ipElement = (IElement)ipMarkElement;
                ipElement.Geometry = pGeo;
                ISimpleMarkerSymbol ipMarkerSymbol = new SimpleMarkerSymbolClass();
                ipColor.Red = 0;
                ipColor.Blue = 255;
                ipColor.Green = 0;

                RgbColor ipColor1 = new RgbColor();

                ipColor1.NullColor = true;
                ipMarkerSymbol.Color = (IColor)ipColor1;
                ipMarkerSymbol.OutlineColor = (IColor)ipColor;
                ipMarkerSymbol.Outline = true;
                ipMarkerSymbol.OutlineSize = 2;
                ipMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
                ipMarkerSymbol.Size = 14;
                ipMarkElement.Symbol = ipMarkerSymbol;
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                ILineElement ipLineElement = new LineElementClass();
                ipElement = (IElement)ipLineElement;
                ipElement.Geometry = pGeo;
                ISimpleLineSymbol ipLineSymbol = new SimpleLineSymbolClass();
                ipColor.Red = 255;
                ipColor.Blue = 0;
                ipColor.Green = 0;
                ipLineSymbol.Color = (IColor)ipColor;
                ipLineSymbol.Width = 2.0;
                ipLineElement.Symbol = ipLineSymbol;
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                IPolygonElement ipPolygonElement = new PolygonElementClass();
                ipElement = (IElement)ipPolygonElement;
                ipElement.Geometry = pGeo;
                ISimpleFillSymbol ipFillSymbol = new SimpleFillSymbolClass();
                ILineSymbol ipLineSymbol = ipFillSymbol.Outline;
                ipLineSymbol.Width = 2.0;
                ipColor.Red = 255;
                ipColor.Blue = 0;
                ipColor.Green = 0;
                ipLineSymbol.Color = (IColor)ipColor;
                ipFillSymbol.Outline = ipLineSymbol;
                IFillShapeElement pFillElement = (IFillShapeElement)ipPolygonElement;
                ipFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
                pFillElement.Symbol = ipFillSymbol;
            }

            //pGraphContainer.DeleteAllElements();

            pGraphContainer.AddElement(ipElement, 0);

            //pMapCtrl.ActiveView.Extent = pEnvelope;
            //如果是点类型则集中显示
            if (pGeo.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                //IEnvelope pEnv = pMapCtrl.ActiveView.FullExtent;
                //pEnv.Expand(0.005, 0.005, false);
                //pMapCtrl.ActiveView.Extent = pEnv;

                IPoint pPoint = (IPoint)pGeo;
                pMapCtrl.CenterAt(pPoint);
                pMapCtrl.MapScale = 2000;

            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                if (!pEnvelope.IsEmpty)
                {
                    pEnvelope.Expand(3, 3, true);
                    pMapCtrl.ActiveView.Extent = pEnvelope;
                }
                else
                {
                    IPointCollection pPntColl = pGeo as IPointCollection;
                    IPoint pt = pPntColl.get_Point(1);
                    pMapCtrl.CenterAt(pt);
                    pMapCtrl.MapScale = 2000;
                }
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                pEnvelope.Expand(2, 2, true);
                pMapCtrl.ActiveView.Extent = pEnvelope;
            }

            //pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            pMapCtrl.ActiveView.Refresh();
            pMapCtrl.ActiveView.ScreenDisplay.UpdateWindow();
            FlashGeometry(pMapCtrl.Object as IMapControl4, pGeo);
            //pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            //pMapCtrl.ActiveView.ScreenDisplay.UpdateWindow();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string input = this.tbxInput.Text;
            string cat = this.tbxSet.Text;
            string folder = this.tbxOutput.Text;
            string target = this.tbxTarget.Text;
            string depth = this.cbxDepth.Text;

            IStyleGalleryStorage sgs = new StyleGalleryClass();
            while (sgs.FileCount > 0)
            {
                sgs.RemoveFile(sgs.get_File(0));
            }
            IStyleGallery sg = sgs as IStyleGallery;
            sgs.AddFile(input);
            sgs.TargetFile = target;

            IPageLayout3 layout = new PageLayoutClass();
            IGraphicsContainer con = layout as IGraphicsContainer;
            IPage page = layout.Page;
            page.Units = esriUnits.esriPoints;

            IRgbColor bgc = new RgbColorClass();
            bgc.Red = 255;
            bgc.Green = 255;
            bgc.Blue = 254;
            IFrameProperties fp = page as IFrameProperties;
            ISymbolBackground bg = new SymbolBackgroundClass();
            bg.Gap = 0;
            ISimpleFillSymbol sfs = new SimpleFillSymbolClass();
            sfs.Color = bgc as IColor;
            ISimpleLineSymbol sls = new SimpleLineSymbolClass();
            sls.Style = esriSimpleLineStyle.esriSLSNull;
            sfs.Outline = sls;
            bg.FillSymbol = sfs as IFillSymbol;
            fp.Background = bg;

            IEnumStyleGalleryItem items = sg.get_Items("Marker Symbols", input, cat);
            IStyleGalleryItem item = items.Next();
            while (item != null)
            {
                //con.DeleteAllElements();
                IMarkerElement mele = new MarkerElementClass();
                IMarkerSymbol sym_m = item.Item as IMarkerSymbol;
                IMultiLayerMarkerSymbol sym_ml = sym_m as IMultiLayerMarkerSymbol;
                double pic_size;
                if (sym_ml.Size % 2 == 0)
                {
                    pic_size = sym_ml.Size+4;
                }
                else
                {
                    pic_size = sym_ml.Size+5;
                }
                page.PutCustomSize(pic_size, pic_size);
                IPoint ptn = new PointClass();
                ptn.PutCoords(pic_size / 2, pic_size / 2);
                IElement ele_i = mele as IElement;
                ele_i.Geometry = ptn;

                sym_m.Size = sym_ml.Size;
                mele.Symbol = sym_m;
                con.AddElement(ele_i, 0);
                IActiveView av = layout as IActiveView;
                string pic_file = folder+"\\"+item.Name + ".png";
                ExportPNG(av, pic_file,bgc,depth);
                con.DeleteElement(ele_i);

                ISymbol sym = CreatePictureMarkerSymbol(esriIPictureType.esriIPicturePNG, pic_file, pic_size) as ISymbol;
                IStyleGalleryItem newitem = new StyleGalleryItemClass();
                newitem.Name = item.Name;
                newitem.Item = sym;
                newitem.Category = cat;
                sg.AddItem(newitem);

                item = items.Next();
            }
            MessageBox.Show("成功导出图标");
        }
Exemplo n.º 56
0
        //坐标画点
        public static void CreatPoint(AxMapControl axMapControl,double x,double y,int m)
        {
            //首先要实现容器接口
            IGraphicsContainer pGraphicsContainer = axMapControl.ActiveView as IGraphicsContainer;
            //pGraphicsContainer.DeleteAllElements();//清空容器里面所有的元素

            //设置点的坐标
            IPoint pPoint = new PointClass();
            pPoint.PutCoords(x, y);

            //IMarkerElement用来获得symbol属性
            IMarkerElement pMarkerElement = new MarkerElementClass();

            //用ISimpleMarkerSymbol来设置点的属性
            ISimpleMarkerSymbol pSymbol = new SimpleMarkerSymbolClass();
            IRgbColor pRGBcolor = new RgbColorClass();
            pRGBcolor.Red = 0;
            pRGBcolor.Green =220;
            pRGBcolor.Blue = 0;
               // pSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            pSymbol.Size = 5;
            pSymbol.Color = pRGBcolor;//绿色
            pSymbol.Style = esriSimpleMarkerStyle.esriSMSCross;
            pSymbol.Outline = false;

            pMarkerElement.Symbol = pSymbol;

            //IEnvelope envelop=new EnvelopeClass();
            pPoint.Envelope.SetEmpty();
            //IElement用来获得Geometry属性
            IElement pElement = pMarkerElement as IElement;
            //把IPoint转换为为IGeoMetry也能实现
            //IGeometry pGeometry = pPoint as IGeometry;
            //pElement.Geometry = pGeometry;
            //设置点的标签;
            ITextSymbol pTextSymbol = new TextSymbolClass();
            pTextSymbol.Size = 10;
            pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            ITextElement texElement = new TextElementClass();
            texElement.Symbol = pTextSymbol;
            texElement.Text = m.ToString();
            IElement tElement = texElement as IElement;
            texElement.ScaleText = true;

            pElement.Geometry = pPoint;
            tElement.Geometry = pPoint;

            //在容器里添加元素
            pGraphicsContainer.AddElement(pElement, 0);
            pGraphicsContainer.AddElement(tElement, 0);
            pElement.Activate(axMapControl.ActiveView.ScreenDisplay);
              //tElement.Activate(axMapControl.ActiveView.ScreenDisplay);
            axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, null);
               // axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, tElement, null);
        }
        private void UpdateMapControlWithMarker(IMapControl4 updateMapControl, string action)
        {
            IRgbColor redRgbColor = new RgbColorClass();
            redRgbColor.Red = 255;
            redRgbColor.Green = 0;
            redRgbColor.Blue = 0;

            IRgbColor yellowRgbColor = new RgbColorClass();
            yellowRgbColor.Red = 255;
            yellowRgbColor.Green = 255;
            yellowRgbColor.Blue = 115;

            IRgbColor blackRgbcolor = new RgbColorClass();
            blackRgbcolor.Red = 0;
            blackRgbcolor.Green = 0;
            blackRgbcolor.Blue = 0;

            IRgbColor greenRgbColor = new RgbColorClass();
            greenRgbColor.Red = 0;
            greenRgbColor.Green = 255;
            greenRgbColor.Blue = 0;

            IEnvelope extentEnvelope = updateMapControl.Extent;
            IGraphicsContainer graphicsContainer = updateMapControl.Map.BasicGraphicsLayer as IGraphicsContainer;

            if (action == "DeleteMarker")
            {
                DeleteElement(updateMapControl, action);
            }
            else if (action == "AcceptMarker")
            {
                DeleteElement(updateMapControl, action);
            }

            IMultiLayerMarkerSymbol multiLayerMarkerSymbol = new MultiLayerMarkerSymbolClass();

            stdole.IFontDisp esriDefaultMarkerFont = new stdole.StdFontClass() as stdole.IFontDisp;
            esriDefaultMarkerFont.Name = "ESRI Default Marker";
            esriDefaultMarkerFont.Size = Convert.ToDecimal(48);

            IPoint markerLocation = new PointClass();
            markerLocation.SpatialReference = updateMapControl.SpatialReference;

            markerLocation.X = extentEnvelope.LowerLeft.X + extentEnvelope.Width / 10;
            markerLocation.Y = extentEnvelope.LowerLeft.Y + extentEnvelope.Height / (10 * (extentEnvelope.Height / extentEnvelope.Width));

            IMarkerElement markerElement = new MarkerElementClass();
            ((IElement)markerElement).Geometry = markerLocation;

            ISimpleMarkerSymbol backgroundMarkerSymbol = new SimpleMarkerSymbolClass();
            backgroundMarkerSymbol.Color = (IColor)yellowRgbColor;
            backgroundMarkerSymbol.Size = 45;
            backgroundMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare;
            backgroundMarkerSymbol.Outline = true;
            backgroundMarkerSymbol.OutlineColor = blackRgbcolor;
            backgroundMarkerSymbol.OutlineSize = 2;

            multiLayerMarkerSymbol.AddLayer((IMarkerSymbol)backgroundMarkerSymbol);

            if (action == "DeleteMarker")
            {
                ICharacterMarkerSymbol deleteMarkerSymbol = new CharacterMarkerSymbolClass();
                deleteMarkerSymbol.Font = esriDefaultMarkerFont;
                deleteMarkerSymbol.CharacterIndex = 68;
                deleteMarkerSymbol.Color = redRgbColor;
                deleteMarkerSymbol.Size = 48;

                multiLayerMarkerSymbol.AddLayer(deleteMarkerSymbol);

                ((IElementProperties)markerElement).Name = "DeleteMarker";

            }
            else if (action == "AcceptMarker")
            {
                ICharacterMarkerSymbol acceptMarkerSymbol = new CharacterMarkerSymbolClass();

                acceptMarkerSymbol.Font = esriDefaultMarkerFont;
                acceptMarkerSymbol.CharacterIndex = 105;
                acceptMarkerSymbol.Color = greenRgbColor;
                acceptMarkerSymbol.Size = 48;

                multiLayerMarkerSymbol.AddLayer(acceptMarkerSymbol);

                ((IElementProperties)markerElement).Name = "AcceptMarker";
            }

            markerElement.Symbol = (IMarkerSymbol)multiLayerMarkerSymbol;

            graphicsContainer.AddElement((IElement)markerElement, 99);

            updateMapControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 58
0
        public static IElement DrawPointMarker(IMap map, IPoint point)
        {
            IMarkerElement markerElement = new MarkerElementClass();
            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
            IRgbColor color = new RgbColorClass();
            color.Red = 200;
            color.Green = 100;
            color.Blue = 100;
            simpleMarkerSymbol.Color = color as IColor;
            simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare;            
            markerElement.Symbol = simpleMarkerSymbol;

            IElement element = markerElement as IElement;
            element.Geometry = point;

            IGraphicsContainer graphicsContainer = map as IGraphicsContainer;
            graphicsContainer.AddElement(element, 0);
            IActiveView activeView = map as IActiveView;
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            return element;
        }
Exemplo n.º 59
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);
        }
Exemplo n.º 60
0
        public void points()
        {
            string strs = "Marker";
            switch (strs)
            {
                case "Marker":

                    IMarkerElement pMarkerElement;//对于点,线,面的element定义这里都不一样,他是可实例化的类,而IElement是实例化的类,必须通过 IMarkerElement 初始化负值给 IElement 。
                    IElement pMElement;
                    IPoint pPoint=new PointClass();//你画的图形式什么就是什么,特别的是LINE则需要定义为POLYLINE
                    pMarkerElement = new MarkerElementClass();

                    pMElement = pMarkerElement as IElement;

                    RubberPointClass pRubberBand = new RubberPointClass();//你的RUBBERBAND随着你的图形耳边
                    //pPoint = pRubberBand.TrackNew(axMapControl.ActiveView.ScreenDisplay, null) as IPoint;
                    ////pPoint = pRubberBand.TrackNew(axMapControl.ActiveView.ScreenDisplay, null) as IPoint;
                    //pPoint.X = 101;
                    //pPoint.Y = 37;

                    // pPoint.PutCoords(Convert.ToDouble(101), Convert.ToDouble(37));
                    //pPoint = axMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(200, 200);
                    // pPoint.PutCoords(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));

                   // pPoint = axMapControl.ToMapPoint(334, 344);
                    //pPoint.X = pPoint.X;
                    //pPoint.Y = pPoint.Y;

                    /*00000000000000000000000000000000000经纬度转换坐标*/
                    //IGlobeDisplay m_globeDisplay = axGlobeControl1.GlobeDisplay;

                    //// IGlobeDisplay pGlobeDisplay = axGlobeControl1.GlobeDisplay;

                    ////axGlobeControl1.GlobeDisplay.ActiveViewer;
                    //ISceneViewer sceneViewer = m_globeDisplay.ActiveViewer;
                    //IGlobeViewUtil globeViewUtil = (IGlobeViewUtil)sceneViewer.Camera;

                    //int winX, winY;
                    ////globeViewUtil.GeographicToWindow(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text), 0, out winX, out winY);

                    ////pPoint.PutCoords(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));//x,y地理坐标

                    //pPoint=axMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(0, 0);//x,y为屏幕坐标
                    ////pPoint.X = Convert.ToDouble(textBox1.Text);
                    ////pPoint.Y = Convert.ToDouble(textBox2.Text);
                    //pPoint.PutCoords(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));//x,y地理坐标

                    //axMapControl.ActiveView.ScreenDisplay.DisplayTransformation.FromMapPoint(pPoint, out winX, out winY);
                    // int mx = winX;
                    //int my = winY;
                    //pPoint=axMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(200, 400);//x,y为屏幕坐标

                    //调用GetProject2方法经纬度转换成米
                    pPoint = GetProject2(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));

                    //pPoint.PutCoords(Convert.ToDouble(textBox3.Text), Convert.ToDouble(textBox4.Text));
                    /*00000000000000000000000000000000000*/

                   // pPoint = axMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(mx, my);

                    //pPoint.PutCoords(mx, my);
                    //pPoint.X = mx;
                    //pPoint.Y = my;

                    //ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
                    //pPoint.SpatialReference = pSRF.CreateProjectedCoordinateSystem(2414);
                    //pPoint.Project(pSRF.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_Beijing1954));

                    pMElement.Geometry = pPoint;//把你在屏幕中画好的图形付给 IElement 储存

                    IGraphicsContainer pGraphicsContainer = axMapControl.ActiveView as IGraphicsContainer;//把地图的当前view作为图片的容器
                   // axMapControl.get_Layer(0)

                    // ILayer pLayer = this.axMapControl.get_Layer(1);//所要加的层

                    pGraphicsContainer.AddElement(pMElement, 0);//显示储存在 IElement 中图形,这样就持久化了。
                    axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                    //axMapControl.Refresh();
                    break;

                case "Line":

                    //ILineElement pLineElement;
                    //IElement pLElement;

                    //IPolyline pLine;
                    // IGraphicsContainer pGraphicsContainerl = axMapControl.ActiveView as IGraphicsContainer;//把地图的当前view作为图片的容器
                    //pLineElement = new LineElementClass();
                    //pLElement = pLineElement as IElement;

                    //RubberLineClass pRubberBandd = new RubberLineClass();
                    //pLine = pRubberBandd.TrackNew(axMapControl.ActiveView.ScreenDisplay, null) as IPolyline;

                    //pLElement.Geometry = pLine;

                    //pGraphicsContainerl = axMapControl.ActiveView as IGraphicsContainer;//把地图的当前view作为图片的容器

                    //pGraphicsContainerl.AddElement(pLElement, 0);//把刚刚的element转到容器上
                    //axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                    //00000000000
                    //调用GetProject2方法经纬度转换成米
                    IPoint pPointl=new PointClass();//你画的图形式什么就是什么,特别的是LINE则需要定义为POLYLINE
                    pPointl = GetProject2(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));

                    IPoint pPointl2=new PointClass();//你画的图形式什么就是什么,特别的是LINE则需要定义为POLYLINE
                    pPointl2 = GetProject2(-120, 40);

                    //创建一个Line对象
                    ILine pLine2 = new LineClass();

                    //Polyline pLine2 = new PolylineClass();
                    //设置Line对象的起始终止点
                    pLine2.PutCoords(pPointl, pPointl2);

                    //IPointCollection pMultipoint = new MultipointClass();
                    //object o=Type.Missing;
                    //pMultipoint.AddPoint(pPointl, ref o, ref o);
                    //pMultipoint.AddPoint(pPointl2, ref o, ref o);

                      axMapControl.ActiveView.Refresh();//刷新当前视图
                    break;
                case "Fill":
                    IFillShapeElement pFillShapeElement;
                    IElement pgonElemnt;

                    IPolygon pPolygon;
                    pFillShapeElement = new PolygonElementClass();
                    pgonElemnt = pFillShapeElement as IElement;//Element

                    RubberPolygonClass pRubberBand3 = new RubberPolygonClass();//在屏幕上画个多边形
                    pPolygon = pRubberBand3.TrackNew(axMapControl.ActiveView.ScreenDisplay, null) as IPolygon;

                    pgonElemnt.Geometry = pPolygon;//把这个多边形转成Element

                    pGraphicsContainer = axMapControl.ActiveView as IGraphicsContainer;//把地图的当前view作为图片的容器

                    //pGraphicsContainer.DeleteAllElements ();
                    pGraphicsContainer.AddElement(pgonElemnt, 0);//把刚刚的element转到容器上
                    axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                    break;
            }
        }