/// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected override void OnDraw(MapDrawArgs e)
 {
     if (_isDragging)
     {
         Rectangle r = Opp.RectangleFromPoints(_startPoint, _currentPoint);
         r.Width  -= 1;
         r.Height -= 1;
         e.Graphics.DrawRectangle(Pens.White, r);
         e.Graphics.DrawRectangle(_selectionPen, r);
     }
     if (_doSelect)
     {
         foreach (IMapLayer lyr in Map.MapFrame.Layers)
         {
             IMapFeatureLayer fl = lyr as IMapFeatureLayer;
             if (fl == null)
             {
                 continue;
             }
             IMapLabelLayer gll = fl.LabelLayer;
             //gll.Select(_selectionEnvelope, e); // using this form of selection can test the actual pixel rectangles
             if (gll != null)
             {
                 gll.Invalidate();
             }
         }
         _doSelect = false;
         _selectTimer.Start();
     }
     base.OnDraw(e);
 }
        /// <summary>
        /// Draws the label.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected override void OnDraw(MapDrawArgs e)
        {
            if (_isDragging)
            {
                Rectangle r = Opp.RectangleFromPoints(_startPoint, _currentPoint);
                r.Width  -= 1;
                r.Height -= 1;
                e.Graphics.DrawRectangle(Pens.White, r);
                e.Graphics.DrawRectangle(_selectionPen, r);
            }

            if (_doSelect)
            {
                foreach (IMapLayer lyr in Map.MapFrame.Layers)
                {
                    IMapFeatureLayer fl = lyr as IMapFeatureLayer;
                    fl?.LabelLayer?.Invalidate();
                }

                _doSelect = false;
                _selectTimer.Start();
            }

            base.OnDraw(e);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected override void OnDraw(MapDrawArgs e)
 {
     if (_isDragging)
     {
         Rectangle r = Opp.RectangleFromPoints(_startPoint, _currentPoint);
         r.Width -= 1;
         r.Height -= 1;
         e.Graphics.DrawRectangle(Pens.White, r);
         e.Graphics.DrawRectangle(_selectionPen, r);
     }
     if (_doSelect)
     {
         foreach (IMapLayer lyr in Map.MapFrame.Layers)
         {
             IMapFeatureLayer fl = lyr as IMapFeatureLayer;
             if (fl == null)
             {
                 continue;
             }
             IMapLabelLayer gll = fl.LabelLayer;
             //gll.Select(_selectionEnvelope, e); // using this form of selection can test the actual pixel rectangles
             if (gll != null)
             {
                 gll.Invalidate();
             }
         }
         _doSelect = false;
         _selectTimer.Start();
     }
     base.OnDraw(e);
 }
Example #4
0
 /// <summary>
 /// Creates a new instance of GeoDrawTextArgs
 /// </summary>
 public MapDrawTextArgs(MapDrawArgs args, ILabelSymbolizer symbolizer)
 {
     _symbolizer = symbolizer;
     _drawArgs   = args;
     _fontBrush  = new SolidBrush(symbolizer.FontColor);
     _backBrush  = new SolidBrush(symbolizer.BackColor);
     _borderPen  = new Pen(symbolizer.BorderColor);
 }
 /// <summary>
 /// Creates a new instance of GeoDrawTextArgs
 /// </summary>
 public MapDrawTextArgs(MapDrawArgs args, ILabelSymbolizer symbolizer)
 {
     _symbolizer = symbolizer;
     _drawArgs = args;
     _fontBrush = new SolidBrush(symbolizer.FontColor);
     _backBrush = new SolidBrush(symbolizer.BackColor);
     _borderPen = new Pen(symbolizer.BorderColor);
 }
Example #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected override void OnDraw(MapDrawArgs e)
 {
     if (_isDragging)
     {
         Rectangle r = Opp.RectangleFromPoints(_startPoint, _currentPoint);
         r.Width  -= 1;
         r.Height -= 1;
         e.Graphics.DrawRectangle(Pens.White, r);
         e.Graphics.DrawRectangle(_selectionPen, r);
     }
     base.OnDraw(e);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected override void OnDraw(MapDrawArgs e)
 {
     if (_isDragging)
     {
         Rectangle r = Opp.RectangleFromPoints(_startPoint, _currentPoint);
         r.Width -= 1;
         r.Height -= 1;
         e.Graphics.DrawRectangle(Pens.White, r);
         e.Graphics.DrawRectangle(_selectionPen, r);
     }
     base.OnDraw(e);
 }
Example #8
0
        /// <summary>
        /// Draws the glyph on the map.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnDraw(MapDrawArgs e)
        {
            Rectangle glyph = GlpyhBounds;
            Bitmap    bmp   = new Bitmap(glyph.Width, glyph.Height);
            Graphics  g     = Graphics.FromImage(bmp);

            if (e.ClipRectangle.IntersectsWith(glyph))
            {
                Rectangle r = Rectangle.Intersect(e.ClipRectangle, glyph);
                r.X -= glyph.X;
                r.Y -= glyph.Y;
                if (HasMouse)
                {
                    OnDrawGlyphLit(new PaintEventArgs(g, r));
                }
                else
                {
                    OnDrawGlyph(new PaintEventArgs(g, r));
                }
            }
            e.Graphics.DrawImageUnscaled(bmp, glyph.X, glyph.Y);
            base.OnDraw(e);
        }
Example #9
0
        /// <summary>
        /// Perform custom drawing
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (_geoMapFrame.IsPanning) return;

            Rectangle clip = e.ClipRectangle;
            if (clip.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);
            Brush b = new SolidBrush(BackColor);
            g.FillRectangle(b, new Rectangle(0, 0, stencil.Width, stencil.Height));
            b.Dispose();
            Matrix m = new Matrix();
            m.Translate(-clip.X, -clip.Y);
            g.Transform = m;

            _geoMapFrame.Draw(new PaintEventArgs(g, e.ClipRectangle));

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

            PaintEventArgs pe = new PaintEventArgs(g, e.ClipRectangle);
            base.OnPaint(pe);

            g.Dispose();
            e.Graphics.DrawImageUnscaled(stencil, clip.X, clip.Y);
            stencil.Dispose();
        }
Example #10
0
        /// <summary>
        /// Perform custom drawing
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (_geoMapFrame.IsPanning) return;

            var clip = e.ClipRectangle;
            if (clip.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;

            using (var stencil = new Bitmap(clip.Width, clip.Height, PixelFormat.Format32bppArgb))
            using (var g = Graphics.FromImage(stencil))
            {
                using (var b = new SolidBrush(BackColor))
                    g.FillRectangle(b, new Rectangle(0, 0, stencil.Width, stencil.Height));

                using (var m = new Matrix())
                {
                    m.Translate(-clip.X, -clip.Y);
                    g.Transform = m;

                    Draw(g, e);

                    var args = new MapDrawArgs(g, clip, _geoMapFrame);
                    foreach (var tool in MapFunctions.Where(_ => _.Enabled))
                    {
                        tool.Draw(args);
                    }

                    var pe = new PaintEventArgs(g, e.ClipRectangle);
                    base.OnPaint(pe);
                }

                e.Graphics.DrawImageUnscaled(stencil, clip.X, clip.Y);
            }
        }
Example #11
0
 /// <summary>
 /// This allows sub-classes to customize the drawing that occurs.  All drawing is done
 /// in the image coordinate space, where 0, 0 is the upper left corner of the image.
 /// </summary>
 /// <param name="e">A PaintEventArgs where the graphics object is already in image coordinates</param>
 protected virtual void OnDraw(MapDrawArgs e)
 {
 }
Example #12
0
 /// <summary>
 /// This is the method that is called by the drawPanel.  The graphics coordinates are
 /// in pixels relative to the image being edited.
 /// </summary>
 public void Draw(MapDrawArgs args)
 {
     //if (OnBeforeDrawing(args) == true) return; // handled
     OnDraw(args);
 }
Example #13
0
 /// <summary>
 /// This allows sub-classes to customize the drawing that occurs.  All drawing is done
 /// in the image coordinate space, where 0, 0 is the upper left corner of the image.
 /// </summary>
 /// <param name="e">A PaintEventArgs where the graphics object is already in image coordinates</param>
 protected virtual void OnDraw(MapDrawArgs e)
 {
 }
Example #14
0
        /// <summary>
        /// Perform custom drawing
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (_geoMapFrame.IsPanning) return;

            Rectangle clip = e.ClipRectangle;
            if (clip.IsEmpty || _isResizing) 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);
            Brush b = new SolidBrush(BackColor);
            g.FillRectangle(b, new Rectangle(0, 0, stencil.Width, stencil.Height));
            b.Dispose();
            Matrix m = new Matrix();
            m.Translate(-clip.X, -clip.Y);
            g.Transform = m;

            _geoMapFrame.Draw(new PaintEventArgs(g, e.ClipRectangle));

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

            PaintEventArgs pe = new PaintEventArgs(g, e.ClipRectangle);
            base.OnPaint(pe);

            g.Dispose();

            if (_isResizing)
            {
                Rectangle v = _geoMapFrame.View;
                Extent target = ViewExtents.Copy();
                GetResizeExtent(target);
                Rectangle nV = _geoMapFrame.ProjToPixel(target);
                const int sourceX = 0;
                const int sourceY = 0;
                int sourceHeight = Height;
                int sourceWidth = Width;
                int destX = 0;
                int destY = 0;
                int destWidth = Width;
                int destHeight = Height;
                if (nV.Height > v.Height)
                {
                    double yRat = nV.Height / (double)v.Height;
                    destHeight = Convert.ToInt32(Height / yRat);
                    destY = (Height - destHeight) / 2;
                }
                else
                {
                    double xRat = nV.Width / (double)v.Width;
                    destWidth = Convert.ToInt32(Width / xRat);
                    destX = (Width - destWidth) / 2;
                }
                using (Bitmap bmp = new Bitmap(Width, Height))
                {
                    using (Graphics gg = Graphics.FromImage(bmp))
                    {
                        using (Brush bb = new SolidBrush(BackColor))
                        {
                            gg.FillRectangle(bb, 0, 0, Width, Height);
                        }

                        Rectangle source = new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight);
                        Rectangle dest = new Rectangle(destX, destY, destWidth, destHeight);
                        gg.DrawImage(stencil, dest, source, GraphicsUnit.Pixel);
                    }

                    e.Graphics.DrawImageUnscaled(bmp, 0, 0);
                }
            }
            else
            {
                e.Graphics.DrawImageUnscaled(stencil, clip.X, clip.Y);
            }

            stencil.Dispose();
        }
        /// <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);
        }
Example #16
0
 /// <summary>
 /// This is the method that is called by the drawPanel. The graphics coordinates are
 /// in pixels relative to the image being edited.
 /// </summary>
 /// <param name="args">The map draw args.</param>
 public void Draw(MapDrawArgs args)
 {
     OnDraw(args);
 }
Example #17
0
 /// <summary>
 /// Draws the glyph on the map.
 /// </summary>
 /// <param name="e"></param>
 protected override void OnDraw(MapDrawArgs e)
 {
     Rectangle glyph = GlpyhBounds;
     Bitmap bmp = new Bitmap(glyph.Width, glyph.Height);
     Graphics g = Graphics.FromImage(bmp);
     if (e.ClipRectangle.IntersectsWith(glyph))
     {
         Rectangle r = Rectangle.Intersect(e.ClipRectangle, glyph);
         r.X -= glyph.X;
         r.Y -= glyph.Y;
         if (HasMouse)
         {
             OnDrawGlyphLit(new PaintEventArgs(g, r));
         }
         else
         {
             OnDrawGlyph(new PaintEventArgs(g, r));
         }
     }
     e.Graphics.DrawImageUnscaled(bmp, glyph.X, glyph.Y);
     base.OnDraw(e);
 }
 /// <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.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();
         }
     }
 }
Example #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);
        }
Example #20
0
 /// <summary>
 /// This is the method that is called by the drawPanel.  The graphics coordinates are
 /// in pixels relative to the image being edited.
 /// </summary>
 public void Draw(MapDrawArgs args)
 {
     //if (OnBeforeDrawing(args) == true) return; // handled
     OnDraw(args);
 }