====== Source Code DesktopEditionSample TrackedShapesToWKT CS 100513.zip ====== ====Program.cs==== using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace TrackedShapesToWKT { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new TestForm()); } } } ====TestForm.cs==== using System; using System.Windows.Forms; using System.Collections.ObjectModel; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.DesktopEdition; namespace TrackedShapesToWKT { public partial class TestForm : Form { public TestForm() { InitializeComponent(); } private void TestForm_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.CurrentExtent = new RectangleShape(-93.9016,31.0287,-86.8264,26.766); winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255)); //Event handlers for the TrackOverlay. winformsMap1.TrackOverlay.TrackEnded += new EventHandler(trackOverlay_TrackEnded); winformsMap1.TrackOverlay.TrackEnding += new EventHandler(trackOverlay_TrackEnding); winformsMap1.TrackOverlay.TrackStarting += new EventHandler(trackOverlay_TrackStarting); winformsMap1.TrackOverlay.TrackMode = TrackMode.Polygon; //Displays the World Map Kit as a background. ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay(); winformsMap1.Overlays.Add(worldMapKitDesktopOverlay); winformsMap1.Refresh(); } //At the mouse down event when in track polygon mode, we clear the shape already tracked. void trackOverlay_TrackStarting(object sender, TrackStartingTrackInteractiveOverlayEventArgs e) { richTextBoxFinished.Text = ""; winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear(); winformsMap1.Refresh(winformsMap1.TrackOverlay); } //At the double click event to finish tracking the shape, we get the WKT of the result shape. void trackOverlay_TrackEnded(object sender, TrackEndedTrackInteractiveOverlayEventArgs e) { richTextBoxCurrent.Text = ""; richTextBoxFinished.Text = e.TrackShape.GetWellKnownText(); } //At mouse move event while the shape is being tracked, we get its WKT. void trackOverlay_TrackEnding(object sender, TrackEndingTrackInteractiveOverlayEventArgs e) { richTextBoxCurrent.Text = e.TrackShape.GetWellKnownText(); } private void winformsMap1_MouseMove(object sender, MouseEventArgs e) { //Displays the X and Y in screen coordinates. statusStrip1.Items["toolStripStatusLabelScreen"].Text = "X:" + e.X + " Y:" + e.Y; //Gets the PointShape in world coordinates from screen coordinates. PointShape pointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, new ScreenPointF(e.X, e.Y), winformsMap1.Width, winformsMap1.Height); //Displays world coordinates. statusStrip1.Items["toolStripStatusLabelWorld"].Text = "(world) X:" + Math.Round(pointShape.X, 4) + " Y:" + Math.Round(pointShape.Y, 4); } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } } }