Table of Contents

Source Code DesktopEditionSample MapSuiteExplorer CS 100923.zip

BuildIndexTool.cs

 using System;  
 using System.Collections.ObjectModel;  
 using System.Drawing;  
 using System.Windows.Forms;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace MapSuiteExplorer  
 {  
     public partial class BuildIndexTool : Form  
     {  
         private Collection<string> files;  
 
         public Collection<string> Files  
         {  
             get { return files; }  
         }  
 
         public BuildIndexTool()  
             : this(new Collection<string>())  
         {  
         }  
 
         internal BuildIndexTool(Collection<string> buildIndexFiles)  
         {  
             files = buildIndexFiles;  
             InitializeComponent();  
         }  
 
         private void btnCancel_Click(object sender, EventArgs e)  
         {  
             Close();  
         }  
 
         private void ProgressBar_Load(object sender, EventArgs e)  
         {  
             this.Size = new Size(this.Size.Width, 50);  
 
             progressBar1.Minimum = 1;  
             progressBar1.Maximum = files.Count;  
             progressBar1.Value = 1;  
             progressBar1.Step = 1;  
         }  
 
         private void BuildIndexTool_Shown(object sender, EventArgs e)  
         {  
             BuildIndex();  
             Close();  
         }  
 
         private void BuildIndex()  
         {  
             if (files != null)  
             {  
                 for (int i = 0; i < files.Count; i++)  
                 {  
                     ShapeFileFeatureLayer.BuildIndexFile(files[i], BuildIndexMode.Rebuild);  
                     progressBar1.PerformStep();  
                 }  
             }  
         }  
     }  
 }  
 

ExplorerHelper.cs

 using System;  
 using System.Collections.Generic;  
 using System.Text;  
 using ThinkGeo.MapSuite.Core;  
 using System.Collections.ObjectModel;  
 
 namespace MapSuiteExplorer  
 {  
     internal static class ExplorerHelper  
     {  
         public static void SetStyleByWellKnownType(FeatureLayer layer)  
         {  
             if (layer.Name.IndexOf("thinkgeo", StringComparison.OrdinalIgnoreCase) != -1)  
             {  
                 layer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(GetRandomColor(ColorType.Bright), 1));  
                 layer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(190, GetRandomColor(ColorType.All))), new GeoPen(GeoColor.StandardColors.Black), 9);  
                 layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.StandardColors.Black, 1), new GeoSolidBrush(new GeoColor(65, GetRandomColor(ColorType.All))));  
                 return;  
             }  
 
             layer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.SimpleColors.Black, 1);  
             layer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.SimpleColors.Black), 9);  
             layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen = new GeoPen(GeoColor.SimpleColors.Black, 1);  
         }  
 
         public static GeoColor GetRandomColor(ColorType ColorType)  
         {  
             GeoColor randomColor = new GeoColor();  
             Random random = new Random();  
             int Number = random.Next(0, 10);  
 
             switch (ColorType)  
             {  
                 case ColorType.All:  
                     {  
                         int R = random.Next(0, 255);  
                         int G = random.Next(0, 255);  
                         int B = random.Next(0, 255);  
                         randomColor = GeoColor.FromArgb(255, R, G, B);  
                     }  
                     break;  
                 case ColorType.Bright:  
                     {  
                         GeoColor[] Colors = new GeoColor[10];  
                         Colors[0] = GeoColor.StandardColors.Blue;  
                         Colors[1] = GeoColor.StandardColors.Green;  
                         Colors[2] = GeoColor.StandardColors.Red;  
                         Colors[3] = GeoColor.StandardColors.Orange;  
                         Colors[4] = GeoColor.StandardColors.Magenta;  
                         Colors[5] = GeoColor.StandardColors.LimeGreen;  
                         Colors[6] = GeoColor.StandardColors.Brown;  
                         Colors[7] = GeoColor.StandardColors.Yellow;  
                         Colors[8] = GeoColor.StandardColors.Purple;  
                         Colors[9] = GeoColor.StandardColors.Maroon;  
 
                         randomColor = Colors[Number];  
                     }  
                     break;  
                 case ColorType.Pastel:  
                     {  
                         GeoColor[] Colors = new GeoColor[10];  
                         Colors[0] = GeoColor.StandardColors.LightBlue;  
                         Colors[1] = GeoColor.StandardColors.LightCoral;  
                         Colors[2] = GeoColor.StandardColors.LightCyan;  
                         Colors[3] = GeoColor.StandardColors.LightGreen;  
                         Colors[4] = GeoColor.StandardColors.LightGoldenrodYellow;  
                         Colors[5] = GeoColor.StandardColors.LightSkyBlue;  
                         Colors[6] = GeoColor.StandardColors.LightSteelBlue;  
                         Colors[7] = GeoColor.StandardColors.LightPink;  
                         Colors[8] = GeoColor.StandardColors.LightSalmon;  
                         Colors[9] = GeoColor.StandardColors.LightSeaGreen;  
 
                         randomColor = Colors[Number];  
                     }  
                     break;  
             }  
             return randomColor;  
         }  
 
         public static string[] GetColumnNames(FeatureLayer layer)  
         {  
             layer.FeatureSource.Open();  
 
             List<string> columnNameList = new List<string>();  
             Collection<FeatureSourceColumn> columns = layer.FeatureSource.GetColumns();  
             foreach (FeatureSourceColumn myColumn in columns)  
             {  
                 columnNameList.Add(myColumn.ColumnName);  
             }  
 
             layer.FeatureSource.Close();  
 
             return columnNameList.ToArray();  
         }  
 
         public static bool IsRasterLayerFile(string filename)  
         {  
             bool result = false;  
             string upperFilename = filename.ToUpperInvariant();  
 
             if (upperFilename.EndsWith(".SID", StringComparison.OrdinalIgnoreCase)  
                 || upperFilename.EndsWith(".ECW", StringComparison.OrdinalIgnoreCase)  
                 || upperFilename.EndsWith(".JP2", StringComparison.OrdinalIgnoreCase)  
                 || upperFilename.EndsWith(".JPEG", StringComparison.OrdinalIgnoreCase)  
                 || upperFilename.EndsWith(".JPG", StringComparison.OrdinalIgnoreCase)  
                 || upperFilename.EndsWith(".GIF", StringComparison.OrdinalIgnoreCase)  
                 || upperFilename.EndsWith(".TIF", StringComparison.OrdinalIgnoreCase)  
                 || upperFilename.EndsWith(".TIFF", StringComparison.OrdinalIgnoreCase)  
                 || upperFilename.EndsWith(".BMP", StringComparison.OrdinalIgnoreCase))  
             {  
                 result = true;  
             }  
 
             return result;  
         }  
 
         public static bool ValidateRasterLayer(RasterLayer rasterLayer)  
         {  
             bool isValidate = true;  
 
             try  
             {  
                 rasterLayer.Open();  
             }  
             catch (Exception)  
             {  
                 isValidate = false;  
             }  
             finally  
             {  
                 if (rasterLayer.IsOpen)  
                 {  
                     rasterLayer.Close();  
                 }  
             }  
 
             return isValidate;  
         }  
     }  
 }  
 

FormAbout.cs

 //<%STEMCELL:PerDirectoryNoticeText%>  
 //ALL RIGHTS RESERVED:  
 //====================  
 //The contents of this file, and associated files in this directory, are  
 //Copyright (C) ThinkGeo,LLC , all rights reserved, 2003-2006.  
 //  
 //All software Source Code, Images, Database-Design and code, Graphics Design  
 //and source files, and related content (collectively referred to as SOURCE) are  
 //Copyright (c) ThinkGeo,LLC, 2003-2006, All Rights Reserved.  
 //ThinkGeo,LLC is a USA corporation at 1617 St. Andrews Dr.Suite 201,Lawrence,  
 //KS 66047.  
 //http://ThinkGeo.com  
 //  
 //MapSuiteĀ® is a Registered Trademark of ThinkGeo,LLC.  
 //</%STEMCELL:PerDirectoryNoticeText%>  
 namespace MapSuiteExplorer  
 {  
     internal class FormAbout : System.Windows.Forms.Form  
     {  
 
         #region " Windows Form Designer generated code "  
 
         internal FormAbout()  
             : base()  
         {  
 
             //This call is required by the Windows Form Designer.  
             InitializeComponent();  
 
             //Add any initialization after the InitializeComponent() call  
 
         }  
 
         //Form overrides dispose to clean up the component list.  
         protected override void Dispose(bool disposing)  
         {  
             if (disposing)  
             {  
                 if ((components != null))  
                 {  
                     components.Dispose();  
                 }  
             }  
             base.Dispose(disposing);  
         }  
 
         //Required by the Windows Form Designer  
         private System.ComponentModel.IContainer components = null;  
 
         //NOTE: The following procedure is required by the Windows Form Designer  
         //It can be modified using the Windows Form Designer.  
         //Do not modify it using the code editor.  
         internal System.Windows.Forms.Button btnOK;  
         internal System.Windows.Forms.Label lblCopyright;  
         internal System.Windows.Forms.PictureBox pbxLogo;  
         internal System.Windows.Forms.Label lblProduct;  
         [System.Diagnostics.DebuggerStepThrough()]  
         private void InitializeComponent()  
         {  
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormAbout));  
             this.btnOK = new System.Windows.Forms.Button();  
             this.lblCopyright = new System.Windows.Forms.Label();  
             this.lblProduct = new System.Windows.Forms.Label();  
             this.pbxLogo = new System.Windows.Forms.PictureBox();  
             ((System.ComponentModel.ISupportInitialize)(this.pbxLogo)).BeginInit();  
             this.SuspendLayout();  
             //  
             // btnOK  
             //  
             this.btnOK.DialogResult = System.Windows.Forms.DialogResult.Cancel;  
             this.btnOK.Location = new System.Drawing.Point(152, 167);  
             this.btnOK.Name = "btnOK";  
             this.btnOK.Size = new System.Drawing.Size(96, 24);  
             this.btnOK.TabIndex = 0;  
             this.btnOK.Text = "&OK";  
             this.btnOK.Click += new System.EventHandler(this.btnOK_Click);  
             //  
             // lblCopyright  
             //  
             this.lblCopyright.AutoSize = true;  
             this.lblCopyright.Location = new System.Drawing.Point(104, 126);  
             this.lblCopyright.Name = "lblCopyright";  
             this.lblCopyright.Size = new System.Drawing.Size(177, 13);  
             this.lblCopyright.TabIndex = 2;  
             this.lblCopyright.Text = Properties.Resources.CopyRight;  
             //  
             // lblProduct  
             //  
             this.lblProduct.AutoSize = true;  
             this.lblProduct.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));  
             this.lblProduct.Location = new System.Drawing.Point(112, 85);  
             this.lblProduct.Name = "lblProduct";  
             this.lblProduct.Size = new System.Drawing.Size(191, 20);  
             this.lblProduct.TabIndex = 3;  
             this.lblProduct.Text = "Map Suite Explorer 3.0";  
             //  
             // pbxLogo  
             //  
             this.pbxLogo.Image = ((System.Drawing.Image)(resources.GetObject("pbxLogo.Image")));  
             this.pbxLogo.Location = new System.Drawing.Point(8, 8);  
             this.pbxLogo.Name = "pbxLogo";  
             this.pbxLogo.Size = new System.Drawing.Size(392, 64);  
             this.pbxLogo.TabIndex = 4;  
             this.pbxLogo.TabStop = false;  
             //  
             // FormAbout  
             //  
             this.AcceptButton = this.btnOK;  
             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);  
             this.CancelButton = this.btnOK;  
             this.ClientSize = new System.Drawing.Size(408, 206);  
             this.ControlBox = false;  
             this.Controls.Add(this.pbxLogo);  
             this.Controls.Add(this.lblProduct);  
             this.Controls.Add(this.lblCopyright);  
             this.Controls.Add(this.btnOK);  
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;  
             this.MaximizeBox = false;  
             this.MinimizeBox = false;  
             this.Name = "FormAbout";  
             this.ShowInTaskbar = false;  
             this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;  
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;  
             this.Text = "About Map Suite Explorer";  
             ((System.ComponentModel.ISupportInitialize)(this.pbxLogo)).EndInit();  
             this.ResumeLayout(false);  
             this.PerformLayout();  
 
         }  
 
         #endregion  
 
         private void btnOK_Click(object sender, System.EventArgs e)  
         {  
             this.Close();  
         }  
 
     }  
 }

FormFeatures.cs

 using System;  
 using System.Data;  
 using System.Windows.Forms;  
 
 using ThinkGeo.MapSuite.Core;  
 
 namespace MapSuiteExplorer  
 {  
     public partial class FormFeatures : Form  
     {  
         private string tableName;  
         private FeatureLayer shapeFileLayer;  
 
         public string TableName  
         {  
             get { return tableName; }  
             set { tableName = value; }  
         }  
 
         public FeatureLayer ShapeFileLayer  
         {  
             get { return shapeFileLayer; }  
             set { shapeFileLayer = value; }  
         }  
 
         public FormFeatures()  
         {  
             InitializeComponent();  
         }  
 
         private void frmFeatures_Load(object sender, EventArgs e)  
         {  
             this.Text = "Features - " + shapeFileLayer.Name;  
 
             dgridFeatures.DataSource = null;  
             this.txtSql.Text = "Select TOP 100 * From " + TableName;  
             ExecuteSql();  
         }  
 
         private void btnExecuteSql_Click(object sender, EventArgs e)  
         {  
             ExecuteSql();  
         }  
 
         private void ExecuteSql()  
         {  
             try  
             {  
                 shapeFileLayer.Open();  
                 DataTable dataTable = shapeFileLayer.QueryTools.ExecuteQuery(txtSql.Text);  
 
                 dgridFeatures.DataSource = dataTable;  
             }  
             catch (Exception ex)  
             {  
                 MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);  
             }  
             finally  
             {  
                 if (shapeFileLayer.IsOpen)  
                 {  
                     shapeFileLayer.Close();  
                 }  
             }  
         }  
     }  
 }  
 

FormInformation.cs

 using System.Collections.ObjectModel;  
 using System.Windows.Forms;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace MapSuiteExplorer  
 {  
     public partial class FormInformation : Form  
     {  
         private Collection<Feature> featuresInfo;  
 
         public Collection<Feature> FeaturesInfo  
         {  
             get { return featuresInfo; }  
         }  
 
         public FormInformation()  
             : this(new Collection<Feature>())  
         {  
         }  
 
         public FormInformation(Collection<Feature> featuresInfo)  
         {  
             this.featuresInfo = featuresInfo;  
             InitializeComponent();  
         }  
 
         private void btnOK_Click(object sender, System.EventArgs e)  
         {  
             Close();  
         }  
 
         private void lstSelectedItems_SelectedIndexChanged(object sender, System.EventArgs e)  
         {  
             lstAssociatedData.Items.Clear();  
 
             foreach (string key in featuresInfo[this.lstSelectedItems.SelectedIndex].ColumnValues.Keys)  
             {  
                 lstAssociatedData.Items.Add(key + ": " + featuresInfo[lstSelectedItems.SelectedIndex].ColumnValues[key]);  
             }  
         }  
 
         private void frmInformation_Load(object sender, System.EventArgs e)  
         {  
             lstSelectedItems.Items.Clear();  
 
             for (int i = 0; i < featuresInfo.Count; i++)  
             {  
                 lstSelectedItems.Items.Add(FeaturesInfo[i].Tag + " - " + FeaturesInfo[i].Id);  
             }  
 
             lstSelectedItems.SelectedIndex = 0;  
         }  
     }  
 }

FormStyleEditor.cs

 using System;  
 using System.Windows.Forms;  
 
 using ThinkGeo.MapSuite.Core;  
 using System.Collections.Generic;  
 using System.Collections.ObjectModel;  
 
 namespace MapSuiteExplorer  
 {  
     internal partial class FormStyleEditor : Form  
     {  
         private StyleEditor styleEditor;  
         private FeatureLayer baseLayer;  
         private StyleType currentStyleType;  
 
         internal FeatureLayer BaseLayer  
         {  
             get { return baseLayer; }  
             set { baseLayer = value; }  
         }  
 
         internal StyleType CurrentStyleType  
         {  
             get { return currentStyleType; }  
             set { currentStyleType = value; }  
         }  
 
         internal string[] ColumnNames  
         {  
             get;  
             set;  
         }  
 
         internal FormStyleEditor()  
         {  
             InitializeComponent();  
         }  
 
         private void frmStyleEditor_Load(object sender, EventArgs e)  
         {  
             this.Text = "Style Editor - " + baseLayer.Name;  
 
             styleEditor = new StyleEditor();  
             styleEditor.ColumnNames = ColumnNames;  
             styleEditor.AreaStyle = BaseLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle;  
             styleEditor.LineStyle = BaseLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle;  
             styleEditor.PointStyle = BaseLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle;  
             styleEditor.TextStyle = BaseLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle;  
 
             switch (currentStyleType)  
             {  
                 case StyleType.Area:  
                     tabControl1.SelectedTab = tabPageAreaStyle;  
                     break;  
                 case StyleType.Line:  
                     tabControl1.SelectedTab = tabPageLineStyle;  
                     break;  
                 case StyleType.Point:  
                     tabControl1.SelectedTab = tabPagePointStyle;  
                     break;  
                 case StyleType.Text:  
                     tabControl1.SelectedTab = tabPageTextStyle;  
                     break;  
                 case StyleType.Custom:  
                     break;  
                 default:  
                     break;  
             }  
         }  
 
         private void tabPageAreaStyle_Enter(object sender, EventArgs e)  
         {  
             styleEditor.StyleType = StyleType.Area;  
             if (!tabPageAreaStyle.Controls.Contains(styleEditor))  
             {  
                 tabPageAreaStyle.Controls.Add(styleEditor);  
             }  
         }  
 
         private void tabPageLineStyle_Enter(object sender, EventArgs e)  
         {  
             styleEditor.StyleType = StyleType.Line;  
             if (!tabPageLineStyle.Controls.Contains(styleEditor))  
             {  
                 tabPageLineStyle.Controls.Add(styleEditor);  
             }  
         }  
 
         private void tabPagePointStyle_Enter(object sender, EventArgs e)  
         {  
             styleEditor.StyleType = StyleType.Point;  
             if (!tabPagePointStyle.Controls.Contains(styleEditor))  
             {  
                 tabPagePointStyle.Controls.Add(styleEditor);  
             }  
         }  
 
         private void tabPageTextStyle_Enter(object sender, EventArgs e)  
         {  
             styleEditor.StyleType = StyleType.Text;  
             if (!tabPageTextStyle.Controls.Contains(styleEditor))  
             {  
                 tabPageTextStyle.Controls.Add(styleEditor);  
             }  
         }  
 
         private void btnOk_Click(object sender, EventArgs e)  
         {  
             currentStyleType = styleEditor.StyleType;  
             Close();  
         }  
 
         private void btnCancel_Click(object sender, EventArgs e)  
         {  
             Close();  
         }  
 
         public void SetLayerStyleType(FeatureLayer layer, StyleType layerStyleType)  
         {  
             layer.FeatureSource.Open();  
             if (layerStyleType == StyleType.Text)  
             {  
                 List<string> columnNameList = new List<string>();  
                 Collection<FeatureSourceColumn> columns = layer.FeatureSource.GetColumns();  
                 foreach (FeatureSourceColumn myColumn in columns)  
                 {  
                     columnNameList.Add(myColumn.ColumnName);  
                 }  
                 this.CurrentStyleType = StyleType.Text;  
                 this.ColumnNames = columnNameList.ToArray();  
             }  
             else  
             {  
                 Feature firstFeature = layer.FeatureSource.GetFeatureById("1", ReturningColumnsType.AllColumns);  
                 BaseShape shape = firstFeature.GetShape();  
                 if (shape is LineBaseShape)  
                 {  
                     this.CurrentStyleType = StyleType.Line;  
                 }  
                 else if (shape is PointBaseShape)  
                 {  
                     this.CurrentStyleType = StyleType.Point;  
                 }  
                 else if (shape is AreaBaseShape)  
                 {  
                     this.CurrentStyleType = StyleType.Area;  
                 }  
             }  
             layer.FeatureSource.Close();  
         }  
     }  
 }  
 

GeographyUnitTool.cs

 using System;  
 using System.Windows.Forms;  
 
 using ThinkGeo.MapSuite.Core;  
 
 namespace MapSuiteExplorer  
 {  
     public partial class GeographyUnitTool : Form  
     {  
         private GeographyUnit currentUnit;  
 
         public GeographyUnit CurrentUnit  
         {  
             get { return currentUnit; }  
             set { currentUnit = value; }  
         }  
 
         public GeographyUnitTool()  
         {  
             InitializeComponent();  
         }  
 
         private void GeographyUnitTool_Load(object sender, EventArgs e)  
         {  
             comboBox1.Text = currentUnit.ToString();  
         }  
 
         private void btnSetUnit_Click(object sender, EventArgs e)  
         {  
             switch (comboBox1.Text)  
             {  
                 case "Unknown":  
                     currentUnit = GeographyUnit.Unknown;  
                     break;  
                 case "DecimalDegree":  
                     currentUnit = GeographyUnit.DecimalDegree;  
                     break;  
                 case "Feet":  
                     currentUnit = GeographyUnit.Feet;  
                     break;  
                 case "Meter":  
                     currentUnit = GeographyUnit.Meter;  
                     break;  
                 default:  
                     break;  
             }  
             Close();  
         }  
     }  
 }  
 

GlobalSuppressions.cs

 [assembly:|System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Scope = "type", Target = "MapSuiteExplorer.MainForm")]  
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "MapSuiteExplorer.MainForm.#AddLayers(System.String[],System.Boolean)")]  
 [assembly:|System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "MapSuiteExplorer.MainForm.#DrawImage()")]  
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "MapSuiteExplorer.MainForm.#SelectInformation(ThinkGeo.MapSuite.Core.PointShape)")]  
 [assembly:|System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "MapSuiteExplorer.MainForm.#themeItem_ItemCheckedChanged(System.Object,MapSuiteExplorer.ShapeEventArgs)")]  
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Scope = "member", Target = "MapSuiteExplorer.MyAreaStyle.#GetGeoCustomStyle(ThinkGeo.MapSuite.Core.GeoHatchBrush)")]  
 [assembly:|System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1701:ResourceStringCompoundWordsShouldBeCasedCorrectly", MessageId = "checkbox", Scope = "resource", Target = "MapSuiteExplorer.Properties.Resources.resources")]  
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", MessageId = "forumid", Scope = "resource", Target = "MapSuiteExplorer.Properties.Resources.resources")]  
 [assembly:|System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", MessageId = "gis", Scope = "resource", Target = "MapSuiteExplorer.Properties.Resources.resources")]  
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", MessageId = "shp", Scope = "resource", Target = "MapSuiteExplorer.Properties.Resources.resources")]  
 [assembly:|System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", MessageId = "tabid", Scope = "resource", Target = "MapSuiteExplorer.Properties.Resources.resources")]  
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "MapSuiteExplorer.FormFeatures.#ExecuteSql()")]  
 

MainForm.cs

 using System;  
 using System.Collections.ObjectModel;  
 using System.Drawing;  
 using System.Globalization;  
 using System.IO;  
 using System.Runtime.Serialization.Formatters.Binary;  
 using System.Windows.Forms;  
 
 using ThinkGeo.MapSuite.Core;  
 using System.Collections.Generic;  
 using System.Diagnostics;  
 using ThinkGeo.MapSuite.DesktopEdition;  
 using System.Threading;  
 
 namespace MapSuiteExplorer  
 {  
     internal partial class MainForm : Form  
     {  
         private const int splitterDistance = 142;  
         private const int widthOfThemeView = 140;  
 
         private FormFeatures frmFeatures;  
         // set selected themeItem which will move up/down  
         private int selectedOrder = -1;  
         private Collection<string> filesWithoutIndex;  
         private Collection<string> addedFiles;  
         private Int32 id = 100;// HotKey id  
         private const int WM_HOTKEY = 0x0312;// HotKey message  
 
         internal MainForm()  
         {  
             InitializeComponent();  
         }  
 
         private void MainForm_Load(object sender, EventArgs e)  
         {  
             filesWithoutIndex = new Collection<string>();  
             addedFiles = new Collection<string>();  
 
             winformsMap1.MapUnit = GeographyUnit.DecimalDegree;  
             winformsMap1.CurrentExtent = new RectangleShape(-90, 45, 90, -45);  
             winformsMap1.MouseMove += new MouseEventHandler(winformsMap1_MouseMove);  
             winformsMap1.MapClick += new EventHandler<MapClickWinformsMapEventArgs>(winformsMap1_MapClick);  
             this.themeView.ThemeViewDragDrop += new EventHandler<DragDropItemEventArgs>(themeView_ThemeViewDragDrop);  
             this.themeView.VScrollVisible += new EventHandler<EventArgs>(themeView_VScrollVisible);  
 
             RegHotkey();  
 
             SetupContextMenu();  
 
             winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.White);  
 
             SetScaleLineAdornment();  
 
             winformsMap1.Overlays.Add(new LayerOverlay());  
         }  
 
         private void MainForm_FormClosing(object sender, FormClosingEventArgs e)  
         {  
             UnRegHotKey();  
         }  
 
         private void MainForm_DragEnter(object sender, DragEventArgs e)  
         {  
             e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? e.Effect = DragDropEffects.All : DragDropEffects.None;  
         }  
 
         private void MainForm_DragDrop(object sender, DragEventArgs e)  
         {  
             string[] draggedPaths = (string[])e.Data.GetData(DataFormats.FileDrop);  
             if ((draggedPaths != null) && (draggedPaths.Length > 0))  
             {  
                 filesWithoutIndex.Clear();  
                 addedFiles.Clear();  
 
                 foreach (string draggedPath in draggedPaths)  
                 {  
                     if (draggedPath.EndsWith(".shp", StringComparison.OrdinalIgnoreCase) && File.Exists(draggedPath))  
                     {  
                         AddShapeFileFeatureLayers(new string[] { draggedPath });  
                     }  
                     else if (ExplorerHelper.IsRasterLayerFile(draggedPath) && File.Exists(draggedPath))  
                     {  
                         AddRasterLayers(new string[] { draggedPath });  
                     }  
                     else if (Directory.Exists(draggedPath))  
                     {  
                         AddLayersByFolder(draggedPath);  
                     }  
                 }  
 
                 if (filesWithoutIndex.Count > 0)  
                 {  
                     CancelAddingLayer();  
                 }  
 
                 SetCurrentExtent();  
 
                 themeView.SetupItems();  
                 DrawImage();  
             }  
         }  
 
         private void winformsMap1_MouseMove(object sender, MouseEventArgs e)  
         {  
             if (((LayerOverlay)winformsMap1.Overlays[0]).Layers.Count > 0)  
             {  
                 ShowCoordinate(e);  
             }  
         }  
 
         private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e)  
         {  
             if (tbnInformation.Checked)  
             {  
                 SelectInformation(e.WorldLocation);  
             }  
         }  
 
         private void mnuHelpAbout_Click(object sender, EventArgs e)  
         {  
             FormAbout frmAbout = new FormAbout();  
             frmAbout.ShowDialog();  
         }  
 
         private void mnuHelpDiscussionForums_Click(object sender, EventArgs e)  
         {  
             System.Diagnostics.Process.Start(Properties.Resources.DiscussionForum);  
         }  
 
         private void themeItem_ThemeItemClick(object sender, LayerOrderEventArgs e)  
         {  
             for (int i = 0; i < themeView.Items.Count; i++)  
             {  
                 if (e.Name == themeView.Items[i].ShapeName)  
                 {  
                     selectedOrder = i;  
                     themeView.Items[i].BorderStyle = BorderStyle.Fixed3D;  
                     themeView.Items[i].BackColor = Color.FromArgb(100, 74, 142, 207);  
                 }  
                 else  
                 {  
                     themeView.Items[i].BorderStyle = BorderStyle.FixedSingle;  
                     themeView.Items[i].BackColor = Color.White;  
                 }  
             }  
         }  
 
         private void themeItem_ItemLinkClicked(object sender, ShapeLinkClickedEventArgs e)  
         {  
             switch (e.LinkType)  
             {  
                 case LinkType.Edit:  
                     if (((LayerOverlay)winformsMap1.Overlays[0]).Layers.Contains(e.ShapeName))  
                     {  
                         EditLayerStyle(((LayerOverlay)winformsMap1.Overlays[0]).Layers[e.ShapeName] as FeatureLayer);  
                     }  
                     break;  
                 case LinkType.Features:  
                     if (((LayerOverlay)winformsMap1.Overlays[0]).Layers.Contains(e.ShapeName))  
                     {  
                         ShowAllFeatures(((LayerOverlay)winformsMap1.Overlays[0]).Layers[e.ShapeName] as FeatureLayer);  
                     }  
                     break;  
                 case LinkType.Remove:  
                     if (MessageBox.Show(string.Format(CultureInfo.InvariantCulture, Properties.Resources.RemoveLayerPrompt, e.ShapeName), "Remove Layer", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0) == DialogResult.Yes)  
                     {  
                         RemoveShapefile(e.ShapeName);  
                     }  
                     break;  
                 case LinkType.ZoomToExtent:  
                     if (((LayerOverlay)winformsMap1.Overlays[0]).Layers.Contains(e.ShapeName))  
                     {  
                         TrackToExtent(((LayerOverlay)winformsMap1.Overlays[0]).Layers[e.ShapeName]);  
                     }  
                     break;  
                 default:  
                     break;  
             }  
         }  
 
         private void themeItem_ItemCheckedChanged(object sender, ShapeEventArgs e)  
         {  
             if (((LayerOverlay)winformsMap1.Overlays[0]).Layers.Contains(e.ShapeName))  
             {  
                 winformsMap1.Overlays[0].Lock.EnterWriteLock();  
                 try  
                 {  
                     ((LayerOverlay)winformsMap1.Overlays[0]).Layers[e.ShapeName].IsVisible = e.IsShow;  
                 }  
                 finally  
                 {  
                     winformsMap1.Overlays[0].Lock.ExitWriteLock();  
                 }  
                 try  
                 {  
                     DrawImage();  
                 }  
                 catch  
                 {  
                 }  
             }  
         }  
 
         private void mnuFileAddNewLayer_Click(object sender, EventArgs e)  
         {  
             AddLayersByOpenFileDialog();  
         }  
 
         private void mnuRemoveAll_Click(object sender, EventArgs e)  
         {  
             RemoveAllShapefiles();  
         }  
 
         private void mnuFileExit_Click(object sender, EventArgs e)  
         {  
             Close();  
         }  
 
         private void MenuItem_Click(object sender, EventArgs e)  
         {  
             ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem;  
 
             if (toolStripMenuItem != null)  
             {  
                 Action(toolStripMenuItem.Tag.ToString());  
             }  
         }  
 
         private void ToolBar_ItemClicked(object sender, ToolStripItemClickedEventArgs e)  
         {  
             ToolStripButton button = e.ClickedItem as ToolStripButton;  
             if (button != null)  
             {  
                 Action(button.Tag.ToString());  
             }  
         }  
 
         private void themeView_ThemeViewDragDrop(object sender, DragDropItemEventArgs e)  
         {  
             winformsMap1.Overlays[0].Lock.EnterWriteLock();  
             try  
             {  
                 ((LayerOverlay)winformsMap1.Overlays[0]).Layers.MoveTo(e.FromOrder, e.ToOrder);  
             }  
             finally  
             {  
                 winformsMap1.Overlays[0].Lock.ExitWriteLock();  
             }  
             winformsMap1.Refresh();  
 
             selectedOrder = e.ToOrder;  
         }  
 
         private void themeView_VScrollVisible(object sender, EventArgs e)  
         {  
             if (themeView.VerticalScroll.Visible)  
             {  
                 splitContainer.SplitterDistance = splitterDistance + 16;  
                 themeView.Width = widthOfThemeView + 16;  
             }  
             else  
             {  
                 splitContainer.SplitterDistance = splitterDistance;  
                 themeView.Width = widthOfThemeView;  
             }  
         }  
 
         private void themeItem_ThemeItemRightClick(object sender, RightClickEventArgs e)  
         {  
             contextMenuStrip.Show(e.Point);  
         }  
 
         protected override void WndProc(ref Message m)  
         {  
             if (m.Msg == WM_HOTKEY)  
             {  
                 DoHotkey(m);  
             }  
             base.WndProc(ref m);  
         }  
 
         private void DoHotkey(Message m)  
         {  
             IntPtr i = m.WParam;  
             if (i.ToInt32() == id)  
             {  
                 GeographyUnitTool geographyUnitTool = new GeographyUnitTool();  
                 geographyUnitTool.CurrentUnit = winformsMap1.MapUnit;  
                 geographyUnitTool.ShowDialog();  
                 if (winformsMap1.MapUnit != geographyUnitTool.CurrentUnit)  
                 {  
                     winformsMap1.Refresh();  
                 }  
             }  
         }  
 
         private RectangleShape GetFullExtent(float screenWidth, float screenHeight)  
         {  
             RectangleShape boundingBox = null;  
 
             foreach (Layer layer in ((LayerOverlay)winformsMap1.Overlays[0]).Layers)  
             {  
                 if (layer.HasBoundingBox)  
                 {  
                     if (!layer.IsOpen) { layer.Open(); }  
                     if (boundingBox == null)  
                     {  
                         boundingBox = layer.GetBoundingBox();  
                     }  
                     else  
                     {  
                         boundingBox.ExpandToInclude(layer.GetBoundingBox());  
                     }  
                 }  
             }  
 
             if (boundingBox != null)  
             {  
                 boundingBox = MapEngine.GetDrawingExtent(boundingBox, screenWidth, screenHeight);  
             }  
 
             return boundingBox;  
         }  
 
         private void RegHotkey()  
         {  
             id = this.GetType().GetHashCode();  
 
             //0 is none,1 is Alt,2 is Control,4 is Shift,8 is Windows  
             NativeMethods.RegisterHotKey(this.Handle, id, 7, Keys.D8);//Ctrl+Shift+Alt+8  
         }  
 
         private void UnRegHotKey()  
         {  
             NativeMethods.UnregisterHotKey(this.Handle, id);  
         }  
 
         private void ShowCoordinate(MouseEventArgs e)  
         {  
             PointShape WorldPointR = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, e.X, e.Y, winformsMap1.Width, winformsMap1.Height);  
             statusStrip.Items[1].Text = string.Format(CultureInfo.InvariantCulture, "X: {0:F4} Y: {1:F4}", WorldPointR.X, WorldPointR.Y);  
             statusStrip.Items[2].Text = string.Format(CultureInfo.InvariantCulture, "X: {0} Y: {1}", e.X, e.Y);  
 
             if (winformsMap1.MapUnit == GeographyUnit.DecimalDegree && ((WorldPointR.X > -180 && WorldPointR.X < 180 && WorldPointR.Y > -90 && WorldPointR.Y < 90)))  
             {  
                 statusStrip.Items[0].Text = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegreePoint(WorldPointR);  
                 return;  
             }  
 
             statusStrip.Items[0].Text = "";  
         }  
 
         private void SetBackgroudColor()  
         {  
             if (colorDialog.ShowDialog() == DialogResult.OK)  
             {  
                 GeoColor geocolor = new GeoColor(colorDialog.Color.R, colorDialog.Color.G, colorDialog.Color.B);  
                 winformsMap1.BackgroundOverlay.Lock.EnterWriteLock();  
                 try  
                 {  
                     winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(geocolor);  
                 }  
                 finally  
                 {  
                     winformsMap1.BackgroundOverlay.Lock.ExitWriteLock();  
                 }  
                 winformsMap1.Refresh();  
             }  
         }  
 
         private void SetCurrentExtent()  
         {  
             if (((LayerOverlay)winformsMap1.Overlays[0]).Layers.Count == 1)  
             {  
                 RectangleShape currentBoundingBox = GetFullExtent(winformsMap1.Width, winformsMap1.Height);  
                 if (currentBoundingBox != null)  
                 {  
                     winformsMap1.CurrentExtent = currentBoundingBox;  
                 }  
             }  
         }  
 
         private void SetScaleLineAdornment()  
         {  
             ScaleLineAdornmentLayer scaleLine = new ScaleLineAdornmentLayer(AdornmentLocation.LowerLeft);  
             scaleLine.XOffsetInPixel = 5;  
             scaleLine.YOffsetInPixel = -5;  
 
             winformsMap1.AdornmentOverlay.Layers.Add("ScaleLine", scaleLine);  
         }  
 
         private void SetupContextMenu()  
         {  
             foreach (ToolStripItem item in mnuCurrentLayer.DropDownItems)  
             {  
                 if (item is ToolStripSeparator)  
                 {  
                     contextMenuStrip.Items.Add(new ToolStripSeparator());  
                 }  
                 else  
                 {  
                     ToolStripItem contextItem = new ToolStripMenuItem(item.Text, item.Image);  
                     contextItem.Tag = item.Tag;  
                     contextItem.Click += new EventHandler(MenuItem_Click);  
                     contextMenuStrip.Items.Add(contextItem);  
                 }  
             }  
         }  
 
         /// <summary>  
         /// Cancel Adding Layer or not  
         /// </summary>  
         /// <returns>  
         /// true: Cancel  
         /// false: Yes,No  
         /// </returns>  
         private void CancelAddingLayer()  
         {  
             string buildIndexMessage = string.Format(Properties.Resources.BuildIndexFilePrompt, filesWithoutIndex[0]);  
             DialogResult result = MessageBox.Show(buildIndexMessage, "Build Index File", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);  
             Application.DoEvents();  
             switch (result)  
             {  
                 case DialogResult.Cancel:  
                     foreach (string fileName in addedFiles)  
                     {  
                         string shapeName = new FileInfo(fileName).Name;  
                         winformsMap1.Overlays[0].Lock.EnterWriteLock();  
                         try  
                         {  
                             ((LayerOverlay)winformsMap1.Overlays[0]).Layers.Remove(shapeName);  
                         }  
                         finally  
                         {  
                             winformsMap1.Overlays[0].Lock.ExitWriteLock();  
                         }  
                         if (themeView.Items.Contains(shapeName))  
                         {  
                             themeView.Items.Remove(shapeName);  
                         }  
                     }  
                     themeView.SetupItems();  
                     break;  
                 case DialogResult.Yes:  
                 case DialogResult.OK:  
                     BuildIndexTool buildIndexTool = new BuildIndexTool(filesWithoutIndex);  
                     buildIndexTool.ShowDialog();  
                     break;  
                 default:  
                     break;  
             }  
         }  
 
         private void SetupThemeItem(Layer layer)  
         {  
             ThemeItem themeItem = new ThemeItem();  
 
             themeItem.ShapeName = layer.Name;  
 
             themeItem.ItemCheckedChanged += new EventHandler<ShapeEventArgs>(themeItem_ItemCheckedChanged);  
             themeItem.ItemLinkClicked += new EventHandler<ShapeLinkClickedEventArgs>(themeItem_ItemLinkClicked);  
             themeItem.ThemeItemClick += new EventHandler<LayerOrderEventArgs>(themeItem_ThemeItemClick);  
             themeItem.ThemeItemRightClick += new EventHandler<RightClickEventArgs>(themeItem_ThemeItemRightClick);  
 
             themeView.Items.Add(layer.Name, themeItem);  
         }  
 
         private void TrackToExtent(Layer layer)  
         {  
             layer.Open();  
             RectangleShape extent = layer.GetBoundingBox();  
             layer.Close();  
 
             winformsMap1.CurrentExtent = ExtentHelper.GetDrawingExtent(extent, winformsMap1.Width, winformsMap1.Height);  
 
             winformsMap1.Refresh();  
         }  
 
         private void EditLayerStyle(FeatureLayer layer)  
         {  
             if (layer != null)  
             {  
                 FormStyleEditor frmStyleEditor = new FormStyleEditor();  
 
                 frmStyleEditor.CurrentStyleType = themeView.Items[selectedOrder].StyleType;  
                 frmStyleEditor.ColumnNames = ExplorerHelper.GetColumnNames(layer);  
 
                 frmStyleEditor.BaseLayer = layer;  
 
                 // store layer status and will recover it after serialize/deserialize  
                 bool isOpened = layer.IsOpen;  
                 // close layer to avoid serialize exception  
                 layer.Close();  
 
                 //  clone layer  
                 Layer clonedLayer = layer.CloneDeep();  
 
                 DialogResult isStyleChanged;  
                 winformsMap1.Overlays[0].Lock.EnterWriteLock();  
                 try  
                 {  
                     isStyleChanged = frmStyleEditor.ShowDialog();  
                 }  
                 finally  
                 {  
                     winformsMap1.Overlays[0].Lock.ExitWriteLock();  
                 }  
                 if (isStyleChanged == DialogResult.OK)  
                 {  
                     themeView.Items[selectedOrder].StyleType = frmStyleEditor.CurrentStyleType;  
                     winformsMap1.Refresh();  
                 }  
                 else  
                 {  
                     // because user cancel modify style, so restore layer  
                     ((LayerOverlay)winformsMap1.Overlays[0]).Layers[selectedOrder] = clonedLayer;  
                 }  
 
                 // recover layer status  
                 if (isOpened) { layer.Open(); }  
             }  
         }  
 
         private void ShowAllFeatures(FeatureLayer layer)  
         {  
             if (layer != null)  
             {  
                 if (frmFeatures == null)  
                 {  
                     frmFeatures = new FormFeatures();  
                 }  
 
                 frmFeatures.TableName = Path.GetFileNameWithoutExtension(layer.Name);  
                 frmFeatures.ShapeFileLayer = layer;  
                 frmFeatures.ShowDialog();  
             }  
         }  
 
         private void RemoveShapefile(string shapeName)  
         {  
             for (int i = 0; i < themeView.Items.Count; i++)  
             {  
                 if (shapeName == themeView.Items[i].ShapeName)  
                 {  
                     if (selectedOrder == i)  
                     {  
                         selectedOrder = -1;  
                     }  
                     break;  
                 }  
             }  
 
             winformsMap1.Overlays[0].Lock.EnterWriteLock();  
             try  
             {  
                 ((LayerOverlay)winformsMap1.Overlays[0]).Layers.Remove(shapeName);  
             }  
             finally  
             {  
                 winformsMap1.Overlays[0].Lock.ExitWriteLock();  
             }  
 
             if (themeView.Items.Contains(shapeName))  
             {  
                 themeView.Items.Remove(shapeName);  
                 themeView.SetupItems();  
             }  
 
             winformsMap1.Refresh();  
         }  
 
         private void RemoveAllShapefiles()  
         {  
             if (MessageBox.Show(Properties.Resources.RemoveAllLayerPrompt, "Remove All Layers", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0) == DialogResult.Yes)  
             {  
                 selectedOrder = -1;  
                 winformsMap1.Overlays[0].Lock.EnterWriteLock();  
                 try  
                 {  
                     ((LayerOverlay)winformsMap1.Overlays[0]).Layers.Clear();  
                 }  
                 finally  
                 {  
                     winformsMap1.Overlays[0].Lock.ExitWriteLock();  
                 }  
                 themeView.Items.Clear();  
                 themeView.SetupItems();  
 
                 winformsMap1.Refresh();  
             }  
         }  
 
         private void RemoveShapefile(FileNotFoundException ex)  
         {  
             MessageBox.Show(ex.Message + "\r\n" + ex.FileName, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);  
             string shapeName = new FileInfo(Path.ChangeExtension(ex.FileName, ".shp")).Name;  
             winformsMap1.Overlays[0].Lock.EnterWriteLock();  
             try  
             {  
                 ((LayerOverlay)winformsMap1.Overlays[0]).Layers.Remove(shapeName);  
             }  
             finally  
             {  
                 winformsMap1.Overlays[0].Lock.ExitWriteLock();  
             }  
             if (themeView.Items.Contains(shapeName))  
             {  
                 themeView.Items.Remove(shapeName);  
                 themeView.SetupItems();  
             }  
         }  
 
         private void SelectInformation(PointShape worldPoint)  
         {  
             try  
             {  
                 Collection<Feature> selectedFeatures = new Collection<Feature>();  
 
                 foreach (Layer layer in ((LayerOverlay)winformsMap1.Overlays[0]).Layers)  
                 {  
                     FeatureLayer featureLayer = layer as FeatureLayer;  
                     if (featureLayer != null)  
                     {  
                         featureLayer.Open();  
                         Collection<Feature> nearestFeatures = featureLayer.QueryTools.GetFeaturesNearestTo(worldPoint, winformsMap1.MapUnit, 1, ReturningColumnsType.AllColumns);  
                         double radius = 10.0 / winformsMap1.Width * winformsMap1.CurrentExtent.Width;  
                         EllipseShape searchingEllipse = new EllipseShape(worldPoint, radius, radius);  
 
                         foreach (Feature feature in nearestFeatures)  
                         {  
                             Feature selectedFeature = feature;  
                             selectedFeature.Tag = featureLayer.Name;  
 
                             BaseShape currentShape = feature.GetShape();  
 
                             if (currentShape is AreaBaseShape)  
                             {  
                                 if (currentShape.Contains(worldPoint))  
                                 {  
                                     selectedFeatures.Add(selectedFeature);  
                                 }  
                             }  
                             else if (currentShape is LineBaseShape)  
                             {  
                                 if (currentShape.Intersects(searchingEllipse))  
                                 {  
                                     selectedFeatures.Add(selectedFeature);  
                                 }  
                             }  
                             else if (currentShape is PointBaseShape)  
                             {  
                                 if (searchingEllipse.Contains(currentShape))  
                                 {  
                                     selectedFeatures.Add(selectedFeature);  
                                 }  
                             }  
                         }  
                         featureLayer.Close();  
                     }  
                 }  
 
                 if (selectedFeatures.Count > 0)  
                 {  
                     FormInformation frmInformation = new FormInformation(selectedFeatures);  
                     frmInformation.ShowDialog();  
                 }  
             }  
             catch (Exception ex)  
             {  
                 MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);  
             }  
         }  
 
         private void Action(string tag)  
         {  
             switch (tag)  
             {  
                 case "Add New Layer":  
                     AddLayersByOpenFileDialog();  
                     break;  
                 case "Add Folder":  
                     AddLayersByFolderBrowserDialog();  
                     break;  
                 case "Backgroud Color":  
                     SetBackgroudColor();  
                     break;  
                 case "Information":  
                     tbnInformation.Checked = !tbnInformation.Checked;  
                     mnuToolsInformation.Checked = tbnInformation.Checked;  
                     break;  
                 default:  
                     OperateMap(tag);  
                     break;  
             }  
         }  
 
         private void OperateMap(string tag)  
         {  
             if (((LayerOverlay)winformsMap1.Overlays[0]).Layers.Count > 0)  
             {  
                 bool needRefresh = true;  
                 switch (tag)  
                 {  
                     case "Zoom In":  
                         winformsMap1.ZoomIn(50);  
                         break;  
                     case "Zoom Out":  
                         winformsMap1.ZoomOut(50);  
                         break;  
                     case "Full Extent":  
                         winformsMap1.CurrentExtent = GetFullExtent(winformsMap1.Width, winformsMap1.Height);  
                         break;  
                     case "Toggle Extent":  
                         winformsMap1.ToggleMapExtents();  
                         break;  
                     case "Previous Extent":  
                         winformsMap1.ZoomToPreviousExtent();  
                         break;  
                     case "Pan Left":  
                         winformsMap1.Pan(PanDirection.Left, 20);  
                         break;  
                     case "Pan Right":  
                         winformsMap1.Pan(PanDirection.Right, 20);  
                         break;  
                     case "Pan Up":  
                         winformsMap1.Pan(PanDirection.Up, 20);  
                         break;  
                     case "Pan Down":  
                         winformsMap1.Pan(PanDirection.Down, 20);  
                         break;  
                     default:  
                         needRefresh = false;  
                         OperateLayer(tag);  
                         break;  
                 }  
 
                 if (needRefresh)  
                 {  
                     winformsMap1.Refresh();  
                 }  
             }  
         }  
 
         private void OperateLayer(string tag)  
         {  
             if (selectedOrder == -1)  
             {  
                 MessageBox.Show(Properties.Resources.NoLayerSelected, "No Layer Selected", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);  
                 return;  
             }  
 
             switch (tag)  
             {  
                 case "Move Up":  
                     MoveUpDown(MoveType.MoveUp);  
                     break;  
                 case "Move Down":  
                     MoveUpDown(MoveType.MoveDown);  
                     break;  
                 case "Move To Top":  
                     MoveUpDown(MoveType.MoveToTop);  
                     break;  
                 case "Move To Bottom":  
                     MoveUpDown(MoveType.MoveToBottom);  
                     break;  
                 case "Track To Extent":  
                     TrackToExtent(((LayerOverlay)winformsMap1.Overlays[0]).Layers[selectedOrder]);  
                     break;  
                 case "Change The Style":  
                     EditLayerStyle(((LayerOverlay)winformsMap1.Overlays[0]).Layers[selectedOrder] as FeatureLayer);  
                     break;  
                 case "Show Features":  
                     ShowAllFeatures(((LayerOverlay)winformsMap1.Overlays[0]).Layers[selectedOrder] as FeatureLayer);  
                     break;  
                 default:  
                     break;  
             }  
         }  
 
         // use OpenFileDialog  
         private void AddLayersByOpenFileDialog()  
         {  
             if (openFileDialog.ShowDialog() == DialogResult.OK)  
             {  
                 filesWithoutIndex.Clear();  
                 addedFiles.Clear();  
 
                 Collection<string> rasterFilenames = new Collection<string>();  
                 Collection<string> featureFilenames = new Collection<string>();  
 
                 foreach (string filename in openFileDialog.FileNames)  
                 {  
                     if (ExplorerHelper.IsRasterLayerFile(filename))  
                     {  
                         rasterFilenames.Add(filename);  
                     }  
                     else  
                     {  
                         featureFilenames.Add(filename);  
                     }  
                 }  
 
                 AddShapeFileFeatureLayers(featureFilenames);  
                 AddRasterLayers(rasterFilenames);  
 
                 if (filesWithoutIndex.Count > 0)  
                 {  
                     CancelAddingLayer();  
                 }  
 
                 SetCurrentExtent();  
 
                 themeView.SetupItems();  
 
                 DrawImage();  
             }  
         }  
 
         private void AddLayersByFolderBrowserDialog()  
         {  
             if (folderBrowserDialog.ShowDialog() == DialogResult.OK)  
             {  
                 if (Directory.Exists(folderBrowserDialog.SelectedPath))  
                 {  
                     filesWithoutIndex.Clear();  
                     addedFiles.Clear();  
 
                     AddLayersByFolder(folderBrowserDialog.SelectedPath);  
                 }  
 
                 if (filesWithoutIndex.Count > 0)  
                 {  
                     CancelAddingLayer();  
                 }  
 
                 SetCurrentExtent();  
 
                 themeView.SetupItems();  
 
                 DrawImage();  
             }  
         }  
 
         private void AddShapeFileFeatureLayers(IEnumerable<string> fileNames)  
         {  
             foreach (string fileName in fileNames)  
             {  
                 try  
                 {  
                     string layerName = new FileInfo(fileName).Name;  
                     if (!((LayerOverlay)winformsMap1.Overlays[0]).Layers.Contains(layerName))  
                     {  
                         ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer(fileName);  
                         layer.Name = layerName;  
                         ExplorerHelper.SetStyleByWellKnownType(layer);  
                         layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
                         winformsMap1.Overlays[0].Lock.EnterWriteLock();  
                         try  
                         {  
                             ((LayerOverlay)winformsMap1.Overlays[0]).Layers.Add(layerName, layer);  
                         }  
                         finally  
                         {  
                             winformsMap1.Overlays[0].Lock.ExitWriteLock();  
                         }  
 
                         SetupThemeItem(layer);  
 
                         if ((!File.Exists(layer.IndexPathFileName)) || (!File.Exists(layer.IndexPathFileName.ToUpper().Replace(".IDX", ".IDS"))))  
                         {  
                             filesWithoutIndex.Add(fileName);  
                         }  
                         addedFiles.Add(fileName);  
                     }  
                 }  
                 catch (FileLoadException fle)  
                 {  
                     RemoveShapefile((FileNotFoundException)fle.InnerException);  
                 }  
                 catch (Exception ex)  
                 {  
                     MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);  
                 }  
             }  
         }  
 
         private void AddRasterLayers(IEnumerable<string> fileNames)  
         {  
             foreach (string fileName in fileNames)  
             {  
                 try  
                 {  
                     string layerName = new FileInfo(fileName).Name;  
 
                     if (!((LayerOverlay)winformsMap1.Overlays[0]).Layers.Contains(layerName))  
                     {  
                         RasterLayer rasterLayer = null;  
                         switch (Path.GetExtension(fileName).ToUpperInvariant())  
                         {  
                             case ".SID":  
                                 rasterLayer = new MrSidRasterLayer(fileName);  
                                 break;  
                             case ".ECW":  
                                 rasterLayer = new EcwRasterLayer(fileName);  
                                 break;  
                             case ".JP2":  
                                 rasterLayer = new Jpeg2000RasterLayer(fileName);  
                                 break;  
                             case ".BMP":  
                             case ".JPG":  
                             case ".JPEG":  
                             case ".GIF":  
                             case ".TIFF":  
                             case ".TIF":  
                                 rasterLayer = new GdiPlusRasterLayer(fileName);  
                                 break;  
                             default:  
                                 break;  
                         }  
 
                         if (rasterLayer != null && ExplorerHelper.ValidateRasterLayer(rasterLayer))  
                         {  
                             rasterLayer.Name = layerName;  
                             winformsMap1.Overlays[0].Lock.EnterWriteLock();  
                             try  
                             {  
                                 ((LayerOverlay)winformsMap1.Overlays[0]).Layers.Add(layerName, rasterLayer);  
                             }  
                             finally  
                             {  
                                 winformsMap1.Overlays[0].Lock.ExitWriteLock();  
                             }  
                             SetupThemeItem(rasterLayer);  
                         }  
                     }  
                 }  
                 catch (Exception ex)  
                 {  
                     MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);  
                 }  
             }  
         }  
 
         private void MoveUpDown(MoveType moveType)  
         {  
             switch (moveType)  
             {  
                 case MoveType.MoveUp:  
                     if (selectedOrder != themeView.Items.Count - 1)  
                     {  
                         themeView.Items.MoveUp(selectedOrder);  
                         winformsMap1.Overlays[0].Lock.EnterWriteLock();  
                         try  
                         {  
                             ((LayerOverlay)winformsMap1.Overlays[0]).Layers.MoveUp(selectedOrder);  
                         }  
                         finally  
                         {  
                             winformsMap1.Overlays[0].Lock.ExitWriteLock();  
                         }  
                         selectedOrder++;  
                     }  
                     break;  
                 case MoveType.MoveDown:  
                     if (selectedOrder != 0)  
                     {  
                         themeView.Items.MoveDown(selectedOrder);  
                         winformsMap1.Overlays[0].Lock.EnterWriteLock();  
                         try  
                         {  
                             ((LayerOverlay)winformsMap1.Overlays[0]).Layers.MoveDown(selectedOrder);  
                         }  
                         finally  
                         {  
                             winformsMap1.Overlays[0].Lock.ExitWriteLock();  
                         }  
                         selectedOrder--;  
                     }  
                     break;  
                 case MoveType.MoveToTop:  
                     if (selectedOrder != themeView.Items.Count - 1)  
                     {  
                         themeView.Items.MoveToTop(selectedOrder);  
                         winformsMap1.Overlays[0].Lock.EnterWriteLock();  
                         try  
                         {  
                             ((LayerOverlay)winformsMap1.Overlays[0]).Layers.MoveToTop(selectedOrder);  
                         }  
                         finally  
                         {  
                             winformsMap1.Overlays[0].Lock.ExitWriteLock();  
                         }  
                         selectedOrder = themeView.Items.Count - 1;  
                     }  
                     break;  
                 case MoveType.MoveToBottom:  
                     if (selectedOrder != 0)  
                     {  
                         themeView.Items.MoveToBottom(selectedOrder);  
                         winformsMap1.Overlays[0].Lock.EnterWriteLock();  
                         try  
                         {  
                             ((LayerOverlay)winformsMap1.Overlays[0]).Layers.MoveToBottom(selectedOrder);  
                         }  
                         finally  
                         {  
                             winformsMap1.Overlays[0].Lock.ExitWriteLock();  
                         }  
                         selectedOrder = 0;  
                     }  
                     break;  
                 default:  
                     break;  
             }  
 
             themeView.SetupItems();  
 
             winformsMap1.Refresh();  
         }  
 
         private void DrawImage()  
         {  
             try  
             {  
                 winformsMap1.Refresh();  
             }  
             catch (FileLoadException fileLoadException)  
             {  
                 RemoveShapefile((FileNotFoundException)fileLoadException.InnerException);  
             }  
             catch (Exception ex)  
             {  
                 foreach (ThemeItem themeItem in themeView.Items)  
                 {  
                     themeItem.IsShow = false;  
                 }  
                 MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);  
                 return;  
             }  
         }  
 
         private void AddLayersByFolder(string folderName)  
         {  
             string[] fileNames = Directory.GetFiles(folderName, "*.*", SearchOption.AllDirectories);  
 
             Collection<string> rasterFilenames = new Collection<string>();  
             Collection<string> featureFilenames = new Collection<string>();  
 
             foreach (string filename in fileNames)  
             {  
                 if (ExplorerHelper.IsRasterLayerFile(filename))  
                 {  
                     rasterFilenames.Add(filename);  
                 }  
                 else if (filename.ToUpperInvariant().Contains(".SHP"))  
                 {  
                     featureFilenames.Add(filename);  
                 }  
             }  
 
             AddShapeFileFeatureLayers(featureFilenames);  
             AddRasterLayers(rasterFilenames);  
         }  
     }  
 }  
 

NativeMethods.cs

 using System;  
 using System.Runtime.InteropServices;  
 using System.Windows.Forms;  
 
 namespace MapSuiteExplorer  
 {  
     internal static class NativeMethods  
     {  
         [DllImport("user32.dll")]  
         [return:|MarshalAs(UnmanagedType.Bool)]  
         internal static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, Keys vk);  
 
         [DllImport("user32.dll")]  
         [return:|MarshalAs(UnmanagedType.Bool)]  
         internal static extern bool UnregisterHotKey(IntPtr hWnd, int id);  
     }  
 }  
 

Program.cs

 using System;  
 using System.Collections.Generic;  
 
 using System.Windows.Forms;  
 
 namespace MapSuiteExplorer  
 {  
     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());  
         }  
     }  
 }  
 

ThemeItem.cs

 using System;  
 using System.Windows.Forms;  
 
 namespace MapSuiteExplorer  
 {  
     public partial class ThemeItem : UserControl  
     {  
         internal event EventHandler<ShapeEventArgs> ItemCheckedChanged;  
         internal event EventHandler<ShapeLinkClickedEventArgs> ItemLinkClicked;  
         internal event EventHandler<LayerOrderEventArgs> ThemeItemClick;  
         internal event EventHandler<RightClickEventArgs> ThemeItemRightClick;  
 
         private StyleType styleType;  
         private bool isShow = true;  
 
         public StyleType StyleType  
         {  
             get { return styleType; }  
             set { styleType = value; }  
         }  
 
         public bool IsShow  
         {  
             get { return isShow; }  
             set  
             {  
                 isShow = value;  
                 cbxItem.Checked = IsShow;  
             }  
         }  
 
         public string ShapeName  
         {  
             get { return cbxItem.Text; }  
             set { cbxItem.Text = value; }  
         }  
 
         public ThemeItem()  
         {  
             InitializeComponent();  
             ToolTip tooTip = new ToolTip();  
             tooTip.SetToolTip(this.btnRemove, "Remove");  
             tooTip.SetToolTip(this, Properties.Resources.ThemeItemToolTip);  
             tooTip.SetToolTip(this.cbxItem, Properties.Resources.ThemeItemCheckBoxToolTip);  
         }  
 
         private void cbxItem_CheckedChanged(object sender, EventArgs e)  
         {  
             if (string.IsNullOrEmpty(cbxItem.Text))  
             {  
                 throw new ArgumentException(Properties.Resources.ShapeNameCheck);  
             }  
             OnItemCheckedChanged(new ShapeEventArgs(cbxItem.Text, cbxItem.Checked));  
         }  
 
         private void ThemeItem_Click(object sender, EventArgs e)  
         {  
             OnThemeItemClick(new LayerOrderEventArgs(this.cbxItem.Text));  
         }  
 
         private void pnlTitle_MouseDown(object sender, MouseEventArgs e)  
         {  
             OnThemeItemClick(new LayerOrderEventArgs(this.cbxItem.Text));  
             DoDragDrop(this, DragDropEffects.Move);  
         }  
 
         private void btnRemove_Click(object sender, EventArgs e)  
         {  
             OnItemLinkClicked(new ShapeLinkClickedEventArgs(cbxItem.Text, LinkType.Remove));  
         }  
 
         private void ThemeItem_MouseDoubleClick(object sender, MouseEventArgs e)  
         {  
             if (e.Button == MouseButtons.Left)  
             {  
                 OnItemLinkClicked(new ShapeLinkClickedEventArgs(cbxItem.Text, LinkType.Edit));  
             }  
         }  
 
         private void ThemeItem_MouseClick(object sender, MouseEventArgs e)  
         {  
             if (e.Button == MouseButtons.Right)  
             {  
                 OnThemeItemRightClick(new RightClickEventArgs(PointToScreen(e.Location)));  
             }  
         }  
 
         protected virtual void OnItemCheckedChanged(ShapeEventArgs e)  
         {  
             EventHandler<ShapeEventArgs> handler = ItemCheckedChanged;  
             if (handler != null)  
             {  
                 handler(this, e);  
             }  
         }  
 
         protected virtual void OnThemeItemClick(LayerOrderEventArgs e)  
         {  
             EventHandler<LayerOrderEventArgs> handler = ThemeItemClick;  
             if (handler != null)  
             {  
                 handler(this, e);  
             }  
         }  
 
         protected virtual void OnItemLinkClicked(ShapeLinkClickedEventArgs e)  
         {  
             EventHandler<ShapeLinkClickedEventArgs> handler = ItemLinkClicked;  
             if (handler != null)  
             {  
                 handler(this, e);  
             }  
         }  
 
         protected virtual void OnThemeItemRightClick(RightClickEventArgs e)  
         {  
             EventHandler<RightClickEventArgs> handler = ThemeItemRightClick;  
             if (handler != null)  
             {  
                 handler(this, e);  
             }  
         }  
     }  
 }  
 

ThemeView.cs

 using System;  
 using System.ComponentModel;  
 using System.Drawing;  
 using System.Windows.Forms;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace MapSuiteExplorer  
 {  
     public partial class ThemeView : UserControl  
     {  
         internal event EventHandler<DragDropItemEventArgs> ThemeViewDragDrop;  
         internal event EventHandler<EventArgs> VScrollVisible;  
 
         private bool isVScrollVisible;  
         private bool scrollBarWidthNeedtoChange;  
         private GeoCollection<ThemeItem> items;  
 
         public GeoCollection<ThemeItem> Items  
         {  
             get { return items; }  
         }  
 
         public ThemeView()  
         {  
             items = new GeoCollection<ThemeItem>();  
             InitializeComponent();  
         }  
 
         internal void SetupItems()  
         {  
             scrollBarWidthNeedtoChange = false;  
 
             this.Controls.Clear();  
             int height = 0;  
 
             for (int i = items.Count - 1; i >= 0; i--)  
             {  
                 items[i].Location = new Point(0, height);  
                 this.Controls.Add(items[i]);  
 
                 height += 60;  
             }  
 
             scrollBarWidthNeedtoChange = true;  
         }  
 
         private void ThemeView_DragEnter(object sender, DragEventArgs e)  
         {  
             if (e.Data.GetDataPresent(typeof(ThemeItem)))  
             {  
                 e.Effect = DragDropEffects.Move;  
             }  
         }  
 
         private void ThemeView_DragDrop(object sender, DragEventArgs e)  
         {  
             // find which theme item be draged  
             ThemeItem currentItem = (ThemeItem)(e.Data.GetData(typeof(ThemeItem)));  
 
             int selectedOrder = GetSelectedOrder(currentItem.ShapeName);  
 
             // find mainform  
             Control control = this;  
             while (control.Parent != null)  
             {  
                 control = control.Parent;  
             }  
 
             // 70 is toolStrip and menu's height  
             int yOffset = (e.Y - control.Location.Y - 70) - currentItem.Location.Y;  
 
             int remainder = yOffset % currentItem.Height;  
             int divider = yOffset / currentItem.Height;  
             int oneThirdHeight = currentItem.Height / 3;  
 
             if (divider < 0 || (remainder > oneThirdHeight && divider > 0))  
             {  
                 DoDragDropItem(selectedOrder, selectedOrder - divider);  
                 return;  
             }  
             if (divider > 1 || (remainder < -oneThirdHeight && divider <= 0))  
             {  
                 DoDragDropItem(selectedOrder, selectedOrder - divider + 1);  
                 return;  
             }  
         }  
 
         private void DoDragDropItem(int from, int to)  
         {  
             items.MoveTo(from, to);  
             OnThemeViewDragDrop(new DragDropItemEventArgs(from, to));  
             SetupItems();  
         }  
 
         private int GetSelectedOrder(string shapeName)  
         {  
             int selectedOrder = -1;  
             for (int i = items.Count - 1; i >= 0; i--)  
             {  
                 if (shapeName == this.Items[i].ShapeName)  
                 {  
                     selectedOrder = i;  
                     break;  
                 }  
             }  
             return selectedOrder;  
         }  
 
         private void ThemeView_Paint(object sender, PaintEventArgs e)  
         {  
             if (isVScrollVisible != VerticalScroll.Visible)  
             {  
                 isVScrollVisible = VerticalScroll.Visible;  
                 OnVScrollVisible(new EventArgs());  
             }  
         }  
 
         protected virtual void OnThemeViewDragDrop(DragDropItemEventArgs e)  
         {  
             EventHandler<DragDropItemEventArgs> handler = ThemeViewDragDrop;  
             if (handler != null)  
             {  
                 handler(this, e);  
             }  
         }  
 
         protected virtual void OnVScrollVisible(EventArgs e)  
         {  
             EventHandler<EventArgs> handler = VScrollVisible;  
             if (handler != null)  
             {  
                 handler(this, e);  
             }  
         }  
 
         protected override void OnPaint(PaintEventArgs e)  
         {  
             if (scrollBarWidthNeedtoChange)  
             {  
                 base.OnPaint(e);  
             }  
         }  
     }  
 }  
 

ColorType.cs

 namespace MapSuiteExplorer  
 {  
     public enum ColorType  
     {  
         All = 0,  
         Pastel = 1,  
         Bright = 2  
     }  
 }  
 

GeoCustomStyle.cs

 namespace MapSuiteExplorer  
 {  
     public enum GeoCustomStyle  
     {  
         /// <summary>A Horizontal pattern fill.</summary>  
         Horizontal = 0,  
         /// <summary>A Vertical pattern fill.</summary>  
         Vertical = 1,  
         /// <summary>A Forward Diagonal pattern fill.</summary>  
         ForwardDiagonal = 2,  
         /// <summary>A Backward Diagonal pattern fill.</summary>  
         BackwardDiagonal = 3,  
         /// <summary>A Large Grid pattern fill.</summary>  
         LargeGrid = 4,  
         /// <summary>A Diagonal Cross pattern fill.</summary>  
         DiagonalCross = 5,  
         /// <summary>A 05 Percent pattern fill.</summary>  
         Percent05 = 6,  
         /// <summary>A 10 Percent pattern fill.</summary>  
         Percent10 = 7,  
         /// <summary>A 20 Percent pattern fill.</summary>  
         Percent20 = 8,  
         /// <summary>A 25 Percent pattern fill.</summary>  
         Percent25 = 9,  
         /// <summary>A 30 Percent pattern fill.</summary>  
         Percent30 = 10,  
         /// <summary>A 40 Percent pattern fill.</summary>  
         Percent40 = 11,  
         /// <summary>A 50 Percent pattern fill.</summary>  
         Percent50 = 12,  
         /// <summary>A 60 Percent pattern fill.</summary>  
         Percent60 = 13,  
         /// <summary>A 70 Percent pattern fill.</summary>  
         Percent70 = 14,  
         /// <summary>A 75 Percent pattern fill.</summary>  
         Percent75 = 15,  
         /// <summary>A 80 Percent pattern fill.</summary>  
         Percent80 = 16,  
         /// <summary>A 90 Percent pattern fill.</summary>  
         Percent90 = 17,  
         /// <summary>A Light Downward Diagonal pattern fill.</summary>  
         LightDownwardDiagonal = 18,  
         /// <summary>A Light Upward Diagonal pattern fill.</summary>  
         LightUpwardDiagonal = 19,  
         /// <summary>A Dark Downward Diagonal pattern fill.</summary>  
         DarkDownwardDiagonal = 20,  
         /// <summary>A Dark Upward Diagonal pattern fill.</summary>  
         DarkUpwardDiagonal = 21,  
         /// <summary>A Wide Downward Diagonal pattern fill.</summary>  
         WideDownwardDiagonal = 22,  
         /// <summary>A Wide Upward Diagonal pattern fill.</summary>  
         WideUpwardDiagonal = 23,  
         /// <summary>A Light Vertical pattern fill.</summary>  
         LightVertical = 24,  
         /// <summary>A Light Horizontal pattern fill.</summary>  
         LightHorizontal = 25,  
         /// <summary>A Narrow Vertical pattern fill.</summary>  
         NarrowVertical = 26,  
         /// <summary>A Narrow Horizontal pattern fill.</summary>  
         NarrowHorizontal = 27,  
         /// <summary>A Dark Vertical pattern fill.</summary>  
         DarkVertical = 28,  
         /// <summary>A Dark Horizontal pattern fill.</summary>  
         DarkHorizontal = 29,  
         /// <summary>A Dashed Downward Diagonal pattern fill.</summary>  
         DashedDownwardDiagonal = 30,  
         /// <summary>A Dashed Upward Diagonal pattern fill.</summary>  
         DashedUpwardDiagonal = 31,  
         /// <summary>A Dashed Horizontal pattern fill.</summary>  
         DashedHorizontal = 32,  
         /// <summary>A Dashed Vertical pattern fill.</summary>  
         DashedVertical = 33,  
         /// <summary>A Small Confetti pattern fill.</summary>  
         SmallConfetti = 34,  
         /// <summary>A Large Confetti pattern fill.</summary>  
         LargeConfetti = 35,  
         /// <summary>A Zig Zag pattern fill.</summary>  
         ZigZag = 36,  
         /// <summary>A Wave pattern fill.</summary>  
         Wave = 37,  
         /// <summary>A Diagonal Brick pattern fill.</summary>  
         DiagonalBrick = 38,  
         /// <summary>A Horizontal Brick pattern fill.</summary>  
         HorizontalBrick = 39,  
         /// <summary>A Weave pattern fill.</summary>  
         Weave = 40,  
         /// <summary>A Plaid pattern fill.</summary>  
         Plaid = 41,  
         /// <summary>A Divot pattern fill.</summary>  
         Divot = 42,  
         /// <summary>A Dotted Grid pattern fill.</summary>  
         DottedGrid = 43,  
         /// <summary>A Dotted Diamond pattern fill.</summary>  
         DottedDiamond = 44,  
         /// <summary>A Shingle pattern fill.</summary>  
         Shingle = 45,  
         /// <summary>A Trellis pattern fill.</summary>  
         Trellis = 46,  
         /// <summary>A Sphere pattern fill.</summary>  
         Sphere = 47,  
         /// <summary>A Small Grid pattern fill.</summary>  
         SmallGrid = 48,  
         /// <summary>A Small Checker Board pattern fill.</summary>  
         SmallCheckerBoard = 49,  
         /// <summary>A Large Checker Board pattern fill.</summary>  
         LargeCheckerBoard = 50,  
         /// <summary>A Outlined Diamond pattern fill.</summary>  
         OutlinedDiamond = 51,  
         /// <summary>A Solid Diamond pattern fill.</summary>  
         SolidDiamond = 52,  
         /// <summary>A Min pattern fill.</summary>  
         Min = 53,  
         /// <summary>A Max pattern fill.</summary>  
         Max = 54,  
         /// <summary>A Cross pattern fill.</summary>  
         Cross = 55,  
         /// <summary>None pattern fill.</summary>  
         None  
     }  
 }  
 

LinkType.cs

 namespace MapSuiteExplorer  
 {  
     public enum LinkType  
     {  
         Edit = 0,  
         Features = 1,  
         Remove = 2,  
         ZoomToExtent = 3  
     }  
 }  
 

MoveType.cs

 namespace MapSuiteExplorer  
 {  
     public enum MoveType  
     {  
         MoveUp = 0,  
         MoveDown = 1,  
         MoveToTop = 2,  
         MoveToBottom = 3  
     }  
 }  
 

StyleType.cs

 namespace MapSuiteExplorer  
 {  
     public enum StyleType  
     {  
         Area = 0,  
         Line = 1,  
         Point = 2,  
         Text = 3,  
         Custom = 4  
     }  
 }  
 

DragDropItemEventArgs.cs

 using System;  
 
 namespace MapSuiteExplorer  
 {  
     public class DragDropItemEventArgs : EventArgs  
     {  
         private int fromOrder;  
         private int toOrder;  
 
         public int FromOrder  
         {  
             get { return fromOrder; }  
             set { fromOrder = value; }  
         }  
 
         public int ToOrder  
         {  
             get { return toOrder; }  
             set { toOrder = value; }  
         }  
 
         public DragDropItemEventArgs(int fromOrder, int toOrder)  
         {  
             this.fromOrder = fromOrder;  
             this.toOrder = toOrder;  
         }  
     }  
 }

LayerOrderEventArgs.cs

 using System;  
 
 namespace MapSuiteExplorer  
 {  
     public class LayerOrderEventArgs : EventArgs  
     {  
         private string name;  
 
         public string Name  
         {  
             get { return name; }  
             set { name = value; }  
         }  
 
         public LayerOrderEventArgs(string name)  
         {  
             this.name = name;  
         }  
     }  
 }

RightClickEventArgs.cs

 using System;  
 using System.Drawing;  
 
 namespace MapSuiteExplorer  
 {  
     public class RightClickEventArgs : EventArgs  
     {  
         private Point point;  
 
         public Point Point  
         {  
             get { return point; }  
             set { point = value; }  
         }  
 
         public RightClickEventArgs(Point point)  
         {  
             this.point = point;  
         }  
     }  
 }  
 

ShapeEventArgs.cs

 using System;  
 
 namespace MapSuiteExplorer  
 {  
     public class ShapeEventArgs : EventArgs  
     {  
         private string shapeName;  
         private bool isShow;  
 
         public string ShapeName  
         {  
             get { return shapeName; }  
             set { shapeName = value; }  
         }  
 
         public bool IsShow  
         {  
             get { return isShow; }  
             set { isShow = value; }  
         }  
 
         public ShapeEventArgs(string shapeName, bool isShow)  
         {  
             this.shapeName = shapeName;  
             this.isShow = isShow;  
         }  
     }  
 }

ShapeLinkClickedEventArgs.cs

 using System;  
 
 namespace MapSuiteExplorer  
 {  
     public class ShapeLinkClickedEventArgs : EventArgs  
     {  
         private string shapeName;  
         private LinkType linkType;  
 
         public string ShapeName  
         {  
             get { return shapeName; }  
             set { shapeName = value; }  
         }  
 
         public LinkType LinkType  
         {  
             get { return linkType; }  
             set { linkType = value; }  
         }  
 
         public ShapeLinkClickedEventArgs(string shapeName, LinkType linkType)  
         {  
             this.linkType = linkType;  
             this.shapeName = shapeName;  
         }  
     }  
 }

MyAreaStyle.cs

 using System.ComponentModel;  
 using System.Drawing;  
 
 using ThinkGeo.MapSuite.Core;  
 
 namespace MapSuiteExplorer  
 {  
     public class MyAreaStyle  
     {  
         private AreaStyle style;  
 
         [Category("AreaStyle")]  
         [Description("The|color of outline pen.")]  
         public Color OutlineColor  
         {  
             get  
             {  
                 return Color.FromArgb(style.OutlinePen.Color.RedComponent, style.OutlinePen.Color.GreenComponent, style.OutlinePen.Color.BlueComponent);  
             }  
             set  
             {  
                 style.OutlinePen.Color = new GeoColor(value.R, value.G, value.B);  
             }  
         }  
 
         [Category("AreaStyle")]  
         [Description("The|width of outline pen.")]  
         public float OutlineThickness  
         {  
             get  
             {  
                 return style.OutlinePen.Width;  
             }  
             set  
             {  
                 style.OutlinePen.Width = value;  
             }  
         }  
 
         [Category("AreaStyle")]  
         [Description("The|color of fill solid brush.")]  
         public Color FillColor  
         {  
             get  
             {  
                 return Color.FromArgb(style.FillSolidBrush.Color.RedComponent, style.FillSolidBrush.Color.GreenComponent, style.FillSolidBrush.Color.BlueComponent);  
             }  
             set  
             {  
                 style.FillSolidBrush.Color = new GeoColor(value.R, value.G, value.B);  
             }  
         }  
 
         [Category("AreaStyle")]  
         [Description("The|alpha component of fill solid brush.")]  
         public byte Transparency  
         {  
             get  
             {  
                 return style.FillSolidBrush.Color.AlphaComponent;  
             }  
             set  
             {  
                 style.FillSolidBrush.Color = GeoColor.FromArgb(value, style.FillSolidBrush.Color);  
             }  
         }  
 
         [Category("AreaStyle")]  
         [Description("If|you don't need fill pattern, please select 'None' at the end of drop-down list")]  
         public GeoCustomStyle FillPattern  
         {  
             get  
             {  
                 GeoHatchBrush brush = null;  
                 if (style.Advanced.FillCustomBrush != null)  
                 {  
                     brush = (GeoHatchBrush)style.Advanced.FillCustomBrush;  
                     return GetGeoCustomStyle(brush);  
                 }  
 
                 return GeoCustomStyle.None;  
             }  
             set  
             {  
                 style.Advanced.FillCustomBrush = value == GeoCustomStyle.None ? null : new GeoHatchBrush((GeoHatchStyle)value, style.FillSolidBrush.Color);  
             }  
         }  
 
         public MyAreaStyle(AreaStyle style)  
         {  
             this.style = style;  
         }  
 
         private static GeoCustomStyle GetGeoCustomStyle(GeoHatchBrush geoHatchBrush)  
         {  
             GeoCustomStyle geoCustomStyle = GeoCustomStyle.None;  
             switch (geoHatchBrush.HatchStyle)  
             {  
                 case GeoHatchStyle.BackwardDiagonal:  
                     geoCustomStyle = GeoCustomStyle.BackwardDiagonal;  
                     break;  
                 case GeoHatchStyle.Cross:  
                     geoCustomStyle = GeoCustomStyle.Cross;  
                     break;  
                 case GeoHatchStyle.DarkDownwardDiagonal:  
                     geoCustomStyle = GeoCustomStyle.DarkDownwardDiagonal;  
                     break;  
                 case GeoHatchStyle.DarkHorizontal:  
                     geoCustomStyle = GeoCustomStyle.DarkHorizontal;  
                     break;  
                 case GeoHatchStyle.DarkUpwardDiagonal:  
                     geoCustomStyle = GeoCustomStyle.DarkUpwardDiagonal;  
                     break;  
                 case GeoHatchStyle.DarkVertical:  
                     geoCustomStyle = GeoCustomStyle.DarkVertical;  
                     break;  
                 case GeoHatchStyle.DashedDownwardDiagonal:  
                     geoCustomStyle = GeoCustomStyle.DashedDownwardDiagonal;  
                     break;  
                 case GeoHatchStyle.DashedHorizontal:  
                     geoCustomStyle = GeoCustomStyle.DashedHorizontal;  
                     break;  
                 case GeoHatchStyle.DashedUpwardDiagonal:  
                     geoCustomStyle = GeoCustomStyle.DashedUpwardDiagonal;  
                     break;  
                 case GeoHatchStyle.DashedVertical:  
                     geoCustomStyle = GeoCustomStyle.DashedVertical;  
                     break;  
                 case GeoHatchStyle.DiagonalBrick:  
                     geoCustomStyle = GeoCustomStyle.DiagonalBrick;  
                     break;  
                 case GeoHatchStyle.DiagonalCross:  
                     geoCustomStyle = GeoCustomStyle.DiagonalCross;  
                     break;  
                 case GeoHatchStyle.Divot:  
                     geoCustomStyle = GeoCustomStyle.Divot;  
                     break;  
                 case GeoHatchStyle.DottedDiamond:  
                     geoCustomStyle = GeoCustomStyle.DottedDiamond;  
                     break;  
                 case GeoHatchStyle.DottedGrid:  
                     geoCustomStyle = GeoCustomStyle.DottedGrid;  
                     break;  
                 case GeoHatchStyle.ForwardDiagonal:  
                     geoCustomStyle = GeoCustomStyle.ForwardDiagonal;  
                     break;  
                 case GeoHatchStyle.Horizontal:  
                     geoCustomStyle = GeoCustomStyle.Horizontal;  
                     break;  
                 case GeoHatchStyle.HorizontalBrick:  
                     geoCustomStyle = GeoCustomStyle.HorizontalBrick;  
                     break;  
                 case GeoHatchStyle.LargeCheckerBoard:  
                     geoCustomStyle = GeoCustomStyle.LargeCheckerBoard;  
                     break;  
                 case GeoHatchStyle.LargeConfetti:  
                     geoCustomStyle = GeoCustomStyle.LargeConfetti;  
                     break;  
                 case GeoHatchStyle.LargeGrid:  
                     geoCustomStyle = GeoCustomStyle.LargeGrid;  
                     break;  
                 case GeoHatchStyle.LightDownwardDiagonal:  
                     geoCustomStyle = GeoCustomStyle.LightDownwardDiagonal;  
                     break;  
                 case GeoHatchStyle.LightHorizontal:  
                     geoCustomStyle = GeoCustomStyle.LightHorizontal;  
                     break;  
                 case GeoHatchStyle.LightUpwardDiagonal:  
                     geoCustomStyle = GeoCustomStyle.LightUpwardDiagonal;  
                     break;  
                 case GeoHatchStyle.LightVertical:  
                     geoCustomStyle = GeoCustomStyle.LightVertical;  
                     break;  
                 case GeoHatchStyle.Max:  
                     geoCustomStyle = GeoCustomStyle.Max;  
                     break;  
                 case GeoHatchStyle.Min:  
                     geoCustomStyle = GeoCustomStyle.Min;  
                     break;  
                 case GeoHatchStyle.NarrowHorizontal:  
                     geoCustomStyle = GeoCustomStyle.NarrowHorizontal;  
                     break;  
                 case GeoHatchStyle.NarrowVertical:  
                     geoCustomStyle = GeoCustomStyle.NarrowVertical;  
                     break;  
                 case GeoHatchStyle.OutlinedDiamond:  
                     geoCustomStyle = GeoCustomStyle.OutlinedDiamond;  
                     break;  
                 case GeoHatchStyle.Percent05:  
                     geoCustomStyle = GeoCustomStyle.Percent05;  
                     break;  
                 case GeoHatchStyle.Percent10:  
                     geoCustomStyle = GeoCustomStyle.Percent10;  
                     break;  
                 case GeoHatchStyle.Percent20:  
                     geoCustomStyle = GeoCustomStyle.Percent20;  
                     break;  
                 case GeoHatchStyle.Percent25:  
                     geoCustomStyle = GeoCustomStyle.Percent25;  
                     break;  
                 case GeoHatchStyle.Percent30:  
                     geoCustomStyle = GeoCustomStyle.Percent30;  
                     break;  
                 case GeoHatchStyle.Percent40:  
                     geoCustomStyle = GeoCustomStyle.Percent40;  
                     break;  
                 case GeoHatchStyle.Percent50:  
                     geoCustomStyle = GeoCustomStyle.Percent50;  
                     break;  
                 case GeoHatchStyle.Percent60:  
                     geoCustomStyle = GeoCustomStyle.Percent60;  
                     break;  
                 case GeoHatchStyle.Percent70:  
                     geoCustomStyle = GeoCustomStyle.Percent70;  
                     break;  
                 case GeoHatchStyle.Percent75:  
                     geoCustomStyle = GeoCustomStyle.Percent75;  
                     break;  
                 case GeoHatchStyle.Percent80:  
                     geoCustomStyle = GeoCustomStyle.Percent80;  
                     break;  
                 case GeoHatchStyle.Percent90:  
                     geoCustomStyle = GeoCustomStyle.Percent90;  
                     break;  
                 case GeoHatchStyle.Plaid:  
                     geoCustomStyle = GeoCustomStyle.Plaid;  
                     break;  
                 case GeoHatchStyle.Shingle:  
                     geoCustomStyle = GeoCustomStyle.Shingle;  
                     break;  
                 case GeoHatchStyle.SmallCheckerBoard:  
                     geoCustomStyle = GeoCustomStyle.SmallCheckerBoard;  
                     break;  
                 case GeoHatchStyle.SmallConfetti:  
                     geoCustomStyle = GeoCustomStyle.SmallConfetti;  
                     break;  
                 case GeoHatchStyle.SmallGrid:  
                     geoCustomStyle = GeoCustomStyle.SmallGrid;  
                     break;  
                 case GeoHatchStyle.SolidDiamond:  
                     geoCustomStyle = GeoCustomStyle.SolidDiamond;  
                     break;  
                 case GeoHatchStyle.Sphere:  
                     geoCustomStyle = GeoCustomStyle.Sphere;  
                     break;  
                 case GeoHatchStyle.Trellis:  
                     geoCustomStyle = GeoCustomStyle.Trellis;  
                     break;  
                 case GeoHatchStyle.Vertical:  
                     geoCustomStyle = GeoCustomStyle.Vertical;  
                     break;  
                 case GeoHatchStyle.Wave:  
                     geoCustomStyle = GeoCustomStyle.Wave;  
                     break;  
                 case GeoHatchStyle.Weave:  
                     geoCustomStyle = GeoCustomStyle.Weave;  
                     break;  
                 case GeoHatchStyle.WideDownwardDiagonal:  
                     geoCustomStyle = GeoCustomStyle.WideDownwardDiagonal;  
                     break;  
                 case GeoHatchStyle.WideUpwardDiagonal:  
                     geoCustomStyle = GeoCustomStyle.WideUpwardDiagonal;  
                     break;  
                 case GeoHatchStyle.ZigZag:  
                     geoCustomStyle = GeoCustomStyle.ZigZag;  
                     break;  
                 default:  
                     geoCustomStyle = GeoCustomStyle.None;  
                     break;  
             }  
             return geoCustomStyle;  
         }  
     }  
 }  
 

MyLineStyle.cs

 using System.ComponentModel;  
 using System.Drawing;  
 
 using ThinkGeo.MapSuite.Core;  
 
 namespace MapSuiteExplorer  
 {  
     public class MyLineStyle  
     {  
         private LineStyle style;  
 
         [Category("LineStyle")]  
         [Description("The|color of outer pen.")]  
         public Color LineColor  
         {  
             get { return Color.FromArgb(style.OuterPen.Color.RedComponent, style.OuterPen.Color.GreenComponent, style.OuterPen.Color.BlueComponent); }  
             set { style.OuterPen.Color = new GeoColor(value.R, value.G, value.B); }  
         }  
 
         [Category("LineStyle")]  
         [Description("The|width of outer pen.")]  
         public float LineThickness  
         {  
             get { return style.OuterPen.Width; }  
             set { style.OuterPen.Width = value; }  
         }  
 
         public MyLineStyle(LineStyle style)  
         {  
             this.style = style;  
         }  
     }  
 }  
 

MyPointStyle.cs

 using System.ComponentModel;  
 using System.Drawing;  
 
 using ThinkGeo.MapSuite.Core;  
 
 namespace MapSuiteExplorer  
 {  
     public class MyPointStyle  
     {  
         private PointStyle style;  
 
         [Category("PointStyle")]  
         [Description("The|point symbol type.")]  
         public PointSymbolType SymbolType  
         {  
             get  
             {  
                 return style.SymbolType;  
             }  
             set  
             {  
                 style.SymbolType = value;  
             }  
         }  
 
         [Category("PointStyle")]  
         [Description("The|color of symbol solid brush.")]  
         public Color FillColor  
         {  
             get  
             {  
                 return Color.FromArgb(style.SymbolSolidBrush.Color.RedComponent, style.SymbolSolidBrush.Color.GreenComponent, style.SymbolSolidBrush.Color.BlueComponent);  
             }  
             set  
             {  
                 style.SymbolSolidBrush.Color = new GeoColor(value.R, value.G, value.B);  
             }  
         }  
 
         [Category("PointStyle")]  
         [Description("The|color of symbol pen.")]  
         public Color OutlineColor  
         {  
             get  
             {  
                 return Color.FromArgb(style.SymbolPen.Color.RedComponent, style.SymbolPen.Color.GreenComponent, style.SymbolPen.Color.BlueComponent);  
             }  
             set  
             {  
                 style.SymbolPen.Color = new GeoColor(value.R, value.G, value.B);  
             }  
         }  
 
         [Category("PointStyle")]  
         [Description("The|symbol size.")]  
         public float SymbolSize  
         {  
             get  
             {  
                 return style.SymbolSize;  
             }  
             set  
             {  
                 style.SymbolSize = value;  
             }  
         }  
 
         public MyPointStyle(PointStyle style)  
         {  
             this.style = style;  
         }  
     }  
 }  
 

MyTextStyle.cs

 using System.ComponentModel;  
 using System.Drawing;  
 
 using ThinkGeo.MapSuite.Core;  
 
 namespace MapSuiteExplorer  
 {  
     public class MyTextStyle  
     {  
         private TextStyle style;  
 
         [Category("TextStyle")]  
         [Description("Find|column name from features dialog when click show features button.")]  
         public string TextColumnName  
         {  
             get { return style.TextColumnName; }  
             set { style.TextColumnName = value; }  
         }  
 
         [Category("TextStyle")]  
         [Description("The|font of text.")]  
         public Font Font  
         {  
             get { return new Font(style.Font.FontName, style.Font.Size, GetFontStyle(style.Font.Style)); }  
             set { style.Font = new GeoFont(value.Name, value.Size, GetDrawingFontStyles(value.Style)); }  
         }  
 
         [Category("TextStyle")]  
         [Description("The|color of text solid brush.")]  
         public Color TextColor  
         {  
             get { return Color.FromArgb(style.TextSolidBrush.Color.RedComponent, style.TextSolidBrush.Color.GreenComponent, style.TextSolidBrush.Color.BlueComponent); }  
             set { style.TextSolidBrush.Color = new GeoColor(value.R, value.G, value.B); }  
         }  
 
         public MyTextStyle(TextStyle style)  
         {  
             this.style = style;  
         }  
 
         private static FontStyle GetFontStyle(DrawingFontStyles drawingFontStyles)  
         {  
             switch (drawingFontStyles)  
             {  
                 case DrawingFontStyles.Bold:  
                     return FontStyle.Bold;  
                 case DrawingFontStyles.Italic:  
                     return FontStyle.Italic;  
                 case DrawingFontStyles.Regular:  
                     return FontStyle.Regular;  
                 case DrawingFontStyles.Strikeout:  
                     return FontStyle.Strikeout;  
                 case DrawingFontStyles.Underline:  
                     return FontStyle.Underline;  
                 default:  
                     break;  
             }  
             return FontStyle.Regular;  
         }  
 
         private static DrawingFontStyles GetDrawingFontStyles(FontStyle fontStyle)  
         {  
             switch (fontStyle)  
             {  
                 case FontStyle.Bold:  
                     return DrawingFontStyles.Bold;  
                 case FontStyle.Italic:  
                     return DrawingFontStyles.Italic;  
                 case FontStyle.Regular:  
                     return DrawingFontStyles.Regular;  
                 case FontStyle.Strikeout:  
                     return DrawingFontStyles.Strikeout;  
                 case FontStyle.Underline:  
                     return DrawingFontStyles.Underline;  
                 default:  
                     break;  
             }  
             return DrawingFontStyles.Regular;  
         }  
     }  
 }  
 

StyleEditor.cs

 using System;  
 using System.Drawing;  
 using System.Windows.Forms;  
 
 using ThinkGeo.MapSuite.Core;  
 using PropertyGridEx;  
 
 namespace MapSuiteExplorer  
 {  
     public partial class StyleEditor : UserControl  
     {  
         private StyleType styleType;  
         private AreaStyle areaStyle;  
         private LineStyle lineStyle;  
         private PointStyle pointStyle;  
         private TextStyle textStyle;  
 
         public string[] ColumnNames  
         {  
             get;  
             set;  
         }  
 
         public StyleType StyleType  
         {  
             get { return styleType; }  
             set { styleType = value; }  
         }  
 
         public AreaStyle AreaStyle  
         {  
             get { return areaStyle; }  
             set { areaStyle = value; }  
         }  
 
         public LineStyle LineStyle  
         {  
             get { return lineStyle; }  
             set { lineStyle = value; }  
         }  
 
         public PointStyle PointStyle  
         {  
             get { return pointStyle; }  
             set { pointStyle = value; }  
         }  
 
         public TextStyle TextStyle  
         {  
             get { return textStyle; }  
             set { textStyle = value; }  
         }  
 
         public StyleEditor()  
         {  
             InitializeComponent();  
 
             ColumnNames = new string[] { string.Empty };  
             pbxPreview.Image = new Bitmap(pbxPreview.Width, pbxPreview.Height);  
         }  
 
         private void gridStyle_PropertyValueChanged(object sender, PropertyValueChangedEventArgs e)  
         {  
             if (styleType == StyleType.Text)  
             {  
                 SetTextStyleValue(e.ChangedItem.PropertyDescriptor as CustomProperty.CustomPropertyDescriptor);  
             }  
             DrawPreviewImage();  
         }  
 
         private void SetTextStyleValue(CustomProperty.CustomPropertyDescriptor cpd)  
         {  
             if (cpd == null)  
             {  
                 return;  
             }  
             CustomProperty cp = cpd.CustomProperty as CustomProperty;  
             if (cp.Name == "Font")  
             {  
                 Font font = cp.Value as Font;  
                 DrawingFontStyles tStyle = DrawingFontStyles.Regular;  
                 if (font.Style == FontStyle.Bold)  
                 {  
                     tStyle = DrawingFontStyles.Bold;  
                 }  
                 if (font.Style == FontStyle.Italic)  
                 {  
                     tStyle = DrawingFontStyles.Italic;  
                 }  
                 if (font.Style == FontStyle.Strikeout)  
                 {  
                     tStyle = DrawingFontStyles.Strikeout;  
                 }  
                 if (font.Style == FontStyle.Underline)  
                 {  
                     tStyle = DrawingFontStyles.Underline;  
                 }  
                 textStyle.Font = new GeoFont(font.FontFamily.Name,  
                                             font.Size,  
                                             tStyle);  
             }  
             if (cp.Name == "TextColor")  
             {  
                 Color fillColor = (Color)cp.Value;  
                 textStyle.TextSolidBrush = new GeoSolidBrush(new GeoColor(fillColor.R,  
                                                                             fillColor.G,  
                                                                             fillColor.B));  
             }  
             if (cp.Name == "TextColumnName")  
             {  
                 string textColumnName = cp.Value.ToString();  
                 textStyle.TextColumnName = textColumnName;  
             }  
         }  
 
         private void DrawPreviewImage()  
         {  
             switch (styleType)  
             {  
                 case StyleType.Text:  
                     pbxPreview.Image = DrawSampleImage(pbxPreview.Image, textStyle);  
                     break;  
                 case StyleType.Line:  
                     pbxPreview.Image = DrawSampleImage(pbxPreview.Image, lineStyle);  
                     break;  
                 case StyleType.Point:  
                     pbxPreview.Image = DrawSampleImage(pbxPreview.Image, pointStyle);  
                     break;  
                 case StyleType.Area:  
                     pbxPreview.Image = DrawSampleImage(pbxPreview.Image, areaStyle);  
                     break;  
                 default:  
                     break;  
             }  
             pbxPreview.Invalidate();  
         }  
 
         private static Image DrawSampleImage(Image image, Style style)  
         {  
             Image newImage = new Bitmap(image.Width, image.Height);  
             image.Dispose();  
             GdiPlusGeoCanvas canvas = new GdiPlusGeoCanvas();  
             canvas.BeginDrawing(newImage, new RectangleShape(0, newImage.Width, newImage.Height, 0), GeographyUnit.DecimalDegree);  
             style.DrawSample(canvas);  
 
             if (canvas.IsDrawing)  
             {  
                 canvas.EndDrawing();  
             }  
 
             return newImage;  
         }  
 
         private void StyleEditor_ParentChanged(object sender, EventArgs e)  
         {  
             DrawPreviewImage();  
             object style = null;  
             switch (styleType)  
             {  
                 case StyleType.Text:  
                     SetTextStyle();  
                     break;  
                 case StyleType.Line:  
                     style = new MyLineStyle(lineStyle);  
                     break;  
                 case StyleType.Point:  
                     style = new MyPointStyle(pointStyle);  
                     break;  
                 case StyleType.Area:  
                     style = new MyAreaStyle(areaStyle);  
                     break;  
                 default:  
                     break;  
             }  
             if (style != null)  
             {  
                 gridStyle.SelectedObject = style;  
             }  
         }  
 
         private void SetTextStyle()  
         {  
             object grid = gridStyle;  
             gridStyle.ShowCustomProperties = true;  
             gridStyle.Item.Add("Font", new Font("Areial", 9), false, string.Empty, "The font of text", true);  
 
             gridStyle.Item.Add("TextColor", Color.Black, false, string.Empty, "the color of text solid bursh", true);  
             gridStyle.Item.Add("TextColumnName", string.Empty, false, string.Empty, string.Empty, true);  
 
             gridStyle.Item[gridStyle.Item.Count|- 1].Choices = new PropertyGridEx.CustomChoices(ColumnNames, true);  
             if (textStyle.TextColumnName != string.Empty)  
             {  
                 gridStyle.Item[gridStyle.Item.Count|- 1].Value = textStyle.TextColumnName;  
             }  
 
             gridStyle.Item[0].Value = new Font(textStyle.Font.FontName, textStyle.Font.Size);  
             if ((int)textStyle.TextSolidBrush.Color.RedComponent == 255 &&  
                 (int)textStyle.TextSolidBrush.Color.GreenComponent == 255 &&  
                 (int)textStyle.TextSolidBrush.Color.BlueComponent == 255)  
             {  
 
             }  
             else  
             {  
                 gridStyle.Item[1].Value = Color.FromArgb((int)textStyle.TextSolidBrush.Color.RedComponent,  
                                             (int)textStyle.TextSolidBrush.Color.GreenComponent,  
                                             (int)textStyle.TextSolidBrush.Color.BlueComponent);  
             }  
         }  
     }  
 }