using System; using System.Drawing; using System.Windows.Forms; using ThinkGeo.MapSuite.Core; namespace CSSampleApps { public class DisplayShapeMap : UserControl { private MapEngine mapEngine; private Bitmap bitmap; private PointStyle pointStyle; public DisplayShapeMap() { InitializeComponent(); // pointStyle = new PointStyle(PointSymbolType.Square, new GeoSolidBrush(GeoColor.FromArgb(100, 0, 255, 0)), 40); pointStyle = new PointStyle(new GeoImage(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 3.0 (Beta)\Samples\CSharp Samples\theme\default\samplepic\USA.jpg")); map.MouseClick += new MouseEventHandler(map_MouseClick); } void map_MouseClick(object sender, MouseEventArgs e) { pointStyle.RotationAngle += 45; DrawPointShape(); } private void DisplayMap_Load(object sender, EventArgs e) { bitmap = new Bitmap(map.Width, map.Height); mapEngine = new MapEngine(); mapEngine.CurrentExtent = ExtentHelper.GetDrawingExtent(new RectangleShape(-180.0, 83.0, 180.0, -90.0), map.Width, map.Height); mapEngine.BackgroundFillBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); ShapeFileLayer worldLayer = new ShapeFileLayer(@"..\..\SampleData\Data\Countries02.shp"); worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1; worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; mapEngine.StaticLayers.Add("WorldLayer", worldLayer); DrawImage(); DrawPointShape(); } private void DrawPointShape() { mapEngine.StaticLayers[0].Open(); PointShape pointShape = mapEngine.StaticLayers[0].GetBoundingBox().GetCenterPoint(); mapEngine.StaticLayers[0].Close(); Feature feature = new Feature(pointShape); InMemoryLayer inMemoryLayer = new InMemoryLayer(new FeatureSourceColumn[] { }, new Feature[]{feature}); inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = pointStyle; inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; mapEngine.DynamicLayers.Add(inMemoryLayer); mapEngine.OpenAllLayers(); mapEngine.DrawDynamicLayers(bitmap, GeographyUnit.DecimalDegree); mapEngine.CloseAllLayers(); map.Image = bitmap; } private void DrawImage() { mapEngine.OpenAllLayers(); mapEngine.DrawStaticLayers(bitmap, GeographyUnit.DecimalDegree); mapEngine.CloseAllLayers(); map.Image = bitmap; } #region Component Designer generated code private PictureBox map; private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (bitmap != null) { bitmap.Dispose(); } if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.map = new System.Windows.Forms.PictureBox(); ((System.ComponentModel.ISupportInitialize)(this.map)).BeginInit(); this.SuspendLayout(); // // map // this.map.Dock = System.Windows.Forms.DockStyle.Fill; this.map.Location = new System.Drawing.Point(0, 0); this.map.Name = "map"; this.map.Size = new System.Drawing.Size(740, 528); this.map.TabIndex = 0; this.map.TabStop = false; // // DisplayShapeMap // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.map); this.Name = "DisplayShapeMap"; this.Size = new System.Drawing.Size(740, 528); this.Load += new System.EventHandler(this.DisplayMap_Load); ((System.ComponentModel.ISupportInitialize)(this.map)).EndInit(); this.ResumeLayout(false); } #endregion } }