コード例 #1
0
ファイル: QueryIntersectionUI.cs プロジェクト: secondii/Yutai
        public void NewBasePointElement()
        {
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)m_context.ActiveView;

            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol();
            IRgbColor           rgbColor           = new RgbColor();

            rgbColor.Red   = 255;
            rgbColor.Green = 0;
            rgbColor.Blue  = 0;
            IRgbColor rgbColor2 = new RgbColor();

            rgbColor2.Red                   = 0;
            rgbColor2.Green                 = 0;
            rgbColor2.Blue                  = 0;
            simpleMarkerSymbol.Style        = (esriSimpleMarkerStyle)(3);
            simpleMarkerSymbol.Color        = (rgbColor);
            simpleMarkerSymbol.Outline      = (true);
            simpleMarkerSymbol.OutlineSize  = (1.0);
            simpleMarkerSymbol.OutlineColor = (rgbColor2);
            simpleMarkerSymbol.Size         = (12.0);
            IElement       element       = new MarkerElement();
            IMarkerElement markerElement = element as IMarkerElement;

            markerElement.Symbol = (simpleMarkerSymbol);
            element.Geometry     = m_pGeoFlash;
            graphicsContainer.AddElement(element, 0);
        }
コード例 #2
0
ファイル: CreatePoint.cs プロジェクト: icye/IGeometry
        protected override void OnMouseDown(MouseEventArgs arg)
        {
            base.OnMouseDown(arg);


            IMxDocument        pMxdoc = ArcMap.Application.Document as IMxDocument;
            IPoint             pPoint = pMxdoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);
            IGraphicsContainer pGC    = pMxdoc.ActiveView.GraphicsContainer;

            IElement       pElement       = new MarkerElement();
            IMarkerElement pMarkerElement = pElement as IMarkerElement;

            ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbol();

            pMarkerSymbol.Size = 10;

            IRgbColor pColor = new RgbColor();

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

            pMarkerSymbol.Color = pColor;

            pMarkerElement.Symbol = pMarkerSymbol;
            pElement.Geometry     = pPoint;


            pGC.AddElement(pElement, 0);
            pMxdoc.ActiveView.Refresh();
        }
コード例 #3
0
        public static void NewBasePointElement(IActiveView pView, IPoint pPoint)
        {
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)pView;

            new RubberPoint();
            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol();
            IRgbColor           rgbColor           = new RgbColor();

            rgbColor.Red   = (255);
            rgbColor.Green = (0);
            rgbColor.Blue  = (0);
            IRgbColor rgbColor2 = new RgbColor();

            rgbColor2.Red                   = (0);
            rgbColor2.Green                 = (0);
            rgbColor2.Blue                  = (0);
            simpleMarkerSymbol.Style        = (esriSimpleMarkerStyle)(3);
            simpleMarkerSymbol.Color        = (rgbColor);
            simpleMarkerSymbol.Outline      = (true);
            simpleMarkerSymbol.OutlineSize  = (1.0);
            simpleMarkerSymbol.OutlineColor = (rgbColor2);
            simpleMarkerSymbol.Size         = (12.0);
            IElement       element       = new MarkerElement();
            IMarkerElement markerElement = element as IMarkerElement;

            markerElement.Symbol = (simpleMarkerSymbol);
            element.Geometry     = (pPoint);
            graphicsContainer.AddElement(element, 0);
        }
コード例 #4
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();
        }
コード例 #5
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);
        }
コード例 #6
0
ファイル: Extension.cs プロジェクト: LukeYoungSFI/FRA_Tool
        public static void ZoomToCurrentError(IMxDocument pMxDoc, double zoomingAdjust, IPoint pPoint)
        {
            IMap pMap = pMxDoc.FocusMap as IMap;
            IGraphicsContainer pGraphicsContainer = pMap as IGraphicsContainer;
            //ILayer pLayer = null;
            //pLayer.Visible = false;
            ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbol();
            IRgbColor           pLightGreen         = (IRgbColor) new RgbColor();

            pLightGreen.Red                  = 181;
            pLightGreen.Green                = 230;
            pLightGreen.Blue                 = 96;
            pSimpleMarkerSymbol.Color        = pLightGreen;
            pSimpleMarkerSymbol.Outline      = true;
            pSimpleMarkerSymbol.OutlineColor = pLightGreen;
            pSimpleMarkerSymbol.OutlineSize  = 2;
            pSimpleMarkerSymbol.Size         = 25;
            pSimpleMarkerSymbol.Style        = esriSimpleMarkerStyle.esriSMSCross;
            IMarkerElement pMarkerElement = (IMarkerElement) new MarkerElement();

            pMarkerElement.Symbol = pSimpleMarkerSymbol;
            IElement pElement = pMarkerElement as IElement;

            pElement.Geometry = pPoint as IGeometry;
            pGraphicsContainer.DeleteAllElements();
            pGraphicsContainer.AddElement(pElement, 0);

            // IEnvelope pExtent = Data.ErrorTable[Data.CurrentErrorIndex].Penvelope;
            // pExtent.Expand(zoomingAdjust, zoomingAdjust, true);
            IEnvelope pExtent = (IEnvelope) new Envelope();

            pExtent.PutCoords(pPoint.X - zoomingAdjust, pPoint.Y - zoomingAdjust, pPoint.X + zoomingAdjust, pPoint.Y + zoomingAdjust);
            pMxDoc.ActiveView.Extent = pExtent;
            pMxDoc.ActiveView.Refresh();
        }
コード例 #7
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            m_pAnchorPoint = this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            if (m_pAnchorPoint == null)
            {
                return;
            }
            simpleMarkerSymbol      = new SimpleMarkerSymbolClass();
            markerElement           = new MarkerElementClass();
            element                 = (IElement)markerElement;
            element.Geometry        = m_pAnchorPoint;
            simpleMarkerSymbol.Size = SystemInfo.Instance.SymbolSize;

            simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;

            Color  color  = ColorTranslator.FromHtml(SystemInfo.Instance.LineColor);
            IColor pColor = new RgbColorClass();

            pColor.RGB = color.B * 65536 + color.G * 256 + color.R;
            simpleMarkerSymbol.Color = pColor;
            markerElement.Symbol     = simpleMarkerSymbol;

            if (element != null)
            {
                pGraphicsContainer = this.m_pMapControl.ActiveView as IGraphicsContainer;
                pGraphicsContainer.AddElement(element, 0);
                this.m_pMapControl.ActiveView.Refresh();
            }
            Result = "X=" + m_pAnchorPoint.X.ToString(".##") + "; " + "Y=" + m_pAnchorPoint.Y.ToString(".##");
            FrmCoordinate.Instance().ShowDialog();
        }
コード例 #8
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);
        }
コード例 #9
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();
        }
コード例 #10
0
 private bool method_2(IElement ielement_1, out ICallout icallout_0)
 {
     icallout_0 = null;
     try
     {
         if (ielement_1 is ITextElement)
         {
             ITextElement element = ielement_1 as ITextElement;
             ITextSymbol  symbol  = element.Symbol;
             if (!(symbol is IFormattedTextSymbol))
             {
                 return(false);
             }
             IFormattedTextSymbol symbol2    = symbol as IFormattedTextSymbol;
             ITextBackground      background = symbol2.Background;
             if (background == null)
             {
                 return(false);
             }
             if (!(background is ICallout))
             {
                 return(false);
             }
             icallout_0 = background as ICallout;
             return(true);
         }
         if (ielement_1 is IMarkerElement)
         {
             IMarkerElement element2 = ielement_1 as IMarkerElement;
             IMarkerSymbol  symbol3  = element2.Symbol;
             if (!(symbol3 is IMarkerBackgroundSupport))
             {
                 return(false);
             }
             IMarkerBackgroundSupport support     = symbol3 as IMarkerBackgroundSupport;
             IMarkerBackground        background2 = support.Background;
             if (background2 == null)
             {
                 return(false);
             }
             if (!(background2 is ICallout))
             {
                 return(false);
             }
             icallout_0 = background2 as ICallout;
             return(true);
         }
     }
     catch
     {
     }
     return(false);
 }
コード例 #11
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            //If left mouse button then zoom in
            if (e.button == 1)
            {
                m_MapControl.Extent = m_MapControl.TrackRectangle();
            }
            else
            {
                //Create a point and get the IPoint interface
                IPoint point = new PointClass();
                //Set points coordinates
                point.PutCoords(e.mapX, e.mapY);

                //QI for ITopologicalOperator interface through IPoint interface
                ITopologicalOperator topologicalOperator = (ITopologicalOperator)point;
                //Create a polygon by buffering the point and get the IPolygon interface
                IPolygon polygon = (IPolygon)topologicalOperator.Buffer(m_MapControl.Extent.Width * 0.02);
                //QI for IRelationalOperator interface through IPolygon interface
                IRelationalOperator relationalOperator = (IRelationalOperator)polygon;

                object o = null;
                //Draw the polygon
                m_MapControl.DrawShape(polygon, ref o);

                //Loop through the elements in the GraphicContainer and get the IElement interface
                m_GraphicsContainer.Reset();
                IElement element = m_GraphicsContainer.Next();
                while (element != null)
                {
                    //If the polygon contains the point
                    if (relationalOperator.Contains(element.Geometry) == true)
                    {
                        //QI for IMarkerElement interface through IElement interface
                        IMarkerElement markerElement = (IMarkerElement)element;
                        markerElement.Symbol = GetMarkerSymbol(true);
                        //QI for the IElementProperties interface through IElement interface
                        IElementProperties elementProperties = (IElementProperties)element;
                        elementProperties.Name = true.ToString();
                    }
                    element = m_GraphicsContainer.Next();
                }
                if (chkTracking.CheckState == CheckState.Unchecked)
                {
                    //Refresh the graphics
                    m_MapControl.Refresh(esriViewDrawPhase.esriViewGraphics, Type.Missing, Type.Missing);
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// 在场景中绘制点要素  20110609
        /// </summary>
        /// <param name="pGeometry">点要素</param>
        /// <param name="r"></param>
        /// <param name="g"></param>
        /// <param name="b"></param>
        /// <param name="Size">符号大小</param>
        /// <returns></returns>
        public static IElement DrawPoint(IGeometry pGeometry, int r, int g, int b, double Size)
        {
            IElement markerElement = new MarkerElementClass();
            ISimpleMarker3DSymbol pSimpleMarker3DSymbol = new SimpleMarker3DSymbolClass();

            pSimpleMarker3DSymbol.Style             = esriSimple3DMarkerStyle.esriS3DMSSphere;
            pSimpleMarker3DSymbol.ResolutionQuality = 1;
            IMarkerSymbol pMarkerSymbol = pSimpleMarker3DSymbol as IMarkerSymbol;

            pMarkerSymbol.Size     = Size;
            pMarkerSymbol.Color    = getRGB(r, g, b);
            markerElement.Geometry = pGeometry;
            IMarkerElement pMarkerElement = markerElement as IMarkerElement;

            pMarkerElement.Symbol = pMarkerSymbol;
            return(markerElement);
        }
コード例 #13
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);
        }
コード例 #14
0
        /// <summary>
        /// 设置标注的样式外观
        /// </summary>
        /// <param name="size">缩放比例 1.5</param>
        /// <param name="pColor">颜色</param>
        /// <param name="pEle">要改变的颜色</param>
        /// <param name="direction">true为改变,false为还原</param>
        /// <returns></returns>
        private static IElement setElementStyle(double size, IRgbColor pColor, IElement pEle, bool direction)
        {
            IMarkerElement      pMarEle    = pEle as IMarkerElement;
            ISimpleMarkerSymbol pMarSymbol = pMarEle.Symbol as ISimpleMarkerSymbol;

            //axMapControl1.FlashShape(pEle.Geometry, 1, 300, pMarEle.Symbol);          //element闪烁,symbol没有则闪烁Geometry
            if (direction)
            {
                pMarSymbol.Size *= size;
            }
            else
            {
                pMarSymbol.Size /= size;
            }
            pMarSymbol.Color = pColor;
            pMarEle.Symbol   = pMarSymbol;
            pEle             = pMarEle as IElement;
            return(pEle);
        }
コード例 #15
0
        public object ConvertToSupportedObject(esriArcGISVersion docVersion)
        {
            ICharacterMarkerSymbol characterMarkerSymbolClass = new CharacterMarkerSymbol()
            {
                Color = this.m_fillSymbol.Color,
                Angle = this.m_rotation,
                Size  = this.m_size,
                //Font = ESRI.ArcGIS.ADF.Local.Converter.ToStdFont(new Font("ESRI Default Marker", (float)this.m_size, FontStyle.Regular)),
                CharacterIndex = 184
            };
            IMarkerElement markerElement = new MarkerElement() as IMarkerElement;

            markerElement.Symbol = characterMarkerSymbolClass;
            IMarkerElement markerElementClass = markerElement as IMarkerElement;
            IPoint         point   = ((IClone)this.m_pointGeometry).Clone() as IPoint;
            IElement       element = (IElement)markerElementClass;

            element.Geometry = point;

            return(element);
        }
コード例 #16
0
ファイル: CmdCreatePoint.cs プロジェクト: wwcc19870805/DIFGIS
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            {
                //控制符号的大小与不随地图缩放
                //                 rubberBand = new RubberPointClass();
                //                 point = rubberBand.TrackNew(this.m_pMapControl.ActiveView.ScreenDisplay, null) as IPoint;
                //                 IEnvelope pEnv = new EnvelopeClass();
                //                 pEnv.PutCoords(point.X, point.Y, point.X + 10, point.Y + 10);
                point = this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                if (point == null)
                {
                    return;
                }
                pRGB                    = new RgbColorClass();
                pRGB.Red                = 255;
                pRGB.Green              = 0;
                pRGB.Blue               = 0;
                simpleMarkerSymbol      = new SimpleMarkerSymbolClass();
                markerElement           = new MarkerElementClass();
                element                 = (IElement)markerElement;
                element.Geometry        = point;
                simpleMarkerSymbol.Size = SystemInfo.Instance.SymbolSize;

                simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;

                Color  color  = ColorTranslator.FromHtml(SystemInfo.Instance.LineColor);
                IColor pColor = new RgbColorClass();
                pColor.RGB = color.B * 65536 + color.G * 256 + color.R;
                simpleMarkerSymbol.Color = pColor;
                markerElement.Symbol     = simpleMarkerSymbol;

                if (element != null)
                {
                    pGraphicsContainer = this.m_pMapControl.ActiveView as IGraphicsContainer;
                    pGraphicsContainer.AddElement(element, 0);
                    this.m_pMapControl.ActiveView.Refresh();
                }
                base.OnMouseDown(button, shift, x, y, mapX, mapY);
            }
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        private void DrawPointsOnActiveView(int colindex, int rowindex, IRasterProps pRasterProps, IActiveView ActiveView)
        {
            IGraphicsContainer pGraphicContainer = ActiveView.GraphicsContainer;

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

            //ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
            //pSimpleLineSymbol.Width = 2;
            //pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            //pSimpleLineSymbol.Color = pRgbColor;

            ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();

            pSimpleMarkerSymbol.Size  = 8;
            pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            pSimpleMarkerSymbol.Color = pRgbColor;

            double dblX = 0, dblY = 0;
            double dblCellSize = Convert.ToDouble(pRasterProps.MeanCellSize().X);

            dblX = pRasterProps.Extent.XMin + (dblCellSize / 2) + dblCellSize * colindex;
            dblY = pRasterProps.Extent.YMax - (dblCellSize / 2) - dblCellSize * rowindex;

            IPoint pPoint = new PointClass();

            pPoint.X = dblX;
            pPoint.Y = dblY;

            IElement pElement = new MarkerElementClass();

            IMarkerElement pMarkerElement = (IMarkerElement)pElement;

            pMarkerElement.Symbol = pSimpleMarkerSymbol;
            pElement.Geometry     = pPoint;

            pGraphicContainer.AddElement(pElement, 0);

            ActiveView.Refresh();
        }
コード例 #19
0
        //this method is called when the user clicks the "Compare Vertices" button at the bottom of the form
        private void cmdCompare_Click(object sender, EventArgs e)
        {
            try
            {
                if (cboLayer1.SelectedItem.ToString() == "" || cboLayer2.SelectedItem.ToString() == "" || txtOID1.Text == "" || txtOID2.Text == "") //the double pipe is an or operator that "short circuts", meaning that it will bail out early if the condition is true, whereas the single pipe evaluates all conditions
                {
                    MessageBox.Show("Choose polygon layer, or specify OBJECTID.", "Verify Selections...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //show busy mouse
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                IFeatureLayer pFeatureLayer1 = null;
                IFeatureLayer pFeatureLayer2 = null;

                IPointCollection pPtnCollMissingVertices = new MultipointClass(); //point collection for missing vertices and used for graphics layer
                IPoint           pPointMissing           = new PointClass();      //used for graphics layer

                //get access to polygon layer 1
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    if (pMap.get_Layer(i) is IFeatureLayer)
                    {
                        if (pMap.get_Layer(i).Name.ToString() == cboLayer1.SelectedItem.ToString())
                        {
                            pFeatureLayer1 = pMap.get_Layer(i) as IFeatureLayer;
                            break;
                        }
                    }
                }

                //get access to polygon layer 2
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    if (pMap.get_Layer(i) is IFeatureLayer)
                    {
                        if (pMap.get_Layer(i).Name.ToString() == cboLayer2.SelectedItem.ToString())
                        {
                            pFeatureLayer2 = pMap.get_Layer(i) as IFeatureLayer;
                            break;
                        }
                    }
                }

                //clear the x,y report list box
                lstMissingVertices.Items.Clear();


                //get vertices for feature 1
                //set up query filter for feature 1
                IQueryFilter pQueryFilter = new QueryFilter();
                pQueryFilter.WhereClause = "OBJECTID = " + txtOID1.Text;

                //set up feature cursor for feature 1
                IFeatureCursor pFeatureCursor = pFeatureLayer1.Search(pQueryFilter, false);

                //get feature 1
                IFeature pFeature1 = pFeatureCursor.NextFeature();

                //if no objectid is found
                if (pFeature1 == null)
                {
                    MessageBox.Show("The provided OBJECTID was not found for layer: " + cboLayer1.SelectedItem, "ObjectID Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //get feature 1 as a polygon
                IPolygon pPolygon1 = pFeature1.Shape as IPolygon;

                //get the point collection for feature 1
                IPointCollection pPointColl1 = pPolygon1 as IPointCollection;


                //get vertices for feature 2
                //set up query filter for feature 2
                pQueryFilter             = new QueryFilter();
                pQueryFilter.WhereClause = "OBJECTID = " + txtOID2.Text;

                //set up feature cursor for feature 2
                pFeatureCursor = null; //reuse the feature cursor from above
                pFeatureCursor = pFeatureLayer2.Search(pQueryFilter, false);

                //get feature 2
                IFeature pFeature2 = pFeatureCursor.NextFeature();

                //if no objectid is found
                if (pFeature2 == null)
                {
                    MessageBox.Show("The provided OBJECTID was not found for layer: " + cboLayer1.SelectedItem, "ObjectID Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //get feature 1 as a polygon
                IPolygon pPolygon2 = pFeature2.Shape as IPolygon;

                //get the point collection for feature 1
                IPointCollection pPointColl2 = pPolygon2 as IPointCollection;


                //loop through point collection and check for missing vertices
                IPoint  pPoint1;
                IPoint  pPoint2;
                Boolean blnFound;


                //loop through each point in the first collection and check for missing
                for (int i = 0; i < pPointColl1.PointCount; i++)
                {
                    pPoint1 = pPointColl1.get_Point(i);

                    //loop through all the points in the second collection and check for the point from the above collection
                    blnFound = false;
                    for (int j = 0; j < pPointColl2.PointCount; j++)
                    {
                        pPoint2 = pPointColl2.get_Point(j);

                        //check for overlapping points
                        if (pPoint1.X == pPoint2.X && pPoint1.Y == pPoint2.Y)
                        {
                            blnFound = true;
                        }
                    }

                    //if no overlapping points were found, report the missing x,y location to the listbox
                    if (blnFound == false)
                    {
                        lstMissingVertices.Items.Add(pPoint1.X + " " + pPoint1.Y + " " + " Feet" + " (missing from polygon 2)");

                        //add the missing point to a new collection for display on map
                        pPtnCollMissingVertices.AddPoint(pPoint1);
                    }
                }


                //loop through each point in the first collection and check for missing
                for (int i = 0; i < pPointColl2.PointCount; i++)
                {
                    pPoint2 = pPointColl2.get_Point(i);

                    //loop through all the points in the second collection and check for the point from the above collection
                    blnFound = false;
                    for (int j = 0; j < pPointColl1.PointCount; j++)
                    {
                        pPoint1 = pPointColl1.get_Point(j);

                        //check for overlapping points
                        if (pPoint2.X == pPoint1.X && pPoint2.Y == pPoint1.Y)
                        {
                            blnFound = true;
                        }
                    }

                    //if no overlapping points were found, report the missing x,y location to the listbox
                    if (blnFound == false)
                    {
                        lstMissingVertices.Items.Add(pPoint2.X + " " + pPoint2.Y + " " + " Feet" + " (missing from polygon 1)");

                        //add the missing point to a new collection for display on map
                        pPtnCollMissingVertices.AddPoint(pPoint2);
                    }
                }


                //if no missing vertices were found, inform the user
                if (lstMissingVertices.Items.Count < 1)
                {
                    lstMissingVertices.Items.Add("No Missing Vertices Found");
                }


                //display vertices if checkbox is checked
                if (chkDisplayVertices.Checked == true)
                {
                    //show busy mouse
                    System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                    //set up the graphics layer for the display of vertices
                    ICompositeGraphicsLayer2 pCompositeGraphicLayer = pMap.BasicGraphicsLayer as ICompositeGraphicsLayer2;
                    ICompositeLayer          pCompositeLayer        = pCompositeGraphicLayer as ICompositeLayer;
                    ILayer             pLayer;
                    IGraphicsLayer     pGraphicsLayer;
                    IGraphicsContainer pGraphicsContainer;

                    //loop through the graphics layer and check for the missing vertices layer.  if found, delete it
                    for (int i = 0; i < pCompositeLayer.Count; i++)
                    {
                        pLayer = pCompositeLayer.Layer[i];
                        if (pLayer.Name == "MissingVertices")
                        {
                            pCompositeGraphicLayer.DeleteLayer("MissingVertices");
                            break;
                        }
                    }


                    //set up a new 'missing vertices' graphics layer
                    pGraphicsLayer           = pCompositeGraphicLayer.AddLayer("MissingVertices", null);
                    pMap.ActiveGraphicsLayer = pGraphicsLayer as ILayer;
                    pGraphicsContainer       = pCompositeGraphicLayer.FindLayer("MissingVertices") as IGraphicsContainer;

                    //define the color
                    ESRI.ArcGIS.Display.IRgbColor rgbColorCls = new ESRI.ArcGIS.Display.RgbColorClass();
                    rgbColorCls.Red   = 250;
                    rgbColorCls.Green = 0;
                    rgbColorCls.Blue  = 0;

                    //define the font
                    stdole.IFontDisp stdFontCls = new stdole.StdFontClass() as stdole.IFontDisp;
                    stdFontCls.Name = "ESRI Surveyor Marker"; //this one has a thin-line hollow circle
                    stdFontCls.Name = "ESRI Surveyor";        //this one has a bold-line hollow circle
                    stdFontCls.Size = 16;

                    //set the character marker symbol's properties
                    ESRI.ArcGIS.Display.ICharacterMarkerSymbol charMarkerSymb = new ESRI.ArcGIS.Display.CharacterMarkerSymbolClass();
                    charMarkerSymb.Angle          = 0;
                    charMarkerSymb.CharacterIndex = 47;
                    charMarkerSymb.Color          = rgbColorCls;
                    charMarkerSymb.Font           = stdFontCls;
                    charMarkerSymb.Size           = 16;
                    charMarkerSymb.XOffset        = 0;
                    charMarkerSymb.YOffset        = 0;

                    //place the graphics on the map
                    for (int i = 0; i < pPtnCollMissingVertices.PointCount; i++)
                    {
                        pPointMissing = pPtnCollMissingVertices.Point[i];
                        IElement pElement = new MarkerElement();
                        pElement.Geometry = pPointMissing;
                        IMarkerElement pMarkerElement = pElement as IMarkerElement;
                        pMarkerElement.Symbol = charMarkerSymb;
                        pGraphicsContainer.AddElement(pElement, 0);
                    }

                    //refresh the map, in order to see the newly added graphics
                    pActiveView.Refresh();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine +
                                "Error Source: " + Environment.NewLine + ex.Source + Environment.NewLine + Environment.NewLine +
                                "Error Location:" + Environment.NewLine + ex.StackTrace,
                                "AGRC Custom Tools ArcMap Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #20
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            try
            {
                //get access to the document and the active view
                pMxDocument = (IMxDocument)clsAgrcArcMapExtension.m_application.Document;
                pMap        = pMxDocument.FocusMap;
                pActiveView = pMxDocument.ActiveView;                  //pActiveView = (IActiveView)pMap;

                //get the map's graphics layer
                ICompositeGraphicsLayer2 pComGraphicsLayer = pMap.BasicGraphicsLayer as ICompositeGraphicsLayer2;
                ICompositeLayer          pCompositeLayer   = pComGraphicsLayer as ICompositeLayer;
                ILayer pLayer;

                //loop through all graphic layers in the map and check for the 'PolyVertices' layer, if found, delete it, in order to start fresh
                for (int i = 0; i < pCompositeLayer.Count; i++)
                {
                    pLayer = pCompositeLayer.get_Layer(i);
                    if (pLayer.Name == "PolyVertices")
                    {
                        pComGraphicsLayer.DeleteLayer("PolyVertices");
                        break;
                    }
                }


                if (bolVerticesOn == false)
                {
                    IGraphicsLayer pGraphicsLayer = pComGraphicsLayer.AddLayer("PolyVertices", null);
                    pMap.ActiveGraphicsLayer = (ILayer)pGraphicsLayer;
                    IGraphicsContainer pGraphicsContainer = pComGraphicsLayer.FindLayer("PolyVertices") as IGraphicsContainer;


                    //make sure the user has selected a polygon or polyline layer
                    if (pMxDocument.SelectedLayer == null)
                    {
                        MessageBox.Show("Please select a layer.", "Select Layer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (!(pMxDocument.SelectedLayer is IFeatureLayer))
                    {
                        MessageBox.Show("Please select a polygon or line layer.", "Polygon or Line", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    //cast the selected layer as a feature layer
                    IGeoFeatureLayer pGFlayer = (IGeoFeatureLayer)pMxDocument.SelectedLayer;

                    //check if the feaure layer is a polygon or line layer
                    if (pGFlayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon & pGFlayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline)
                    {
                        MessageBox.Show("Please select a polygon or line layer.", "Polygon or Line", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }


                    //setup marker symbol
                    ISimpleMarkerSymbol pSimpleMarker = new SimpleMarkerSymbol();
                    ISymbol             pSymbolMarker = (ISymbol)pSimpleMarker;
                    IRgbColor           pRgbColor     = new ESRI.ArcGIS.Display.RgbColorClass();
                    pRgbColor.Red       = 223;
                    pRgbColor.Green     = 155;
                    pRgbColor.Blue      = 255;
                    pSimpleMarker.Color = pRgbColor;
                    pSimpleMarker.Style = esriSimpleMarkerStyle.esriSMSDiamond;
                    pSimpleMarker.Size  = 8;

                    //setup line symbol
                    ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbol();
                    ISymbol           pSymbolLine       = (ISymbol)pSimpleLineSymbol;
                    pRgbColor               = new ESRI.ArcGIS.Display.RgbColor();
                    pRgbColor.Red           = 0;
                    pRgbColor.Green         = 255;
                    pRgbColor.Blue          = 0;
                    pSimpleLineSymbol.Color = pRgbColor;
                    pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                    pSimpleLineSymbol.Width = 1;

                    //setup simplefill symbol
                    ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbol();
                    ISymbol           pSymbolPolygon    = (ISymbol)pSimpleFillSymbol;
                    pRgbColor               = new ESRI.ArcGIS.Display.RgbColor();
                    pRgbColor.Red           = 0;
                    pRgbColor.Green         = 0;
                    pRgbColor.Blue          = 255;
                    pSimpleFillSymbol.Color = pRgbColor;
                    pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;

                    //get all the polygons in the current map extent ina cursor
                    IEnvelope      pMapExtent = pActiveView.Extent;
                    ISpatialFilter pQFilter   = new SpatialFilter();
                    pQFilter.GeometryField = "SHAPE";
                    pQFilter.Geometry      = pMapExtent;
                    pQFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                    IFeatureCursor pFCursor = pGFlayer.Search(pQFilter, true);


                    //draw each polygon and then each polygon's point collection
                    IFeature  pFeature = pFCursor.NextFeature();
                    IGeometry pGeometry;

                    while (pFeature != null)
                    {
                        pGeometry = pFeature.Shape;
                        //draw the polygon
                        //draw each vertex on the polygon
                        IPointCollection pPointCollection = pGeometry as IPointCollection;
                        for (int i = 0; i < pPointCollection.PointCount; i++)
                        {
                            IGeometry pPtGeom  = pPointCollection.get_Point(i);
                            IElement  pElement = new MarkerElement();
                            pElement.Geometry = pPtGeom;
                            IMarkerElement pMarkerElement = pElement as IMarkerElement;
                            pMarkerElement.Symbol = pSimpleMarker;
                            pGraphicsContainer.AddElement(pElement, 0);
                        }
                        pFeature = pFCursor.NextFeature();
                    }

                    bolVerticesOn = true;
                }
                else                 //if (bolVerticesOn == true)
                {
                    bolVerticesOn = false;
                }

                //refresh the map
                pActiveView.Refresh();
                pActiveView.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine +
                                "Error Source: " + Environment.NewLine + ex.Source + Environment.NewLine + Environment.NewLine +
                                "Error Location:" + Environment.NewLine + ex.StackTrace,
                                "AGRC Custom Tools ArcMap Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #21
0
ファイル: XiangMapClass.cs プロジェクト: secondii/Yutai
        public void DrawGrid()
        {
            string              str        = "";
            string              str2       = "";
            ITextElement        element    = null;
            ITextElement        element2   = null;
            ITextElement        element3   = null;
            ITextElement        element4   = null;
            double              num        = 40.0;
            double              num2       = 20.0;
            double              num3       = 10.0;
            int                 num4       = 13;
            int                 num5       = 10;
            IPoint              point      = null;
            IElement            item       = null;
            ITextSymbol         symbol     = new TextSymbolClass();
            ITextSymbol         symbol2    = new TextSymbolClass();
            ITextSymbol         symbol3    = new TextSymbolClass();
            ITextSymbol         symbol4    = new TextSymbolClass();
            ITextSymbol         symbol5    = new TextSymbolClass();
            ITextSymbol         symbol6    = new TextSymbolClass();
            int                 num6       = 0;
            int                 num7       = 0;
            int                 num8       = 1000;
            double              x          = 0.0;
            double              y          = 0.0;
            IPoint              point2     = new PointClass();
            object              missing    = System.Type.Missing;
            IElementProperties2 properties = null;
            IMarkerElement      element6   = null;
            ISymbol             symbol7    = new SimpleMarkerSymbolClass();
            ISimpleMarkerSymbol symbol8    = symbol7 as ISimpleMarkerSymbol;
            IRgbColor           color      = new RgbColorClass
            {
                Red   = 0,
                Blue  = 0,
                Green = 0
            };

            symbol8.Size  = 10.0;
            symbol8.Style = esriSimpleMarkerStyle.esriSMSCross;
            symbol8.Color = color;
            double num11 = 0.0;
            double num12 = 0.0;
            double num13 = 0.0;
            double num14 = 0.0;
            int    num15 = 0;
            int    num16 = 0;
            int    num17 = 0;
            int    num18 = 0;
            int    num19 = 0;
            double num20 = 0.0;
            double num21 = 0.0;
            double num22 = 0.0;
            double num23 = 0.0;

            try
            {
                symbol = base.FontStyle((double)num4, esriTextHorizontalAlignment.esriTHARight,
                                        esriTextVerticalAlignment.esriTVABottom);
                symbol2 = base.FontStyle((double)num5, esriTextHorizontalAlignment.esriTHALeft,
                                         esriTextVerticalAlignment.esriTVABottom);
                symbol3 = base.FontStyle((double)num5, esriTextHorizontalAlignment.esriTHARight,
                                         esriTextVerticalAlignment.esriTVATop);
                symbol4 = base.FontStyle((double)num4, esriTextHorizontalAlignment.esriTHALeft,
                                         esriTextVerticalAlignment.esriTVATop);
                symbol5 = base.FontStyle((double)num5, esriTextHorizontalAlignment.esriTHARight,
                                         esriTextVerticalAlignment.esriTVABottom);
                symbol6 = base.FontStyle((double)num4, esriTextHorizontalAlignment.esriTHALeft,
                                         esriTextVerticalAlignment.esriTVABottom);
                if (base.LeftUp.Y < base.RightUp.Y)
                {
                    y     = Math.Truncate(base.LeftUp.Y);
                    num23 = (base.RightUp.Y + base.InOutDist) + 1.0;
                }
                else
                {
                    y     = Math.Truncate(base.RightUp.Y);
                    num23 = (base.LeftUp.Y + base.InOutDist) + 1.0;
                }
                num15 = (int)(y % ((double)num8));
                if (num15 != 0)
                {
                    num12 = y - num15;
                }
                else
                {
                    num12 = y;
                }
                if (base.LeftUp.X > base.LeftLow.X)
                {
                    x     = Math.Truncate((double)(base.LeftUp.X + 1.0));
                    num20 = (base.LeftLow.X - base.InOutDist) - 1.0;
                }
                else
                {
                    x     = Math.Truncate((double)(base.LeftLow.X + 1.0));
                    num20 = (base.LeftUp.X - base.InOutDist) - 1.0;
                }
                num15 = (int)(x % ((double)num8));
                if (num15 != 0)
                {
                    num11 = x + (num8 - num15);
                }
                else
                {
                    num11 = x;
                }
                if (base.LeftLow.Y < base.RightLow.Y)
                {
                    y     = Math.Truncate(base.LeftLow.Y);
                    num21 = (base.LeftLow.Y - base.InOutDist) - 1.0;
                }
                else
                {
                    y     = Math.Truncate(base.RightLow.Y);
                    num21 = (base.RightLow.Y - base.InOutDist) - 1.0;
                }
                num15 = (int)(y % ((double)num8));
                if (num15 != 0)
                {
                    num14 = y + (num8 - num15);
                }
                else
                {
                    num14 = y;
                }
                if (base.RightUp.X > base.RightLow.X)
                {
                    x     = Math.Truncate(base.RightLow.X);
                    num22 = (base.RightUp.X + base.InOutDist) + 1.0;
                }
                else
                {
                    x     = Math.Truncate(base.RightUp.X);
                    num22 = (base.RightLow.X + base.InOutDist) + 1.0;
                }
                num15 = (int)(x % ((double)num8));
                if (num15 != 0)
                {
                    num13 = x - num15;
                }
                else
                {
                    num13 = x;
                }
                num16 = ((int)(num12 - num14)) / num8;
                num17 = ((int)(num13 - num11)) / num8;
                for (num18 = 0; num18 <= num16; num18++)
                {
                    y = num12 - (num18 * num8);
                    for (num19 = 0; num19 <= num17; num19++)
                    {
                        x = num11 + (num19 * num8);
                        point2.PutCoords(x, y);
                        item = new MarkerElementClass
                        {
                            Geometry = point2
                        };
                        element6        = item as IMarkerElement;
                        element6.Symbol = symbol8;
                        properties      = item as IElementProperties2;
                        properties.Type = "公里网";
                        this.ilist_0.Add(item);
                    }
                }
                IPolygon polygon = new PolygonClass();
                new PolygonElementClass();
                polygon = this.method_3();
                double           num1      = base.LeftUp.X - base.InOutDist;
                double           num24     = base.LeftUp.X;
                double           num25     = base.RightUp.X;
                double           num26     = base.RightUp.X + base.InOutDist;
                IPoint           inPoint   = null;
                IPoint           point4    = null;
                IPoint           point5    = null;
                IPoint           point6    = null;
                IPolyline        polyline  = new PolylineClass();
                IPolyline        polyline2 = new PolylineClass();
                IPolyline        polyline3 = new PolylineClass();
                IPoint           point7    = null;
                IPoint           point8    = null;
                IPointCollection points    = null;
                IPointCollection points2   = null;
                IElement         element7  = null;
                IElement         element8  = null;
                ILineElement     element9  = null;
                ILineSymbol      symbol9   = this.method_5(1);
                for (num18 = 0; num18 <= num16; num18++)
                {
                    y      = num12 - (num18 * num8);
                    point7 = new PointClass();
                    point8 = new PointClass();
                    point7.PutCoords(num20, y);
                    point8.PutCoords(num22, y);
                    points = polyline3 as IPointCollection;
                    if (points.PointCount >= 1)
                    {
                        points.RemovePoints(0, points.PointCount);
                    }
                    points.AddPoint(point7, ref missing, ref missing);
                    points.AddPoint(point8, ref missing, ref missing);
                    points          = this.method_4(polyline3, polygon);
                    inPoint         = points.get_Point(0);
                    point4          = points.get_Point(1);
                    point5          = points.get_Point(2);
                    point6          = points.get_Point(3);
                    element7        = new LineElementClass();
                    element9        = element7 as ILineElement;
                    element9.Symbol = symbol9;
                    points2         = polyline as IPointCollection;
                    if (points2.PointCount >= 1)
                    {
                        points2.RemovePoints(0, points2.PointCount);
                    }
                    points2.AddPoint(inPoint, ref missing, ref missing);
                    points2.AddPoint(point4, ref missing, ref missing);
                    element7.Geometry = polyline;
                    element8          = new LineElementClass();
                    element9          = element8 as ILineElement;
                    element9.Symbol   = symbol9;
                    points2           = polyline2 as IPointCollection;
                    if (points2.PointCount >= 1)
                    {
                        points2.RemovePoints(0, points2.PointCount);
                    }
                    points2.AddPoint(point5, ref missing, ref missing);
                    points2.AddPoint(point6, ref missing, ref missing);
                    element8.Geometry = polyline2;
                    this.ilist_0.Add(element7);
                    this.ilist_0.Add(element8);
                    element  = new TextElementClass();
                    element2 = new TextElementClass();
                    element3 = new TextElementClass();
                    element4 = new TextElementClass();
                    num6     = (int)Math.Truncate((double)(y / 100000.0));
                    str      = num6.ToString();
                    num7     = (int)Math.Truncate((double)((y - (num6 * 100000)) / 1000.0));
                    str2     = num7.ToString();
                    if (str2.Length < 2)
                    {
                        str2 = "0" + str2;
                    }
                    element.Text  = str2;
                    element2.Text = str;
                    element3.Text = str2;
                    element4.Text = str;
                    point         = new PointClass();
                    point.PutCoords(inPoint.X, inPoint.Y + num2);
                    item           = element as IElement;
                    item.Geometry  = point;
                    element.Symbol = symbol;
                    this.ilist_0.Add(item);
                    if ((num18 == 0) || (num18 == num16))
                    {
                        point = new PointClass();
                        point.PutCoords(point4.X, point4.Y + num);
                        item            = element2 as IElement;
                        item.Geometry   = point;
                        element2.Symbol = symbol2;
                        this.ilist_0.Add(item);
                    }
                    point = new PointClass();
                    point.PutCoords(point5.X, point5.Y + num2);
                    item            = element3 as IElement;
                    item.Geometry   = point;
                    element3.Symbol = symbol;
                    this.ilist_0.Add(item);
                    if ((num18 == 0) || (num18 == num16))
                    {
                        point = new PointClass();
                        point.PutCoords(point6.X, point6.Y + num);
                        item            = element4 as IElement;
                        item.Geometry   = point;
                        element4.Symbol = symbol2;
                        this.ilist_0.Add(item);
                    }
                }
                for (num18 = 0; num18 <= num17; num18++)
                {
                    x      = num11 + (num18 * num8);
                    point7 = new PointClass();
                    point8 = new PointClass();
                    point7.PutCoords(x, num23);
                    point8.PutCoords(x, num21);
                    points = polyline3 as IPointCollection;
                    if (points.PointCount >= 1)
                    {
                        points.RemovePoints(0, points.PointCount);
                    }
                    points.AddPoint(point7, ref missing, ref missing);
                    points.AddPoint(point8, ref missing, ref missing);
                    points          = this.method_4(polyline3, polygon);
                    inPoint         = points.get_Point(0);
                    point4          = points.get_Point(1);
                    point5          = points.get_Point(2);
                    point6          = points.get_Point(3);
                    element7        = new LineElementClass();
                    element9        = element7 as ILineElement;
                    element9.Symbol = symbol9;
                    points2         = polyline as IPointCollection;
                    if (points2.PointCount >= 1)
                    {
                        points2.RemovePoints(0, points2.PointCount);
                    }
                    points2.AddPoint(inPoint, ref missing, ref missing);
                    points2.AddPoint(point4, ref missing, ref missing);
                    element7.Geometry = polyline;
                    element8          = new LineElementClass();
                    element9          = element8 as ILineElement;
                    element9.Symbol   = symbol9;
                    points2           = polyline2 as IPointCollection;
                    if (points2.PointCount >= 1)
                    {
                        points2.RemovePoints(0, points2.PointCount);
                    }
                    points2.AddPoint(point5, ref missing, ref missing);
                    points2.AddPoint(point6, ref missing, ref missing);
                    element8.Geometry = polyline2;
                    this.ilist_0.Add(element7);
                    this.ilist_0.Add(element8);
                    element  = new TextElementClass();
                    element2 = new TextElementClass();
                    element3 = new TextElementClass();
                    element4 = new TextElementClass();
                    num6     = (int)Math.Truncate((double)(x / 100000.0));
                    str      = num6.ToString();
                    str2     = ((int)Math.Truncate((double)((x - (num6 * 100000)) / 1000.0))).ToString();
                    if (str2.Length < 2)
                    {
                        str2 = "0" + str2;
                    }
                    element.Text  = str2;
                    element2.Text = str;
                    element3.Text = str2;
                    element4.Text = str;
                    point         = new PointClass();
                    point.PutCoords(inPoint.X, inPoint.Y - num3);
                    item           = element as IElement;
                    item.Geometry  = point;
                    element.Symbol = symbol4;
                    this.ilist_0.Add(item);
                    if ((num18 == 0) || (num18 == num17))
                    {
                        point = new PointClass();
                        point.PutCoords(inPoint.X, inPoint.Y - num3);
                        item            = element2 as IElement;
                        item.Geometry   = point;
                        element2.Symbol = symbol3;
                        this.ilist_0.Add(item);
                    }
                    point = new PointClass();
                    point.PutCoords(point6.X, point6.Y + num3);
                    item            = element3 as IElement;
                    item.Geometry   = point;
                    element3.Symbol = symbol6;
                    this.ilist_0.Add(item);
                    if ((num18 == 0) || (num18 == num17))
                    {
                        point = new PointClass();
                        point.PutCoords(point6.X, point6.Y + num3);
                        item            = element4 as IElement;
                        item.Geometry   = point;
                        element4.Symbol = symbol5;
                        this.ilist_0.Add(item);
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
コード例 #22
0
        public void AddGraphic(IScene iscene_0, IGeometry igeometry_0, ISymbol isymbol_0, bool bool_1, bool bool_2, string string_0)
        {
            if (!igeometry_0.IsEmpty)
            {
                IGraphicsLayer   basicGraphicsLayer = iscene_0.BasicGraphicsLayer;
                IElement         element            = null;
                esriGeometryType geometryType       = igeometry_0.GeometryType;
                switch (geometryType)
                {
                case esriGeometryType.esriGeometryPoint:
                {
                    element = new MarkerElement();
                    IMarkerElement markerElement = element as IMarkerElement;
                    if (isymbol_0 != null)
                    {
                        markerElement.Symbol = (isymbol_0 as IMarkerSymbol);
                    }
                    else
                    {
                        markerElement.Symbol = new SimpleMarkerSymbol();
                    }
                    break;
                }

                case esriGeometryType.esriGeometryMultipoint:
                    break;

                case esriGeometryType.esriGeometryPolyline:
                {
                    element = new LineElement();
                    ILineElement lineElement = element as ILineElement;
                    if (isymbol_0 != null)
                    {
                        lineElement.Symbol = (isymbol_0 as ILineSymbol);
                    }
                    else
                    {
                        lineElement.Symbol = new SimpleLineSymbol();
                    }
                    break;
                }

                case esriGeometryType.esriGeometryPolygon:
                {
                    element = new PolygonElement();
                    IFillShapeElement fillShapeElement = element as IFillShapeElement;
                    if (isymbol_0 != null)
                    {
                        fillShapeElement.Symbol = (isymbol_0 as IFillSymbol);
                    }
                    else
                    {
                        fillShapeElement.Symbol = new SimpleFillSymbol();
                    }
                    break;
                }

                default:
                    if (geometryType == esriGeometryType.esriGeometryMultiPatch)
                    {
                        element = new MultiPatchElement();
                        IFillShapeElement fillShapeElement = element as IFillShapeElement;
                        if (isymbol_0 != null)
                        {
                            fillShapeElement.Symbol = (isymbol_0 as IFillSymbol);
                        }
                        else
                        {
                            fillShapeElement.Symbol = new SimpleFillSymbol();
                        }
                    }
                    break;
                }
                if (element != null)
                {
                    element.Geometry = igeometry_0;
                    if (string_0.Length > 0)
                    {
                        IElementProperties elementProperties = element as IElementProperties;
                        elementProperties.Name = string_0;
                    }
                    IGraphicsContainer3D graphicsContainer3D = basicGraphicsLayer as IGraphicsContainer3D;
                    graphicsContainer3D.AddElement(element);
                    IGraphicsSelection graphicsSelection = graphicsContainer3D as IGraphicsSelection;
                    if (bool_2)
                    {
                        if (!bool_1)
                        {
                            graphicsSelection.UnselectAllElements();
                        }
                        graphicsSelection.SelectElement(element);
                    }
                    iscene_0.SceneGraph.RefreshViewers();
                }
            }
        }
コード例 #23
0
        private void DrawPointsOnActiveView(int colindex, int rowindex, IRasterProps pRasterProps, IActiveView ActiveView)
        {
            IGraphicsContainer pGraphicContainer = ActiveView.GraphicsContainer;

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

            //ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
            //pSimpleLineSymbol.Width = 2;
            //pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            //pSimpleLineSymbol.Color = pRgbColor;

            ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();

            pSimpleMarkerSymbol.Size  = 8;
            pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            pSimpleMarkerSymbol.Color = pRgbColor;

            double dblX = 0, dblY = 0;
            double dblCellSize = Convert.ToDouble(pRasterProps.MeanCellSize().X);

            dblX = pRasterProps.Extent.XMin + (dblCellSize / 2) + dblCellSize * colindex;
            dblY = pRasterProps.Extent.YMax - (dblCellSize / 2) - dblCellSize * rowindex;

            IPoint pPoint = new PointClass();

            pPoint.X = dblX;
            pPoint.Y = dblY;

            IElement pElement = new MarkerElementClass();

            IMarkerElement pMarkerElement = (IMarkerElement)pElement;

            pMarkerElement.Symbol = pSimpleMarkerSymbol;
            pElement.Geometry     = pPoint;

            pGraphicContainer.AddElement(pElement, 0);

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

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

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

            //    IElement pElement = new LineElementClass();

            //    ILineElement pLineElement = (ILineElement)pElement;
            //    pLineElement.Symbol = pSimpleLineSymbol;
            //    pElement.Geometry = polyline;

            //    pGraphicContainer.AddElement(pElement, 0);
            //}

            //pActiveView.Refresh();
        }
コード例 #24
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdNorthArrowAttribute.OnClick implementation

            IGraphicsContainer       GraphicsContainer       = m_hookHelper.ActiveView.GraphicsContainer;
            IGraphicsContainerSelect GraphicsContainerSelect = GraphicsContainer as IGraphicsContainerSelect;
            int SelectElementCount = GraphicsContainerSelect.ElementSelectionCount;

            IEnumElement pEnumElement = GraphicsContainerSelect.SelectedElements;
            ////判断选择要素的类型是否在两种以上
            IElement           pElement           = pEnumElement.Next();
            IElementProperties pElementProperties = pElement as IElementProperties;
            //第一个要素属性类型
            string pSelElementType = pElementProperties.Type;

            for (int i = 0; i < SelectElementCount; i++)
            {
                if (pSelElementType != pElementProperties.Type)
                {
                    MessageBox.Show("请选择同一种类型的要素!");
                    return;
                }
                pElement           = pEnumElement.Next();
                pElementProperties = pElement as IElementProperties;
            }

            //当选择要素类型相同时,开始进行修改样式
            IEnumElement EnumElement = GraphicsContainerSelect.SelectedElements;

            EnumElement.Reset();
            IElement           Element           = EnumElement.Next();
            IElementProperties ElementProperties = Element as IElementProperties;

            //当选择的要素为指北针、比例尺、图例、DataFrame时,必须选择一个
            if (ElementProperties.Type == "地图整饰要素框架" || ElementProperties.Type == "Map Surround Frame" || ElementProperties.Type == "Data Frame")
            {
                if (SelectElementCount == 1)
                {
                    if (ElementProperties.Name == "North Arrow")
                    {
                        LibCerMap.FrmNorthArrwoAttribute frm = new LibCerMap.FrmNorthArrwoAttribute(SymbolStyle, Element, GraphicsContainer, m_hookHelper);
                        frm.ShowDialog();
                    }
                    else if (ElementProperties.Name == "Scale Line" || ElementProperties.Name == "比例尺" || ElementProperties.Name.Contains("Scale Bar"))
                    {
                        LibCerMap.FrmScaleBarAttribute frm = new LibCerMap.FrmScaleBarAttribute(SymbolStyle, Element, GraphicsContainer, m_hookHelper);
                        frm.ShowDialog();
                    }
                    else if (ElementProperties.Name == "Scale Text")
                    {
                        LibCerMap.FrmScaleTextAttribute frm = new LibCerMap.FrmScaleTextAttribute(SymbolStyle, Element, GraphicsContainer, m_hookHelper);
                        frm.ShowDialog();
                    }
                    else if (ElementProperties.Name == "Legend" || ElementProperties.Name == "图例")
                    {
                        LibCerMap.FrmLegendAttribute frm = new LibCerMap.FrmLegendAttribute(SymbolStyle, Element, GraphicsContainer, m_hookHelper);
                        frm.ShowDialog();
                    }
                    else if (ElementProperties.Type == "Data Frame")
                    {
                        int SelIndex = 0;
                        LibCerMap.FrmFrameAttrSel frmsel = new LibCerMap.FrmFrameAttrSel();
                        frmsel.ShowDialog();
                        if (frmsel.DialogResult == DialogResult.OK)
                        {
                            SelIndex = frmsel.FrmIndex;
                        }
                        if (SelIndex == 1)
                        {
                            LibCerMap.FrmNavigationGrids frm = new LibCerMap.FrmNavigationGrids(SymbolStyle, m_hookHelper);
                            frm.ShowDialog();
                        }
                        else if (SelIndex == 2)
                        {
                            LibCerMap.FrmFrameAttribute frm = new LibCerMap.FrmFrameAttribute(SymbolStyle, Element, GraphicsContainer, m_hookHelper);
                            frm.ShowDialog();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("当选择要素为指北针、比例尺、图例、Frame窗体时,只可以选择一个要素");
                }
            }
            else if (ElementProperties.Type == "Text" || ElementProperties.Type == "文本")
            {
                LibCerMap.FrmAddText frm = new LibCerMap.FrmAddText(Element as ITextElement, m_hookHelper);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    //ITextSymbol pTextSymbol = frm.pTextElement.Symbol;
                    //for (int i = 0; i < SelectElementCount; i++)
                    //{
                    //    ITextElement pTextElement = Element as ITextElement;
                    //    //pTextElement.Symbol = pTextSymbol;
                    //    Element = EnumElement.Next();
                    //}
                    m_hookHelper.ActiveView.Refresh();
                }
            }

            else if (ElementProperties.Type == "Marker" || ElementProperties.Type == "标记")
            {
                IMarkerElement      pMarkerElement = Element as IMarkerElement;
                LibCerMap.FrmSymbol FrmMarker      = new LibCerMap.FrmSymbol(SymbolStyle, (ISymbol)pMarkerElement.Symbol, esriSymbologyStyleClass.esriStyleClassMarkerSymbols);
                FrmMarker.ShowDialog();
                if (FrmMarker.DialogResult == DialogResult.OK)
                {
                    IMarkerSymbol pMarkerSymbol = FrmMarker.GetStyleGalleryItem().Item as IMarkerSymbol;
                    for (int i = 0; i < SelectElementCount; i++)
                    {
                        pMarkerElement.Symbol = pMarkerSymbol;
                        Element        = EnumElement.Next();
                        pMarkerElement = Element as IMarkerElement;
                    }
                }
            }
            else if (ElementProperties.Type == "Line" || ElementProperties.Type == "线")
            {
                ILineElement        pLineElement = Element as ILineElement;
                LibCerMap.FrmSymbol frm          = new LibCerMap.FrmSymbol(SymbolStyle, (ISymbol)pLineElement.Symbol, esriSymbologyStyleClass.esriStyleClassLineSymbols);
                frm.ShowDialog();
                if (frm.DialogResult == DialogResult.OK)
                {
                    ILineSymbol pLineSymbol = frm.GetStyleGalleryItem().Item as ILineSymbol;
                    for (int i = 0; i < SelectElementCount; i++)
                    {
                        pLineElement.Symbol = pLineSymbol;
                        Element             = EnumElement.Next();
                        pLineElement        = Element as ILineElement;
                    }
                }
            }

            else if (ElementProperties.Type == "Polygon" || ElementProperties.Type == "Rectangle" ||
                     ElementProperties.Type == "Circle" || ElementProperties.Type == "Ellipse" ||
                     ElementProperties.Type == "面" || ElementProperties.Type == "矩形" ||
                     ElementProperties.Type == "圆形" || ElementProperties.Type == "椭圆")
            {
                IFillShapeElement   pFillShapeElement = Element as IFillShapeElement;
                LibCerMap.FrmSymbol frm = new LibCerMap.FrmSymbol(SymbolStyle, (ISymbol)pFillShapeElement.Symbol, esriSymbologyStyleClass.esriStyleClassFillSymbols);
                frm.ShowDialog();
                if (frm.DialogResult == DialogResult.OK)
                {
                    IFillSymbol pFillsymbol = frm.GetStyleGalleryItem().Item as IFillSymbol;

                    for (int i = 0; i < SelectElementCount; i++)
                    {
                        pFillShapeElement.Symbol = pFillsymbol;
                        Element           = EnumElement.Next();
                        pFillShapeElement = Element as IFillShapeElement;
                    }
                }
            }

            m_hookHelper.ActiveView.Refresh();
        }
コード例 #25
0
 public void SetObjects(object object_0)
 {
     this.imarkerElement_0 = object_0 as IMarkerElement;
 }
コード例 #26
0
ファイル: modFacades.cs プロジェクト: secondii/Yutai
        public static IElement AddGraphic(IGeometry igeometry_0, ISymbol isymbol_0, string string_0, IGraphicsContainer3D igraphicsContainer3D_0)
        {
            IElement element = null;
            IElement result;

            try
            {
                if (igeometry_0.IsEmpty)
                {
                    result = element;
                    return(result);
                }
                if (modFacades.g_pGCon == null)
                {
                    result = element;
                    return(result);
                }
                IElement         element2     = null;
                esriGeometryType geometryType = igeometry_0.GeometryType;
                switch (geometryType)
                {
                case esriGeometryType.esriGeometryPoint:
                    element2 = new MarkerElement();
                    if (isymbol_0 != null)
                    {
                        IMarkerElement markerElement = element2 as IMarkerElement;
                        markerElement.Symbol = (isymbol_0 as IMarkerSymbol);
                    }
                    break;

                case esriGeometryType.esriGeometryMultipoint:
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    element2 = new LineElement();
                    if (isymbol_0 != null)
                    {
                        ILineElement lineElement = element2 as ILineElement;
                        lineElement.Symbol = (isymbol_0 as ILineSymbol);
                    }
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    element2 = new PolygonElement();
                    if (isymbol_0 != null)
                    {
                        IFillShapeElement fillShapeElement = element2 as IFillShapeElement;
                        fillShapeElement.Symbol = (isymbol_0 as IFillSymbol);
                    }
                    break;

                default:
                    if (geometryType == esriGeometryType.esriGeometryMultiPatch)
                    {
                        element2 = new MultiPatchElement();
                        if (isymbol_0 != null)
                        {
                            IFillShapeElement fillShapeElement = element2 as IFillShapeElement;
                            fillShapeElement.Symbol = (isymbol_0 as IFillSymbol);
                        }
                    }
                    break;
                }
                if (string_0.Length > 0)
                {
                    IElementProperties elementProperties = element2 as IElementProperties;
                    elementProperties.Name = string_0;
                }
                element2.Geometry = igeometry_0;
                if (igraphicsContainer3D_0 != null)
                {
                    igraphicsContainer3D_0.AddElement(element2);
                }
                element = element2;
                result  = element;
                return(result);
            }
            catch
            {
            }
            result = element;
            return(result);
        }
コード例 #27
0
        /// <summary>
        /// 绘制对象 张琪  20110628
        /// </summary>
        /// <param name="pGeometry">对象</param>
        /// <param name="pColor">颜色</param>
        /// <param name="lSize">绘制的大小</param>
        /// <param name="sName">名称</param>
        /// <param name="pScene"></param>
        /// <param name="pGroup"></param>
        public static void AddSimpleGraphic(IGeometry pGeometry, IRgbColor pColor, int lSize, string sName, IMap pMap, IGroupElement pGroup)
        {
            if (pGeometry == null)
            {
                return;
            }
            IElement pElement = null;

            //ISymbol pSym;
            //根据绘制的对象类型对IElement进行不同的定义
            switch (pGeometry.GeometryType.ToString())
            {
            case "esriGeometryPoint":
                pElement = new MarkerElementClass();
                IMarkerElement      pPointElement = pElement as IMarkerElement;
                ISimpleMarkerSymbol pMSym         = new SimpleMarkerSymbolClass();
                pMSym.Color = pColor;
                pMSym.Size  = lSize;
                pMSym.Style = esriSimpleMarkerStyle.esriSMSCircle;
                IMarkerSymbol pMarkerSymbol = pMSym as IMarkerSymbol;
                pPointElement.Symbol = pMarkerSymbol;
                break;

            case "esriGeometryPolyline":
                pElement = new LineElementClass();
                ILineElement      pLineElement = pElement as ILineElement;
                ISimpleLineSymbol pLSym        = new SimpleLineSymbolClass();
                pLSym.Width = lSize;
                pLSym.Style = esriSimpleLineStyle.esriSLSSolid;
                pLSym.Color = pColor;
                ILineSymbol pLineSymbol = pLSym as ILineSymbol;
                pLineElement.Symbol = pLineSymbol;
                break;

            case "esriGeometryPolygon":
                ISimpleLineSymbol pOutlineSym = new SimpleLineSymbolClass();
                pOutlineSym.Color = pColor;
                pOutlineSym.Width = lSize;
                pOutlineSym.Style = esriSimpleLineStyle.esriSLSSolid;
                if (sName == "_ReferancePlane_")
                {
                    pColor.Transparency = Convert.ToByte(Convert.ToInt32(255 / 2));
                }
                pElement = new PolygonElementClass();
                IFillShapeElement pPolygonElement = pElement as IFillShapeElement;
                IFillSymbol       pFSym           = new SimpleFillSymbolClass();
                pFSym.Color = pColor;
                ILineSymbol pLineSymbol1 = pOutlineSym as ILineSymbol;
                pFSym.Outline          = pLineSymbol1;
                pPolygonElement.Symbol = pFSym;
                break;

            default:
                break;
            }
            pElement.Geometry = pGeometry;
            IElementProperties pElemProps = pElement as IElementProperties;

            pElemProps.Name = sName;
            if (pGroup == null)
            {
                IGraphicsContainer pGCon = pMap.BasicGraphicsLayer as IGraphicsContainer;
                pGCon.AddElement(pElement, 0);
            }
            else
            {
                pGroup.AddElement(pElement);
            }
        }
コード例 #28
0
        /// <summary>
        /// 添加图元
        /// </summary>
        /// <param name="pGeometry"></param>
        /// <param name="pActiveView"></param>
        /// <param name="pSymbol"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public IElement AddElement(IGeometry pGeometry, ISymbol pSymbol, string key)
        {
            try
            {
                IActiveView        pActiveView        = mapControl.ActiveView;
                IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer;
                IElement           pElement           = null;
                ILineElement       pLineElement       = null;
                IFillShapeElement  pFillShapeElement  = null;
                IMarkerElement     pMarkerElement     = null;
                ICircleElement     pCircleElement     = null;
                IElementProperties pElmentProperties  = null;
                switch (pGeometry.GeometryType)
                {
                case esriGeometryType.esriGeometryEnvelope:
                {
                    pElement                 = new RectangleElement();
                    pElement.Geometry        = pGeometry;
                    pFillShapeElement        = (IFillShapeElement)pElement;
                    pFillShapeElement.Symbol = (IFillSymbol)pSymbol;
                    break;
                }

                case esriGeometryType.esriGeometryPolyline:
                {
                    pElement            = new LineElement();
                    pElement.Geometry   = pGeometry;
                    pLineElement        = (ILineElement)pElement;
                    pLineElement.Symbol = (ILineSymbol)pSymbol;
                    break;
                }

                case esriGeometryType.esriGeometryLine:
                {
                    pElement          = new LineElement();
                    pElement.Geometry = pGeometry;

                    pLineElement        = (ILineElement)pElement;
                    pLineElement.Symbol = (ILineSymbol)pSymbol;
                    break;
                }

                case esriGeometryType.esriGeometryPolygon:
                {
                    pElement          = new PolygonElement();
                    pElement.Geometry = pGeometry;
                    pFillShapeElement = (IFillShapeElement)pElement;

                    pFillShapeElement.Symbol = (IFillSymbol)pSymbol;
                    break;
                }

                case esriGeometryType.esriGeometryMultipoint:
                case esriGeometryType.esriGeometryPoint:
                {
                    pElement          = new MarkerElement();
                    pElement.Geometry = pGeometry;

                    pMarkerElement = (IMarkerElement)pElement;

                    pMarkerElement.Symbol = (IMarkerSymbol)pSymbol;
                    break;
                }

                case esriGeometryType.esriGeometryCircularArc:
                {
                    pElement          = new CircleElement();
                    pElement.Geometry = pGeometry;

                    pCircleElement = (ICircleElement)pElement;
                    break;
                }

                default:
                    pElement = null;
                    break;
                }

                if (pElement != null)
                {
                    pElmentProperties      = pElement as IElementProperties;
                    pElmentProperties.Name = key;
                    pGraphicsContainer.AddElement(pElement, 0);
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, pGeometry.Envelope);
                    return(pElement);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
コード例 #29
0
ファイル: ElementFun.cs プロジェクト: 605258778/GISData
        public IElement CreateBaseElementByGeometry(IGeometry pGeometry, ISymbol pSymbol)
        {
            IElement element7;

            try
            {
                IElement element;
                if (pGeometry != null)
                {
                    if (pGeometry.IsEmpty)
                    {
                        return(null);
                    }
                    IGeometry geometry = null;
                    geometry = GISFunFactory.SystemFun.CloneObejct(pGeometry as IClone) as IGeometry;
                    element  = null;
                    switch (geometry.GeometryType)
                    {
                    case esriGeometryType.esriGeometryPoint:
                        element = new MarkerElementClass {
                            Geometry = geometry
                        };
                        if ((pSymbol != null) && (pSymbol is IMarkerSymbol))
                        {
                            IMarkerElement element2 = element as IMarkerElement;
                            element2.Symbol = pSymbol as IMarkerSymbol;
                        }
                        goto Label_0166;

                    case esriGeometryType.esriGeometryPolyline:
                        element = new LineElementClass {
                            Geometry = geometry
                        };
                        if ((pSymbol != null) && (pSymbol is ILineSymbol))
                        {
                            ILineElement element4 = element as ILineElement;
                            element4.Symbol = pSymbol as ILineSymbol;
                        }
                        goto Label_0166;

                    case esriGeometryType.esriGeometryPolygon:
                        element = new PolygonElementClass {
                            Geometry = geometry
                        };
                        if ((pSymbol != null) && (pSymbol is IFillSymbol))
                        {
                            IFillShapeElement element5 = element as IFillShapeElement;
                            element5.Symbol = pSymbol as IFillSymbol;
                        }
                        goto Label_0166;

                    case esriGeometryType.esriGeometryEnvelope:
                        element = new RectangleElementClass {
                            Geometry = geometry
                        };
                        if ((pSymbol != null) && (pSymbol is IFillSymbol))
                        {
                            IFillShapeElement element6 = element as IFillShapeElement;
                            element6.Symbol = pSymbol as IFillSymbol;
                        }
                        goto Label_0166;

                    case esriGeometryType.esriGeometryLine:
                        element = new LineElementClass {
                            Geometry = geometry
                        };
                        if ((pSymbol != null) && (pSymbol is ILineSymbol))
                        {
                            ILineElement element3 = element as ILineElement;
                            element3.Symbol = pSymbol as ILineSymbol;
                        }
                        goto Label_0166;
                    }
                }
                return(null);

Label_0166:
                element7 = element;
            }
            catch (Exception exception)
            {
                this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ElementFun", "CreateBaseElementByGeometry", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
                element7 = null;
            }
            return(element7);
        }
コード例 #30
0
ファイル: FlyByUtils.cs プロジェクト: secondii/Yutai
        public static void AddFlyByGraphic(ISceneGraph isceneGraph_0, IGeometry igeometry_0, FlyByUtils.FlyByElementType flyByElementType_0, System.Drawing.Color color_0, System.Drawing.Color color_1, System.Drawing.Color color_2, System.Drawing.Color color_3, bool bool_0)
        {
            if (!igeometry_0.IsEmpty)
            {
                IGraphicsContainer3D graphicsContainer3D = isceneGraph_0.Scene.BasicGraphicsLayer as IGraphicsContainer3D;
                if (!FlyByUtils.LayerIsExist(isceneGraph_0.Scene, graphicsContainer3D as ILayer))
                {
                    isceneGraph_0.Scene.AddLayer(graphicsContainer3D as ILayer, true);
                }
                switch (flyByElementType_0)
                {
                case FlyByUtils.FlyByElementType.FLYBY_PATH:
                    if (FlyByUtils.pPathElem != null)
                    {
                        graphicsContainer3D.DeleteElement(FlyByUtils.pPathElem);
                    }
                    break;

                case FlyByUtils.FlyByElementType.FLYBY_OBSERVER:
                    if (FlyByUtils.pObserverElem != null)
                    {
                        graphicsContainer3D.DeleteElement(FlyByUtils.pObserverElem);
                    }
                    break;

                case FlyByUtils.FlyByElementType.FLYBY_TARGET:
                    if (FlyByUtils.pTargetElem != null)
                    {
                        graphicsContainer3D.DeleteElement(FlyByUtils.pTargetElem);
                    }
                    break;
                }
                ISymbol  flyBySymbol = FlyByUtils.GetFlyBySymbol(color_0, color_1, color_2, color_3, flyByElementType_0);
                IElement element;
                switch (igeometry_0.GeometryType)
                {
                case esriGeometryType.esriGeometryPoint:
                {
                    element = new MarkerElement();
                    IMarkerElement markerElement = element as IMarkerElement;
                    markerElement.Symbol = (flyBySymbol as IMarkerSymbol);
                    break;
                }

                case esriGeometryType.esriGeometryMultipoint:
                    return;

                case esriGeometryType.esriGeometryPolyline:
                {
                    element = new LineElement();
                    ILineElement lineElement = element as ILineElement;
                    lineElement.Symbol = (flyBySymbol as ILineSymbol);
                    break;
                }

                default:
                    return;
                }
                switch (flyByElementType_0)
                {
                case FlyByUtils.FlyByElementType.FLYBY_ANCHORS:
                {
                    IElementProperties elementProperties = element as IElementProperties;
                    elementProperties.Name = "SceneFlyBy.AnchorPoint";
                    break;
                }

                case FlyByUtils.FlyByElementType.FLYBY_PATH:
                    FlyByUtils.pPathElem = element;
                    break;

                case FlyByUtils.FlyByElementType.FLYBY_OBSERVER:
                    FlyByUtils.pObserverElem = element;
                    break;

                case FlyByUtils.FlyByElementType.FLYBY_TARGET:
                    FlyByUtils.pTargetElem = element;
                    break;

                case FlyByUtils.FlyByElementType.FLYBY_STATIC:
                {
                    IElementProperties elementProperties = element as IElementProperties;
                    elementProperties.Name = "SceneFlyBy.StaticLoc";
                    break;
                }
                }
                element.Geometry = igeometry_0;
                graphicsContainer3D.AddElement(element);
                if (bool_0)
                {
                    isceneGraph_0.RefreshViewers();
                }
            }
        }