Click or drag to resize

Scribble Class

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
A free-form drawing tool that allows a user to scribble on the map.
Inheritance Hierarchy
SystemObject
  Telogis.GeoBaseScribble

Namespace:  Telogis.GeoBase
Assembly:  geobase.net (in geobase.net.dll) Version: 4.99.0.0
Syntax
public class Scribble : IMapRenderer

The Scribble type exposes the following members.

Constructors
  NameDescription
Public methodScribble
Construct a new Scribble object.
Top
Properties
  NameDescription
Public propertyPoints
Get the array of points for this Scribble.
Public propertyRenderPen
Gets or sets the Pen used to render the scribble drawing.
Public propertyRequiredRendermodes
Gets the RenderMode required by this Scribble.
Top
Methods
  NameDescription
Public methodAddPoint
Add a LatLon point to the scribble drawing.
Public methodClear
Clears the scribble drawing.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodRender
Renders this Scribble object using the specified Graphics and RenderContext.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks
The scribble is composed of a series of LatLon points and is thus bound to the area of the map that it was drawn upon.
Examples
The following examples demonstrate the scribble class as used by a MapCtrl and by Map.
C#
// --- MapCtrl Example
   // Create a scribble object
   Telogis.GeoBase.Scribble myScribble = new Telogis.GeoBase.Scribble();

   // Create a renderlist
   Telogis.GeoBase.RendererList rlist = new Telogis.GeoBase.RendererList();

   public Form1() {
       InitializeComponent();
       // Set the mapCtrl renderer
       mapMain.Renderer = rlist;
       // Add the scribble object to the renderer
       rlist.Add(myScribble);
       // The scribble line is 2 pixels wide and blue
       myScribble.RenderPen = new Pen(Color.Blue, 2);
       // Click the map to trigger an event
       mapMain.MouseClick += new MouseEventHandler(mapMain_MouseClick);
   }

   void mapMain_MouseClick(object sender, MouseEventArgs e) {
       // Translate the clicked location to a LatLon
       LatLon mouseClickLoc = new LatLon(mapMain.XYtoLatLon(e.X, e.Y));
       // If the mouse button was a right-click then...
       if (e.Button == MouseButtons.Right) {
           // Add the click location to the scribble object
           myScribble.AddPoint(mouseClickLoc);
           // Invalidate the map to force a redraw
           mapMain.Invalidate();
       }
   }
C#
// --- Map Example
   // Create an 800px x 500px Map object in California with a zoom value of 4
   Telogis.GeoBase.Map myMap = new Telogis.GeoBase.Map(new LatLon(33.694165, -117.956236), 800, 500, 4);

   // Create a PictureBox to display the map on the Form
   PictureBox myPictureBox = new PictureBox();

   public Form1() {
       InitializeComponent();

       // Specify the renderer
       myMap.Renderer = new ScribbleRenderer();

       // Set the PictureBox size
       myPictureBox.Size = new System.Drawing.Size(800, 500);

       // Set the PictureBox image to the Map image
       myPictureBox.Image = myMap.GetMap();

       // Add the PictureBox to the form
       Controls.Add(myPictureBox);

       // Create a mouse move event
       myPictureBox.MouseMove += new MouseEventHandler(myPictureBox_MouseMove);
   }

   void myPictureBox_MouseMove(object sender, MouseEventArgs e) {
       // Convert the mouse location (XY) to a LatLon
       LatLon mouseLoc = new LatLon(myMap.XYtoLatLon(e.X, e.Y));
       // Was there a left-click while the mouse was moving (drag)?
       if (e.Button == MouseButtons.Left) {
           (myMap.Renderer as ScribbleRenderer).AddPoint(mouseLoc);
           myPictureBox.Image = myMap.GetMap();
       }
   }

   public class ScribbleRenderer : IMapRenderer {

       // Create the scribble object
       Telogis.GeoBase.Scribble myScribble = new Telogis.GeoBase.Scribble();

       // Configure the scribble object
       public void Render(Graphics graphics, RenderContext rc) {
           // Black line, 2px wide
           myScribble.RenderPen = new Pen(Color.Black, 2);
           myScribble.Render(graphics, rc);
       }

       // Required for the IMapRenderer interface - must be postlabelling for scribble
       public RenderMode RequiredRendermodes {
           get { return RenderMode.PostLabelling; }
       }

       // This method is used to add a point to the renderer
       public void AddPoint(LatLon point) {
           myScribble.AddPoint(point);
       }
   }
See Also