Esempio n. 1
0
        public IGeometry DrawPolyline(ESRI.ArcGIS.Carto.IActiveView activeView)
        {
            if (activeView == null)
            {
                return(null);
            }
            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;

            // Constant
            screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
            ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColor();
            rgbColor.Red = 255;

            ESRI.ArcGIS.Display.IColor            color            = rgbColor; // Implicit Cast
            ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol();
            simpleLineSymbol.Color = color;
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDot;

            ESRI.ArcGIS.Display.ISymbol     symbol     = (ESRI.ArcGIS.Display.ISymbol)simpleLineSymbol; // Explicit Cast
            ESRI.ArcGIS.Display.IRubberBand rubberBand = new RubberLine();
            ESRI.ArcGIS.Geometry.IGeometry  geometry   = rubberBand.TrackNew(screenDisplay, symbol);
            screenDisplay.SetSymbol(symbol);
            screenDisplay.DrawPolyline(geometry);
            screenDisplay.FinishDrawing();
            return(geometry);
        }
Esempio n. 2
0
        private void line绘制线ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // 创建图形
            IPolyline   pPolyline   = new Polyline() as IPolyline;
            IRubberBand pRubberBand = new RubberLine();

            pPolyline = pRubberBand.TrackNew(axMapControl1.ActiveView.ScreenDisplay, null) as IPolyline;
            // 创建符号
            ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbol();

            pSimpleLineSymbol.Width = 2;
            pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            // pSimpleLineSymbol.Color = GetRGBColor(44, 44, 44);

            // 创建Element并赋值图形和符号
            ILineElement pLineElement = new LineElement() as ILineElement;
            IElement     pElement     = pLineElement as IElement;

            pElement.Geometry   = pPolyline;
            pLineElement.Symbol = pSimpleLineSymbol;
            // 添加到IGraphicsContainer容器
            IGraphicsContainer pGraphicsContainer = axMapControl1.Map as IGraphicsContainer;

            pGraphicsContainer.AddElement(pLineElement as IElement, 0);
            axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 3
0
        protected override void OnMouseDown(MouseEventArgs arg)
        {
            IMxDocument pmxdoc    = ArcMap.Application.Document as IMxDocument;
            IRubberBand pRubber   = new RubberLine();
            IPolyline   pPolyline = pRubber.TrackNew(pmxdoc.ActiveView.ScreenDisplay, null) as IPolyline;

            IElement     pElement     = new LineElement();
            ILineElement pLineElement = pElement as ILineElement;

            pLineElement.Symbol = new SimpleLineSymbol();
            pElement.Geometry   = pPolyline;

            IElementProperties pElementProp = pElement as IElementProperties;

            pElementProp.Name = "Hussein Element " + ++i;

            IGraphicsContainer pgc = pmxdoc.ActiveView.GraphicsContainer;

            pgc.AddElement(pElement, 0);
            pmxdoc.ActiveView.Refresh();
        }