/// <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>
 /// 
 /// </summary>
 /// <param name="e"></param>
 protected override void OnDraw(MapDrawArgs e)
 {
     if (_isDragging) // don't draw anything unless we need to draw a select rectangle
     {
         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>
        /// Handles drawing of editing features
        /// </summary>
        /// <param name="e">The drawing args</param>
        protected override void OnDraw(MapDrawArgs e)
        {
          
            
   
            if (_standBy) return;
            if (_featureSet.FeatureType == FeatureTypes.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)
                {
                    foreach (Coordinate c in part)
                    {
                        partPoints.Add(Map.ProjToPixel(c));
                    }
                    if (_featureSet.FeatureType == FeatureTypes.Line)
                    {
                        gp.AddLines(partPoints.ToArray());
                    }
                    if (_featureSet.FeatureType == FeatureTypes.Polygon)
                    {
                        gp.AddPolygon(partPoints.ToArray());
                    }
                    partPoints.Clear();
                }
                e.Graphics.DrawPath(Pens.Blue, gp);
                if (_featureSet.FeatureType == FeatureTypes.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)
            {
                foreach (Coordinate coord in _coordinates)
                {
                    points.Add(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 != FeatureTypes.MultiPoint)
                    {
                        e.Graphics.DrawLines(bluePen, points.ToArray());
                    }
                    
                }
                if (points.Count > 0 && _standBy == false)
                {
                    if (_featureSet.FeatureType != FeatureTypes.MultiPoint)
                    {
                        e.Graphics.DrawLine(redPen, points[points.Count - 1], _mousePosition);
                    }
                }
            }
            
            
            bluePen.Dispose();
            redPen.Dispose();
            redBrush.Dispose();
            base.OnDraw(e);
        }
Example #4
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;
            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.Values)
            {
                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();
            if (_collectAfterDraw) GC.Collect();
            
        }
        ///// <summary>
        ///// Fires the BeforeDrawing event and allows users to intercept drawing if they want
        ///// </summary>
        ///// <param name="e"></param>
        ///// <returns></returns>
        //protected virtual bool OnBeforeDrawing(MapDrawArgs e)
        //{
        //    if (BeforeDrawing == null) return false;
        //    GeoDrawVerifyArgs args = new GeoDrawVerifyArgs(e);
        //    BeforeDrawing(this, args);
        //    return args.Handled;
        //}
        /// <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)
        {

        }
 /// <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);
 }
      /// <summary>
      /// Handles drawing of editing features
      /// </summary>
      /// <param name="e">The drawing args</param>
      protected override void OnDraw(MapDrawArgs e)
      {
 
          if (_standBy) return;
          Pen bluePen = new Pen(Color.Blue, 2F);
          Pen redPen = new Pen(Color.Red, 3F);
          Brush redBrush = new SolidBrush(Color.Red);
          List<System.Drawing.Point> points = new List<System.Drawing.Point>();
          e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
          if (_coordinates != null)
          {
              foreach (Coordinate coord in _coordinates)
              {
                  points.Add(Map.ProjToPixel(coord));
              }
              
              if (points.Count > 1)
              {
                  e.Graphics.DrawLines(bluePen, points.ToArray());
                  foreach (System.Drawing.Point pt in points)
                  {
                      e.Graphics.FillRectangle(redBrush, new Rectangle(pt.X - 2, pt.Y - 2, 4, 4));
                  }
              }
              
              if (points.Count > 0 && _standBy == false)
              {
                  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)
              {
                  points.Add(_mousePosition);
                  e.Graphics.FillPolygon(Brushes.Blue, points.ToArray());
              }
          }
          bluePen.Dispose();
          redPen.Dispose();
          redBrush.Dispose();
          base.OnDraw(e);
      }
        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 == FeatureTypes.Point || _featureSet.FeatureType == FeatureTypes.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);
                    p.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();
                }

                
            }

        }