/// <summary>
        /// Creates a new instance of GeoHandledDrawArgs
        /// </summary>
        public GeoDrawCompletedArgs(MapDrawArgs args, Exception inException)
            : base(args.Graphics, args.ClipRectangle, args.GeoGraphics)
        {
         
            _exception = inException;

        }
示例#2
0
        protected override void OnDraw(MapDrawArgs e)
        {
            if (SnapMode != SnapMode.None && SnapInfo != null)
            {
                int       left, top, width, height;
                Rectangle rectangle;
                switch (SnapInfo.SnapMode)
                {
                case SnapMode.Point:
                case SnapMode.End:
                case SnapMode.Vertex:
                    left      = _mousePosition.X - SnapTol;
                    top       = _mousePosition.Y - SnapTol;
                    width     = SnapTol * 2;
                    height    = width;
                    rectangle = new Rectangle(left, top, width, height);
                    e.Graphics.DrawRectangle(SnapPen, rectangle);
                    e.Graphics.DrawLine(SnapPen, rectangle.Left, _mousePosition.Y, rectangle.Right, _mousePosition.Y);
                    e.Graphics.DrawLine(SnapPen, _mousePosition.X, rectangle.Top, _mousePosition.X, rectangle.Bottom);
                    break;

                case SnapMode.Edege:
                    left      = _mousePosition.X - 4;
                    top       = _mousePosition.Y - 4;
                    width     = 4 * 2;
                    height    = width;
                    rectangle = new Rectangle(left, top, width, height);
                    e.Graphics.DrawRectangle(SnapPen, rectangle);
                    break;
                }
            }
            base.OnDraw(e);
        }
示例#3
0
        protected override void OnDraw(MapDrawArgs e)
        {
            if (_isEnabled)
            {
                List <System.Drawing.Point> temPoints = _points;
                GraphicsPath gp = new GraphicsPath();
                if (_points.Count > 0)
                {
                    gp.AddLines(_points.ToArray());
                    gp.AddLine(_points[(_points.Count - 1)], _currentPoint);
                    gp.AddLine(_points[0], _currentPoint);
                }

                Pen pen = new Pen(Color.LawnGreen);
                pen.DashStyle = DashStyle.Dash;
                pen.Width     = 2;

                e.Graphics.DrawPath(pen, gp);

                //SolidBrush brush = new SolidBrush(Color.FromArgb(50, Color.Gold));

                HatchBrush hatchBruch = new HatchBrush(HatchStyle.Percent90, Color.BlueViolet, Color.Pink);
                temPoints.Add(_currentPoint);
                e.Graphics.FillPolygon(hatchBruch, _points.ToArray(), FillMode.Winding);
                temPoints.RemoveAt((temPoints.Count - 1));
            }

            base.OnDraw(e);
        }
        /// <summary>
        /// Creates a new instance of GeoHandledDrawArgs
        /// </summary>
        public GeoDrawCompletedArgs(MapDrawArgs args, bool inCancelled)
            : base(args.Graphics, args.ClipRectangle, args.GeoGraphics)
        {
            _cancelled = inCancelled;
          

        }
示例#5
0
 //Draws the rubber band line while the left mouse button is still down
 protected override void OnDraw(MapDrawArgs e)
 {
     if (currentlyDrawing)
     {
         e.Graphics.DrawLine(redPen, latestPoint, currentPoint);
     }
     base.OnDraw(e);
 }
示例#6
0
        /// <inheritdoc />
        protected override void OnDraw(MapDrawArgs e)
        {
            Rectangle mouseRect = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6);

            if (_selectedFeature != null)
            {
                foreach (Coordinate c in _selectedFeature.Geometry.Coordinates)
                {
                    Point pt = e.GeoGraphics.ProjToPixel(c);
                    if (e.GeoGraphics.ImageRectangle.Contains(pt))
                    {
                        e.Graphics.FillRectangle(Brushes.Blue, pt.X - 2, pt.Y - 2, 4, 4);
                    }

                    if (mouseRect.Contains(pt))
                    {
                        e.Graphics.FillRectangle(Brushes.Red, mouseRect);
                    }
                }
            }

            if (_dragging)
            {
                if (_featureSet.FeatureType == FeatureType.Point || _featureSet.FeatureType == FeatureType.MultiPoint)
                {
                    Rectangle r = new Rectangle(_mousePosition.X - (_imageRect.Width / 2), _mousePosition.Y - (_imageRect.Height / 2), _imageRect.Width, _imageRect.Height);
                    _selectedCategory.Symbolizer.Draw(e.Graphics, r);
                }
                else
                {
                    e.Graphics.FillRectangle(Brushes.Red, _mousePosition.X - 3, _mousePosition.Y - 3, 6, 6);
                    Point b = _mousePosition;
                    Pen   p = new Pen(Color.Blue)
                    {
                        DashStyle = DashStyle.Dash
                    };
                    if (_previousPoint != null)
                    {
                        Point a = e.GeoGraphics.ProjToPixel(_previousPoint);
                        e.Graphics.DrawLine(p, a, b);
                    }

                    if (_nextPoint != null)
                    {
                        Point c = e.GeoGraphics.ProjToPixel(_nextPoint);
                        e.Graphics.DrawLine(p, b, c);
                    }

                    p.Dispose();
                }
            }
        }
示例#7
0
        protected override void OnDraw(MapDrawArgs e)
        {
            if (isDragging)
            {
                Rectangle rectangle = Opp.RectangleFromPoints(startPoint, currentPoint);
                rectangle.Width  -= 1;
                rectangle.Height -= 1;
                e.Graphics.DrawRectangle(Pens.White, rectangle);
                e.Graphics.DrawRectangle(selectionPen, rectangle);
            }

            base.OnDraw(e);
        }
示例#8
0
        //public bool PolygonCanIn
        //{
        //    get;
        //    set;
        //}

        #endregion

        #region Properties

        //public IGeometry Geometry
        //{
        //    get
        //    {
        //        LinearRing linearRing = new LinearRing(_coordinatePoints.ToArray());
        //        Polygon polygon = new Polygon(linearRing);
        //        return polygon as IGeometry;
        //    }
        //}

        #endregion

        #region Method

        protected override void OnDraw(MapDrawArgs e)
        {
            if (_isEnabled)
            {
                Rectangle r = Opp.RectangleFromPoints(_startPoint, _currentPoint);
                r.Width  -= 1;
                r.Height -= 1;

                HatchBrush brush = new HatchBrush(HatchStyle.Percent25, Color.Tomato, Color.SeaGreen);
                Pen        pen   = new Pen(brush, 2);
                pen.DashStyle = DashStyle.Dot;
                e.Graphics.DrawRectangle(pen, r);
                e.Graphics.FillRectangle(brush, r);
            }
            base.OnDraw(e);
        }
示例#9
0
        //public FeatureSet LineFeatureSet
        //{
        //    get
        //    {
        //        return _featureSet;
        //    }
        //}

        //public bool LineCanIn
        //{
        //    get;
        //    set;
        //}

        #endregion

        #region Method

        protected override void OnDraw(MapDrawArgs e)
        {
            if (_isEnabled)
            {
                GraphicsPath gp = new GraphicsPath();
                if (_points.Count >= 1)
                {
                    gp.AddLines(_points.ToArray());
                    gp.AddLine(_points[(_points.Count - 1)], _currentPoint);
                }

                Pen pen = new Pen(Color.CadetBlue);
                pen.Width    = 2;
                pen.StartCap = LineCap.Round;
                pen.EndCap   = LineCap.Round;
                e.Graphics.DrawPath(pen, gp);
            }

            base.OnDraw(e);
        }
示例#10
0
        /// <summary>
        /// 편집 기능 그리기를 처리합니다.
        /// </summary>
        /// <param name="e">The drawing args for the draw method.</param>
        protected override void OnDraw(MapDrawArgs e)
        {
            if (_standBy)
            {
                return;
            }

            // 스냅 시작
            DoSnapDrawing(e.Graphics, _mousePosition);

            // 도형요소가 점인 경우 스냅 종료
            if (_featureSet.FeatureType == FeatureType.Point)
            {
                return;
            }

            // 현재까지 완성 된 도형을 그려 활성 도면 내용 뒤에 그린디.
            if (_parts != null)
            {
                GraphicsPath gp = new GraphicsPath();

                List <Point> partPoints = new List <Point>();
                foreach (List <Coordinate> part in _parts)
                {
                    partPoints.AddRange(part.Select(c => Map.ProjToPixel(c)));

                    if (_featureSet.FeatureType == FeatureType.Line)
                    {
                        gp.AddLines(partPoints.ToArray());
                    }

                    if (_featureSet.FeatureType == FeatureType.Polygon)
                    {
                        gp.AddPolygon(partPoints.ToArray());
                    }

                    partPoints.Clear();
                }

                // 외곽선 그리기
                e.Graphics.DrawPath(Pens.Blue, gp);

                // 도형요소가 면이면 칠하기
                if (_featureSet.FeatureType == FeatureType.Polygon)
                {
                    Brush fill = new SolidBrush(Color.FromArgb(70, Color.LightCyan));
                    e.Graphics.FillPath(fill, gp);
                    fill.Dispose();
                }
            }

            Pen   bluePen  = new Pen(Color.Blue, 2F);
            Pen   redPen   = new Pen(Color.Red, 3F);
            Brush redBrush = new SolidBrush(Color.Red);

            List <Point> points = new List <Point>();

            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            if (_coordinates != null)
            {
                points.AddRange(_coordinates.Select(coord => Map.ProjToPixel(coord)));

                foreach (Point pt in points)
                {
                    e.Graphics.FillRectangle(redBrush, new Rectangle(pt.X - 2, pt.Y - 2, 4, 4));
                }

                if (points.Count > 1)
                {
                    if (_featureSet.FeatureType != FeatureType.MultiPoint)
                    {
                        e.Graphics.DrawLines(bluePen, points.ToArray());
                    }
                }

                if (points.Count > 0 && _standBy == false)
                {
                    if (_featureSet.FeatureType != FeatureType.MultiPoint)
                    {
                        e.Graphics.DrawLine(redPen, points[points.Count - 1], _mousePosition);
                    }
                }
            }

            bluePen.Dispose();
            redPen.Dispose();
            redBrush.Dispose();

            base.OnDraw(e);
        }
示例#11
0
        /// <summary>
        /// Perform custom drawing
        /// </summary>
        /// <param name="e"></param>
        public override void DrawRect(RectangleF dirtyRect)
        {
            if (MapFrame.IsPanning) return;
            if(!InLiveResize && _mapCore.oldSize != Bounds.Size)
                _mapCore.oldSize = Bounds.Size;

            var context = NSGraphicsContext.CurrentContext.GraphicsPort;
            Rectangle clip = new Rectangle((int)dirtyRect.X, 
                (int)(Height - (dirtyRect.Height + dirtyRect.Y)), 
                (int)dirtyRect.Width, (int)dirtyRect.Height);

            if (dirtyRect.IsEmpty)
                clip = ClientRectangle;

            // if the area to paint is too small, there's nothing to paint.
            // Added to fix http://dotspatial.codeplex.com/workitem/320
            if (clip.Width < 1 || clip.Height < 1) return;

            Bitmap stencil = new Bitmap(clip.Width, clip.Height, PixelFormat.Format32bppArgb);
            Graphics g = Graphics.FromImage(stencil);
            g.CompositingMode = CompositingMode.SourceCopy;

            Brush b = new SolidBrush(Color.White);
            g.FillRectangle(b, clip);
            b.Dispose();
            Matrix m = new Matrix();
            m.Translate(-clip.X, -clip.Y);
            g.Transform = m;

            PaintEventArgs e = new PaintEventArgs (g, clip);
            Draw(g, e);

            MapDrawArgs args = new MapDrawArgs(g, clip, MapFrame);
            foreach (IMapFunction tool in MapFunctions)
            {
                if (tool.Enabled) tool.Draw(args);
            }

            g.Dispose();

            if(dirtyRect.IsEmpty)
                context.DrawImage(((NSView)this).Bounds, ToCGImage(stencil));
            else
                context.DrawImage(dirtyRect, ToCGImage(stencil));

            stencil.Dispose();
        }
示例#12
0
        /// <summary>
        /// Handles drawing of editing features
        /// </summary>
        /// <param name="e">The drawing args</param>
        protected override void OnDraw(MapDrawArgs e)
        {
            Point mouseTest = Map.PointToClient(Control.MousePosition);

            bool hasMouse = Map.ClientRectangle.Contains(mouseTest);

            Pen   bluePen  = new Pen(Color.Blue, 2F);
            Pen   redPen   = new Pen(Color.Red, 3F);
            Brush redBrush = new SolidBrush(Color.Red);

            List <Point> points = new List <Point>();

            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            Brush blue = new SolidBrush(Color.FromArgb(60, 0, 0, 255));

            if (_previousParts != null && _previousParts.Count > 0)
            {
                GraphicsPath previous = new GraphicsPath();
                previous.FillMode = FillMode.Winding;
                List <Point> allPoints = new List <Point>();
                foreach (List <Coordinate> part in _previousParts)
                {
                    List <Point> prt = new List <Point>();
                    foreach (Coordinate c in part)
                    {
                        prt.Add(Map.ProjToPixel(c));
                    }
                    previous.AddLines(prt.ToArray());
                    allPoints.AddRange(prt);
                    if (_areaMode)
                    {
                        previous.CloseFigure();
                    }
                    previous.StartFigure();
                }
                if (_areaMode && _coordinates != null)
                {
                    List <Point> fillPts = new List <Point>();
                    if ((!_standBy && _coordinates.Count > 2) || _coordinates.Count > 3)
                    {
                        foreach (Coordinate c in _coordinates)
                        {
                            fillPts.Add(Map.ProjToPixel(c));
                        }
                        if (!_standBy && hasMouse)
                        {
                            fillPts.Add(_mousePosition);
                        }

                        previous.AddLines(fillPts.ToArray());
                        previous.CloseFigure();
                    }
                }
                if (allPoints.Count > 1)
                {
                    e.Graphics.DrawPath(bluePen, previous);
                    if (_areaMode)
                    {
                        e.Graphics.FillPath(blue, previous);
                    }
                }

                foreach (Point pt in allPoints)
                {
                    e.Graphics.FillRectangle(redBrush, new Rectangle(pt.X - 2, pt.Y - 2, 4, 4));
                }
            }

            if (_coordinates != null)
            {
                foreach (Coordinate coord in _coordinates)
                {
                    points.Add(Map.ProjToPixel(coord));
                }

                if (points.Count > 1)
                {
                    e.Graphics.DrawLines(bluePen, points.ToArray());
                    foreach (Point pt in points)
                    {
                        e.Graphics.FillRectangle(redBrush, new Rectangle(pt.X - 2, pt.Y - 2, 4, 4));
                    }
                }

                if (points.Count > 0 && _standBy == false && hasMouse)
                {
                    e.Graphics.DrawLine(redPen, points[points.Count - 1], _mousePosition);
                    if (_areaMode && points.Count > 1)
                    {
                        e.Graphics.DrawLine(redPen, points[0], _mousePosition);
                    }
                }
                if (points.Count > 1 && _areaMode && (_previousParts == null || _previousParts.Count == 0))
                {
                    if (hasMouse && !_standBy)
                    {
                        points.Add(_mousePosition);
                    }

                    if (points.Count > 2)
                    {
                        e.Graphics.FillPolygon(blue, points.ToArray());
                    }
                }
            }
            bluePen.Dispose();
            redPen.Dispose();
            redBrush.Dispose();
            blue.Dispose();
            base.OnDraw(e);
        }
示例#13
0
 /// <summary>
 /// Fires the Initialized event
 /// </summary>
 /// <param name="e">An EventArgs parameter</param>
 protected virtual void OnInitialize(MapDrawArgs e)
 {
     if (Inititialized != null)
     {
         Inititialized(this, e);
     }
    
 }
示例#14
0
 /// <summary>
 /// This will be called once for each part.  If there is only one part, then this will still be called for 
 /// the first part.  The OnDraw method is called once, regardless of the number of parts.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnDraw(MapDrawArgs e)
 {
     e.Graphics.DrawImage(_stencils[e.GeoGraphics.Stage], e.ClipRectangle, e.ClipRectangle, GraphicsUnit.Pixel);   
 }
示例#15
0
        /// <summary>
        /// This handles the initialization where structures are created
        /// </summary>
        public virtual void Initialize(MapDrawArgs args)
        {
            
            Graphics stencilDevice;
            if (_stencils == null) _stencils = new List<Image>();
            if (_stencils.Count > 0)
            {
                if (_stencils[0].Width != args.GeoGraphics.ClientRectangle.Width ||
                    _stencils[0].Height != args.GeoGraphics.ClientRectangle.Height)
                {
                    _stencils = new List<Image>();
                }
            }
            if (_stencils.Count == args.GeoGraphics.Stage)
            {
                Image bmp = new Bitmap(args.GeoGraphics.ClientRectangle.Width, args.GeoGraphics.ClientRectangle.Height);
                _stencils.Add(bmp);
            }
            
            stencilDevice = Graphics.FromImage(_stencils[args.GeoGraphics.Stage]);
            if (args.GeoGraphics.Chunk == 0)
            {
                stencilDevice.FillRectangle(Brushes.White, args.ClipRectangle);
            }

            // Any customize initialization that is layer specific will be drawn on the stencil.

            MapDrawArgs newArgs = new MapDrawArgs(stencilDevice, args.ClipRectangle, args.GeoGraphics);
            OnInitialize(newArgs);
            //_stencils[args.GeoGraphics.Stage].Save("C:\\stencil" + args.GeoGraphics.Stage.ToString() + ".bmp");
            stencilDevice.Dispose();

        }
示例#16
0
        /// <summary>
        /// This can be overridden, but should not be.  Instead override OnDraw so that
        /// the standard checks on visibility can be performed.
        /// </summary>
        /// <param name="args">A DrawingArgs class.  This is used so that this method
        /// can also be called asynchronously, or be easilly updated later.</param>
        public virtual void Draw2D(MapDrawArgs args)
        {
            try
            {
               
                if (_isVisible == false)
                {
                    OnDrawingCompleted(new GeoDrawCompletedArgs(args, false));
                    return;
                }
                if (OnBeforeDrawing(new GeoDrawVerifyArgs(args)) == true)
                {
                    OnDrawingCompleted(new GeoDrawCompletedArgs(args, true));
                    return;
                }

                for (int stage = 0; stage < _numStages; stage++)
                {
                    args.GeoGraphics.Stage = stage;
                    if (IsInitialized == false)
                    {
                        Initialize(args); // keep building if we haven't finished drawing to the stencil
                    }
                    OnDraw(args); // Draw whatever we have on the stencil
                }
                args.GeoGraphics.Stage = 0;
                OnDrawingCompleted(new GeoDrawCompletedArgs(args, false));

            }
            catch (Exception ex)
            {
                OnDrawingCompleted(new GeoDrawCompletedArgs(args, ex));
            }


        }
示例#17
0
        /// <summary>
        /// Handles drawing of editing features
        /// </summary>
        /// <param name="e">The drawing args</param>
        protected override void OnDraw(MapDrawArgs e)
        {
            double lastX     = 0;
            double lastY     = 0;
            Point  mouseTest = Map.PointToClient(Control.MousePosition);

            bool hasMouse = Map.ClientRectangle.Contains(mouseTest);

            Pen bluePen = new Pen(Color.Magenta, 1F);

            Pen redPen = new Pen(Color.Red, 2F);

            // redPen = new Pen(Color.Red, 2F);
            Brush redBrush = new SolidBrush(Color.Red);

            List <System.Drawing.Point> points = new List <System.Drawing.Point>();

            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            Brush blue = new SolidBrush(Color.FromArgb(60, 0, 0, 255));

            /*/---Specific distance
             * if (_measureDialog.chkDistance == true & _coordinates.Count > 1)
             * {
             *  kGeoFunc.CircleType cr = new  kGeoFunc.CircleType();
             *  cr.pt.X = 1;
             *
             * }
             * else
             * {
             * }
             *///----------------------------------------------------------------------------

            if (_previousParts != null && _previousParts.Count > 0)
            {
                GraphicsPath previous = new GraphicsPath();
                previous.FillMode = FillMode.Winding;
                List <Point> allPoints = new List <Point>();
                foreach (List <Coordinate> part in _previousParts)
                {
                    List <Point> prt = new List <Point>();
                    foreach (Coordinate c in part)
                    {
                        prt.Add(Map.ProjToPixel(c));
                    }
                    previous.AddLines(prt.ToArray());
                    allPoints.AddRange(prt);
                    if (_areaMode)
                    {
                        previous.CloseFigure();
                    }
                    previous.StartFigure();
                }
                if (_areaMode && _coordinates != null)
                {
                    List <Point> fillPts = new List <Point>();
                    if ((!_standBy && _coordinates.Count > 2) || _coordinates.Count > 3)
                    {
                        foreach (Coordinate c in _coordinates)
                        {
                            fillPts.Add(Map.ProjToPixel(c));
                        }
                        if (!_standBy && hasMouse)
                        {
                            fillPts.Add(_mousePosition);
                        }

                        previous.AddLines(fillPts.ToArray());
                        previous.CloseFigure();
                    }
                }
                if (allPoints.Count > 1)
                {
                    e.Graphics.DrawPath(bluePen, previous);
                    if (_areaMode)
                    {
                        e.Graphics.FillPath(blue, previous);
                    }
                }

                foreach (Point pt in allPoints)
                {
                    e.Graphics.FillRectangle(redBrush, new Rectangle(pt.X - 2, pt.Y - 2, 5, 5));
                    lastX = pt.X;
                    lastY = pt.Y;
                }
            }

            if (_coordinates != null)
            {
                foreach (Coordinate coord in _coordinates)
                {
                    points.Add(Map.ProjToPixel(coord));
                }

                if (points.Count > 1)
                {
                    e.Graphics.DrawLines(bluePen, points.ToArray());
                    foreach (Point pt in points)
                    {
                        e.Graphics.FillRectangle(redBrush, new Rectangle(pt.X - 2, pt.Y - 2, 4, 4));
                    }
                }

                if (points.Count > 0 && _standBy == false && hasMouse)
                {
                    e.Graphics.DrawLine(redPen, points[points.Count - 1], _mousePosition);
                    if (_areaMode && points.Count > 1)
                    {
                        e.Graphics.DrawLine(redPen, points[0], _mousePosition);
                    }
                }
                if (points.Count > 1 && _areaMode && (_previousParts == null || _previousParts.Count == 0))
                {
                    if (hasMouse && !_standBy)
                    {
                        points.Add(_mousePosition);
                    }

                    if (points.Count > 2)
                    {
                        e.Graphics.FillPolygon(blue, points.ToArray());
                    }
                }
            }

            bluePen.Dispose();
            redPen.Dispose();
            redBrush.Dispose();
            blue.Dispose();
            base.OnDraw(e);
        }
        /// <summary>
        /// 地图绘制
        /// </summary>
        /// <param name="e"> </param>
        protected override void OnDraw(MapDrawArgs e)
        {
            //当前鼠标在屏幕坐标系下的坐标
            Point mouseTest = Map.PointToClient(Control.MousePosition);

            //鼠标是否在地图内
            bool hasMouse = Map.ClientRectangle.Contains(mouseTest);

            //画笔 ---蓝色
            Pen bluePen = new Pen(Color.Blue, 2F);

            //画笔---红色
            Pen redPen = new Pen(Color.Red, 3F);

            //红色刷子
            Brush redBrush = new SolidBrush(Color.Red);

            //点序列
            List <Point> points = new List <Point>();

            //字体
            Font drawFont = new Font("Arial", 12);

            //抗锯齿
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;


            Brush blue = new SolidBrush(Color.FromArgb(60, 0, 0, 255));

            //绘制历史测量路劲
            if (previousParts != null && previousParts.Count > 0)
            {
                //绘制路劲
                GraphicsPath previous = new GraphicsPath
                {
                    FillMode = FillMode.Winding
                };

                //点序列
                List <Point> allPoints = new List <Point>();

                //获取一次历史记录
                foreach (List <Coordinate> part in previousParts)
                {
                    //获取此次历史记录中的每个点
                    List <Point> prt = new List <Point>();

                    foreach (Coordinate c in part)
                    {
                        prt.Add(Map.ProjToPixel(c));
                    }

                    //将点添加到路劲中绘制出来
                    previous.AddLines(prt.ToArray());

                    //将此次历史记录中的所有点添加到序列中
                    allPoints.AddRange(prt);

                    //结束此次历史路劲的绘制,为下次绘制做准备
                    previous.StartFigure();
                }


                //当所有点大于一的时候
                if (allPoints.Count > 1)
                {
                    //绘制所有历史路劲
                    e.Graphics.DrawPath(bluePen, previous);
                }

                //将所有节点绘制出来(红色)
                foreach (Point pt in allPoints)
                {
                    e.Graphics.FillRectangle(redBrush, new Rectangle(pt.X - 2, pt.Y - 2, 4, 4));
                }
            }


            //绘制当前测量
            if (coordinates != null)
            {
                //获取此次测量的所有点
                foreach (Coordinate coord in coordinates)
                {
                    points.Add(Map.ProjToPixel(coord));
                }


                //点数量大于1
                if (points.Count > 1)
                {
                    //绘制折线,节点,长度

                    for (int i = 0; i < points.Count - 1; i++)
                    {
                        Point cp = points[i];

                        Point np = points[i + 1];

                        e.Graphics.DrawLine(bluePen, cp, np);

                        e.Graphics.FillRectangle(redBrush, new Rectangle(cp.X - 2, cp.Y - 2, 4, 4));

                        e.Graphics.DrawString(curDis[i].ToString(), drawFont, redBrush, new Point((cp.X + np.X) / 2, (cp.Y + np.Y) / 2));
                    }
                }

                //当点数量大于0时,绘制鼠标移动所构成的那条线
                if (points.Count > 0 && _standBy == false && hasMouse)
                {
                    e.Graphics.DrawLine(redPen, points[points.Count - 1], _mousePosition);

                    double dis = GetDist(Map.PixelToProj(_mousePosition), null);

                    e.Graphics.DrawString(dis.ToString(), drawFont, redBrush, new Point((points[points.Count - 1].X + _mousePosition.X) / 2, (points[points.Count - 1].Y + _mousePosition.Y) / 2));

                    e.Graphics.DrawString(String.Format("总长度:{0}", tempDistance.ToString()), drawFont, redBrush, _mousePosition);
                }
            }

            //释放
            bluePen.Dispose();
            redPen.Dispose();
            redBrush.Dispose();
            blue.Dispose();
            drawFont.Dispose();
            base.OnDraw(e);
        }
示例#19
0
        /// <summary>
        /// Handles drawing of editing features.
        /// </summary>
        /// <param name="e">The drawing args for the draw method.</param>
        protected override void OnDraw(MapDrawArgs e)
        {
            if (_standBy)
            {
                return;
            }

            // Begin snapping changes
            DoSnapDrawing(e.Graphics, _mousePosition);
            // End snapping changes

            if (_featureSet.FeatureType == FeatureType.Point)
            {
                return;
            }

            // Draw any completed parts first so that they are behind my active drawing content.
            if (_parts != null)
            {
                GraphicsPath gp = new GraphicsPath();

                List <Point> partPoints = new List <Point>();
                foreach (List <Coordinate> part in _parts)
                {
                    partPoints.AddRange(part.Select(c => Map.ProjToPixel(c)));
                    if (_featureSet.FeatureType == FeatureType.Line)
                    {
                        gp.AddLines(partPoints.ToArray());
                    }
                    if (_featureSet.FeatureType == FeatureType.Polygon)
                    {
                        gp.AddPolygon(partPoints.ToArray());
                    }
                    partPoints.Clear();
                }
                e.Graphics.DrawPath(Pens.Blue, gp);
                if (_featureSet.FeatureType == FeatureType.Polygon)
                {
                    Brush fill = new SolidBrush(Color.FromArgb(70, Color.LightCyan));
                    e.Graphics.FillPath(fill, gp);
                    fill.Dispose();
                }
            }

            Pen          bluePen  = new Pen(Color.Blue, 2F);
            Pen          redPen   = new Pen(Color.Red, 3F);
            Brush        redBrush = new SolidBrush(Color.Red);
            List <Point> points   = new List <Point>();

            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            if (_coordinates != null)
            {
                points.AddRange(_coordinates.Select(coord => Map.ProjToPixel(coord)));
                foreach (Point pt in points)
                {
                    e.Graphics.FillRectangle(redBrush, new Rectangle(pt.X - 2, pt.Y - 2, 4, 4));
                }
                if (points.Count > 1)
                {
                    if (_featureSet.FeatureType != FeatureType.MultiPoint)
                    {
                        e.Graphics.DrawLines(bluePen, points.ToArray());
                    }
                }
                if (points.Count > 0 && _standBy == false)
                {
                    if (_featureSet.FeatureType != FeatureType.MultiPoint)
                    {
                        e.Graphics.DrawLine(redPen, points[points.Count - 1], _mousePosition);
                    }
                }
            }

            bluePen.Dispose();
            redPen.Dispose();
            redBrush.Dispose();
            base.OnDraw(e);
        }
 /// <summary>
 /// Creates a new instance of GeoHandledDrawArgs
 /// </summary>
 public GeoDrawVerifyArgs(MapDrawArgs args)
     : base(args.Graphics, args.ClipRectangle, args.GeoGraphics)
 {
    
 }