ThinkGeo Cloud
ThinkGeo UI Controls
ThinkGeo Open Source
Help and Support
External Resources
ThinkGeo Cloud
ThinkGeo UI Controls
ThinkGeo Open Source
Help and Support
External Resources
using System; using System.Collections.Generic; using System.Linq; using System.Text; using ThinkGeo.MapSuite.DesktopEdition; using ThinkGeo.MapSuite.Core; using System.Windows.Forms; namespace TrackZoomInWithoutShiftKey { class ModeInteractiveOverlay: ExtentInteractiveOverlay { public enum Mode { TrackZoomIn,Pan }; private Mode mode; public ModeInteractiveOverlay() { //Sets default mode to TrackZoomIn. base.PanMode = MapPanMode.Disabled; base.LeftClickDragMode = MapLeftClickDragMode.ZoomInWithKey; base.LeftClickDragKey = Keys.None; mode = Mode.TrackZoomIn; } public Mode MapMode { get { return mode; } set { mode = value; if (mode == Mode.TrackZoomIn) { base.PanMode = MapPanMode.Disabled; base.LeftClickDragMode = MapLeftClickDragMode.ZoomInWithKey; base.LeftClickDragKey = Keys.None; } else if (mode == Mode.Pan) { base.PanMode = MapPanMode.StandardPanning; base.LeftClickDragMode = MapLeftClickDragMode.Disabled; base.LeftClickDragKey = Keys.None; } } } protected override InteractiveResult MouseDownCore(InteractionArguments interactionArguments) { InteractiveResult result = null; result = base.MouseDownCore(interactionArguments); base.PanAndTrackZoomState.IsLeftClickDragKeyPressed = true; return result; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace TrackZoomInWithoutShiftKey { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new TestForm()); } } }
using System; using System; using System.Windows.Forms; using System.Collections.ObjectModel; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.DesktopEdition; namespace TrackZoomInWithoutShiftKey { public partial class TestForm : Form { ModeInteractiveOverlay modeInteractiveOverlay = null; public TestForm() { InitializeComponent(); } private void TestForm_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.CurrentExtent = new RectangleShape(-125, 47, -67, 25); winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255)); //Displays the World Map Kit as a background. ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay(); winformsMap1.Overlays.Add(worldMapKitDesktopOverlay); //Adds the ModeInteractiveOverlay to the InteractiveOverlays collection of the map. winformsMap1.InteractiveOverlays.Clear(); modeInteractiveOverlay = new ModeInteractiveOverlay(); modeInteractiveOverlay.MapMode = ModeInteractiveOverlay.Mode.TrackZoomIn; winformsMap1.InteractiveOverlays.Add(modeInteractiveOverlay); winformsMap1.Refresh(); } private void ToolBar1_ButtonClick(object sender, ToolBarButtonClickEventArgs e) { foreach (ToolBarButton toolBarButton in ToolBar1.Buttons) { toolBarButton.Pushed = false; } switch (e.Button.ToolTipText) { case "Track Zoom In": ToolBar1.Buttons[0].Pushed = true; modeInteractiveOverlay.MapMode = ModeInteractiveOverlay.Mode.TrackZoomIn; break; case "Pan": ToolBar1.Buttons[2].Pushed = true; modeInteractiveOverlay.MapMode = ModeInteractiveOverlay.Mode.Pan; break; default: break; } } 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(); } } }