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.Threading.Tasks; using System.Windows.Forms; namespace TrackZoomInWithShiftSample { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } } }
using System; using System.Drawing; using System.Windows.Forms; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.DesktopEdition; namespace TrackZoomInWithShiftSample { public partial class MainForm : Form { public MainForm() { InitializeComponent(); } private void MainFormLoad(object sender, EventArgs e) { winformsMap.MapUnit = GeographyUnit.Meter; winformsMap.CurrentExtent = new RectangleShape(-10037508.352, 10037508.352, 10037508.352, -10037508.352); winformsMap.BackColor = Color.AliceBlue; LayerOverlay layerOverlay = new LayerOverlay(); ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer(@"..\..\App_Data\Countries02.shp"); shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Yellow), new GeoSolidBrush(new GeoColor(100, GeoColor.SimpleColors.Green))); shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; layerOverlay.Layers.Add(shapeFileFeatureLayer); winformsMap.Overlays.Add(layerOverlay); winformsMap.InteractiveOverlays.Clear(); ModeInteractiveOverlay modeInteractiveOverlay = new ModeInteractiveOverlay(); modeInteractiveOverlay.MapMode = ModeInteractiveOverlay.Mode.TrackZoomIn; winformsMap.InteractiveOverlays.Add("ModeInteractiveOverlay", modeInteractiveOverlay); winformsMap.ZoomLevelSnapping = ZoomLevelSnappingMode.None; winformsMap.Refresh(); } private void ToolBarButtonClick(object sender, ToolBarButtonClickEventArgs e) { ModeInteractiveOverlay modeInteractiveOverlay = (ModeInteractiveOverlay)winformsMap.InteractiveOverlays["ModeInteractiveOverlay"]; foreach (ToolBarButton toolBarButton in toolBar.Buttons) { toolBarButton.Pushed = false; } switch (e.Button.ToolTipText) { case "Zoom In": toolBar.Buttons[0].Pushed = true; modeInteractiveOverlay.MapMode = ModeInteractiveOverlay.Mode.TrackZoomIn; break; case "Pan": toolBar.Buttons[2].Pushed = true; modeInteractiveOverlay.MapMode = ModeInteractiveOverlay.Mode.Pan; break; default: break; } } } }
namespace TrackZoomInWithShiftSample { partial class MainForm { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.winformsMap = new ThinkGeo.MapSuite.DesktopEdition.WinformsMap(); this.toolBar = new System.Windows.Forms.ToolBar(); this.ToolBarButtonZIT = new System.Windows.Forms.ToolBarButton(); this.spc = new System.Windows.Forms.ToolBarButton(); this.ToolBarButtonPan = new System.Windows.Forms.ToolBarButton(); this.imageList1 = new System.Windows.Forms.ImageList(this.components); this.SuspendLayout(); // // winformsMap // this.winformsMap.BackColor = System.Drawing.Color.White; this.winformsMap.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.Default; this.winformsMap.CurrentScale = 590591790D; this.winformsMap.DrawingQuality = ThinkGeo.MapSuite.Core.DrawingQuality.Default; this.winformsMap.Location = new System.Drawing.Point(0, 34); this.winformsMap.MapFocusMode = ThinkGeo.MapSuite.DesktopEdition.MapFocusMode.Default; this.winformsMap.MapResizeMode = ThinkGeo.MapSuite.Core.MapResizeMode.PreserveScale; this.winformsMap.MapUnit = ThinkGeo.MapSuite.Core.GeographyUnit.DecimalDegree; this.winformsMap.MaximumScale = 80000000000000D; this.winformsMap.MinimumScale = 200D; this.winformsMap.Name = "winformsMap"; this.winformsMap.Size = new System.Drawing.Size(1172, 723); this.winformsMap.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; this.winformsMap.TabIndex = 0; this.winformsMap.Text = "winformsMap"; this.winformsMap.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; this.winformsMap.ThreadingMode = ThinkGeo.MapSuite.DesktopEdition.MapThreadingMode.Default; this.winformsMap.ZoomLevelSnapping = ThinkGeo.MapSuite.DesktopEdition.ZoomLevelSnappingMode.Default; // // toolBar // this.toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { this.ToolBarButtonZIT, this.spc, this.ToolBarButtonPan}); this.toolBar.ButtonSize = new System.Drawing.Size(16, 16); this.toolBar.DropDownArrows = true; this.toolBar.ImageList = this.imageList1; this.toolBar.Location = new System.Drawing.Point(0, 0); this.toolBar.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.toolBar.Name = "toolBar"; this.toolBar.ShowToolTips = true; this.toolBar.Size = new System.Drawing.Size(1172, 28); this.toolBar.TabIndex = 86; this.toolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.ToolBarButtonClick); // // ToolBarButtonZIT // this.ToolBarButtonZIT.ImageIndex = 0; this.ToolBarButtonZIT.Name = "ToolBarButtonZIT"; this.ToolBarButtonZIT.Pushed = true; this.ToolBarButtonZIT.ToolTipText = "Zoom In"; // // spc // this.spc.Name = "spc"; this.spc.Style = System.Windows.Forms.ToolBarButtonStyle.Separator; // // ToolBarButtonPan // this.ToolBarButtonPan.ImageIndex = 1; this.ToolBarButtonPan.Name = "ToolBarButtonPan"; this.ToolBarButtonPan.ToolTipText = "Pan"; // // imageList1 // this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); this.imageList1.TransparentColor = System.Drawing.Color.Transparent; this.imageList1.Images.SetKeyName(0, "draw.png"); this.imageList1.Images.SetKeyName(1, "pan.png"); // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1172, 757); this.Controls.Add(this.toolBar); this.Controls.Add(this.winformsMap); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "MainForm"; this.Text = "TrackZoomIn With ShiftKey"; this.Load += new System.EventHandler(this.MainFormLoad); this.ResumeLayout(false); this.PerformLayout(); } #endregion private ThinkGeo.MapSuite.DesktopEdition.WinformsMap winformsMap; internal System.Windows.Forms.ToolBar toolBar; internal System.Windows.Forms.ToolBarButton ZoomIn; private System.Windows.Forms.ToolBarButton spc; internal System.Windows.Forms.ToolBarButton Pan; private System.Windows.Forms.ImageList imageList1; internal System.Windows.Forms.ToolBarButton ToolBarButtonZIT; internal System.Windows.Forms.ToolBarButton ToolBarButtonPan; } }
using System; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.DesktopEdition; namespace TrackZoomInWithShiftSample { class ModeInteractiveOverlay : ExtentInteractiveOverlay { private Mode mode; private PointShape startPoint; public ModeInteractiveOverlay() { MapMode = Mode.TrackZoomIn; startPoint = new PointShape(); } public Mode MapMode { get { return mode; } set { mode = value; if (mode == Mode.TrackZoomIn) { PanMode = MapPanMode.Disabled; LeftClickDragMode = MapLeftClickDragMode.ZoomInWithKey; } else if (mode == Mode.Pan) { PanMode = MapPanMode.StandardPanning; LeftClickDragMode = MapLeftClickDragMode.Disabled; } } } protected override InteractiveResult MouseMoveCore(InteractionArguments interactionArguments) { if (mode == Mode.TrackZoomIn && UnsafeHelper.IsKeyPressed(LeftClickDragKey)) { double mapResolution = (double)interactionArguments.MapWidth / interactionArguments.MapHeight; double height = Math.Abs(startPoint.Y - interactionArguments.WorldY); if (startPoint.X > interactionArguments.WorldX) interactionArguments.WorldX = startPoint.X - height * mapResolution; else interactionArguments.WorldX = startPoint.X + height * mapResolution; } return base.MouseMoveCore(interactionArguments); } protected override InteractiveResult MouseDownCore(InteractionArguments interactionArguments) { startPoint.X = interactionArguments.WorldX; startPoint.Y = interactionArguments.WorldY; InteractiveResult result = base.MouseDownCore(interactionArguments); if (mode == Mode.TrackZoomIn) PanAndTrackZoomState.IsLeftClickDragKeyPressed = true; return result; } public enum Mode { TrackZoomIn, Pan }; } }
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("TrackZoomInWithShiftSample")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("TrackZoomInWithShiftSample")] [assembly: AssemblyCopyright("Copyright © 2015")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("86ce57c1-2148-4e0d-8568-1a9b582a7cd5")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace TrackZoomInWithShiftSample.Properties { using System; /// <summary> /// A strongly-typed resource class, for looking up localized strings, etc. /// </summary> // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// <summary> /// Returns the cached ResourceManager instance used by this class. /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager ("TrackZoomInWithShiftSample.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } /// <summary> /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } } }
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace TrackZoomInWithShiftSample.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); public static Settings Default { get { return defaultInstance; } } } }