Scribble Class |
Namespace: Telogis.GeoBase
The Scribble type exposes the following members.
Name | Description | |
---|---|---|
Points |
Get the array of points for this Scribble.
| |
RenderPen |
Gets or sets the Pen used to render the scribble drawing.
| |
RequiredRendermodes |
Gets the RenderMode required by this Scribble.
|
Name | Description | |
---|---|---|
AddPoint |
Add a LatLon point to the scribble drawing.
| |
Clear |
Clears the scribble drawing.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Render |
Renders this Scribble object using the specified Graphics
and RenderContext.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
// --- 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(); } }
// --- 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); } }