This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
source_code_serviceseditionsample_codegeneratorsample_cs_111213.zip [2015/08/20 03:08] 127.0.0.1 external edit |
source_code_serviceseditionsample_codegeneratorsample_cs_111213.zip [2015/09/08 05:18] (current) admin |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Source_Code_ServicesEditionSample_CodeGeneratorSample_CS_111213.zip ====== | + | ====== Source Code ServicesEditionSample CodeGeneratorSample CS 111213.zip ====== |
- | <noinclude>{{article rating}}</noinclude> | ||
====Banner.cs==== | ====Banner.cs==== | ||
- | ^ Code ^ | + | |
- | | <source lang="csharp" line="1">using System; \\ using System.Diagnostics; \\ using System.IO; \\ using System.Management; \\ using System.Windows.Forms; \\ \\ public partial class Banner : UserControl \\ { \\ public Banner() \\ { \\ InitializeComponent(); \\ SetupBannerAd(); \\ } \\ \\ public void SetupBannerAd() \\ { \\ if (Process.GetCurrentProcess().ProcessName != "devenv") \\ { \\ adRotator.Url = new Uri(new DirectoryInfo(@"..\..\Resources\bannerad_offline.html").FullName); \\ if (IsNetworkAlive()) \\ { \\ adsRotatorTimer.Start(); \\ } \\ } \\ } \\ \\ private static bool IsNetworkAlive() \\ { \\ ObjectQuery objectQuery = new ObjectQuery("select * from Win32_NetworkAdapter where NetConnectionStatus=2"); \\ ManagementObjectSearcher searcher = null; \\ try \\ { \\ searcher = new ManagementObjectSearcher(objectQuery); \\ \\ return (searcher.Get().Count > 0); \\ } \\ finally \\ { \\ if (searcher != null) \\ { \\ searcher.Dispose(); \\ } \\ } \\ } \\ \\ private void adsRotatorTimer_Tick(object sender, EventArgs e) \\ { \\ adRotator.Navigate("http://gis.thinkgeo.com/Default.aspx?tabid=640&random=" + Guid.NewGuid().ToString()); \\ } \\ } \\ </source> | | + | <code csharp> using System; |
+ | using System.Diagnostics; | ||
+ | using System.IO; | ||
+ | using System.Management; | ||
+ | using System.Windows.Forms; | ||
+ | |||
+ | public partial class Banner : UserControl | ||
+ | { | ||
+ | public Banner() | ||
+ | { | ||
+ | InitializeComponent(); | ||
+ | SetupBannerAd(); | ||
+ | } | ||
+ | |||
+ | public void SetupBannerAd() | ||
+ | { | ||
+ | if (Process.GetCurrentProcess().ProcessName != "devenv") | ||
+ | { | ||
+ | adRotator.Url = new Uri(new DirectoryInfo(@"..\..\Resources\bannerad_offline.html").FullName); | ||
+ | if (IsNetworkAlive()) | ||
+ | { | ||
+ | adsRotatorTimer.Start(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | private static bool IsNetworkAlive() | ||
+ | { | ||
+ | ObjectQuery objectQuery = new ObjectQuery("select * from Win32_NetworkAdapter where NetConnectionStatus=2"); | ||
+ | ManagementObjectSearcher searcher = null; | ||
+ | try | ||
+ | { | ||
+ | searcher = new ManagementObjectSearcher(objectQuery); | ||
+ | |||
+ | return (searcher.Get().Count > 0); | ||
+ | } | ||
+ | finally | ||
+ | { | ||
+ | if (searcher != null) | ||
+ | { | ||
+ | searcher.Dispose(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | private void adsRotatorTimer_Tick(object sender, EventArgs e) | ||
+ | { | ||
+ | adRotator.Navigate("http://gis.thinkgeo.com/Default.aspx?tabid=640&random=" + Guid.NewGuid().ToString()); | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
====Footer.cs==== | ====Footer.cs==== | ||
- | ^ Code ^ | + | |
- | | <source lang="csharp" line="1">using System; \\ using System.Diagnostics; \\ using System.Windows.Forms; \\ using CodeGeneratorSample.Properties; \\ \\ public partial class Footer : UserControl \\ { \\ public Footer() \\ { \\ InitializeComponent(); \\ } \\ \\ private void btnProductInformation_Click(object sender, EventArgs e) \\ { \\ Process.Start("http://gis.thinkgeo.com/Products/GISComponentsforNETDevelopers/MapSuiteServicesEdition/tabid/628/Default.aspx"); \\ } \\ \\ private void btnProductInformation_Activate(object sender, EventArgs e) \\ { \\ btnProductInformation.Image = Resources.btn_active_map_suite_products; \\ } \\ \\ private void btnProductInformation_Deactivate(object sender, EventArgs e) \\ { \\ btnProductInformation.Image = Resources.btn_inactive_map_suite_products; \\ } \\ \\ private void btnSupportCenter_Click(object sender, EventArgs e) \\ { \\ Process.Start("http://gis.thinkgeo.com/supportcenter"); \\ } \\ \\ private void btnSupportCenter_Activate(object sender, EventArgs e) \\ { \\ btnSupportCenter.Image = Resources.btn_active_support_center; \\ } \\ \\ private void btnSupportCenter_Deactivate(object sender, EventArgs e) \\ { \\ btnSupportCenter.Image = Resources.btn_inactive_support_center; \\ } \\ \\ private void btnDiscussForum_Click(object sender, EventArgs e) \\ { \\ Process.Start("http://gis.thinkgeo.com/Support/DiscussionForums/tabid/143/afv/topicsview/aff/11/Default.aspx"); \\ } \\ \\ private void btnDiscussForum_Activate(object sender, EventArgs e) \\ { \\ btnDiscussForum.Image = Resources.btn_active_discussion_forums; \\ } \\ \\ private void btnDiscussForum_Deactivate(object sender, EventArgs e) \\ { \\ btnDiscussForum.Image = Resources.btn_inactive_discussion_forums; \\ } \\ \\ private void btnWiki_Click(object sender, EventArgs e) \\ { \\ Process.Start("http://wiki.thinkgeo.com/wiki/Map_Suite_Services_Edition"); \\ } \\ \\ private void btnWiki_Activate(object sender, EventArgs e) \\ { \\ btnWiki.Image = Resources.btn_active_thinkgeo_wiki; \\ } \\ \\ private void btnWiki_Deactivate(object sender, EventArgs e) \\ { \\ btnWiki.Image = Resources.btn_inactive_thinkgeo_wiki; \\ } \\ \\ private void btnContactUs_Click(object sender, EventArgs e) \\ { \\ Process.Start("http://gis.thinkgeo.com/Default.aspx?tabid=147"); \\ } \\ \\ private void btnContactUs_Activate(object sender, EventArgs e) \\ { \\ btnContactUs.Image = Resources.btn_active_contact_us; \\ } \\ \\ private void btnContactUs_Deactivate(object sender, EventArgs e) \\ { \\ btnContactUs.Image = Resources.btn_inactive_contact_us; \\ } \\ } \\ </source> | | + | <code csharp> using System; |
+ | using System.Diagnostics; | ||
+ | using System.Windows.Forms; | ||
+ | using CodeGeneratorSample.Properties; | ||
+ | |||
+ | public partial class Footer : UserControl | ||
+ | { | ||
+ | public Footer() | ||
+ | { | ||
+ | InitializeComponent(); | ||
+ | } | ||
+ | |||
+ | private void btnProductInformation_Click(object sender, EventArgs e) | ||
+ | { | ||
+ | Process.Start("http://gis.thinkgeo.com/Products/GISComponentsforNETDevelopers/MapSuiteServicesEdition/tabid/628/Default.aspx"); | ||
+ | } | ||
+ | |||
+ | private void btnProductInformation_Activate(object sender, EventArgs e) | ||
+ | { | ||
+ | btnProductInformation.Image = Resources.btn_active_map_suite_products; | ||
+ | } | ||
+ | |||
+ | private void btnProductInformation_Deactivate(object sender, EventArgs e) | ||
+ | { | ||
+ | btnProductInformation.Image = Resources.btn_inactive_map_suite_products; | ||
+ | } | ||
+ | |||
+ | private void btnSupportCenter_Click(object sender, EventArgs e) | ||
+ | { | ||
+ | Process.Start("http://gis.thinkgeo.com/supportcenter"); | ||
+ | } | ||
+ | |||
+ | private void btnSupportCenter_Activate(object sender, EventArgs e) | ||
+ | { | ||
+ | btnSupportCenter.Image = Resources.btn_active_support_center; | ||
+ | } | ||
+ | |||
+ | private void btnSupportCenter_Deactivate(object sender, EventArgs e) | ||
+ | { | ||
+ | btnSupportCenter.Image = Resources.btn_inactive_support_center; | ||
+ | } | ||
+ | |||
+ | private void btnDiscussForum_Click(object sender, EventArgs e) | ||
+ | { | ||
+ | Process.Start("http://gis.thinkgeo.com/Support/DiscussionForums/tabid/143/afv/topicsview/aff/11/Default.aspx"); | ||
+ | } | ||
+ | |||
+ | private void btnDiscussForum_Activate(object sender, EventArgs e) | ||
+ | { | ||
+ | btnDiscussForum.Image = Resources.btn_active_discussion_forums; | ||
+ | } | ||
+ | |||
+ | private void btnDiscussForum_Deactivate(object sender, EventArgs e) | ||
+ | { | ||
+ | btnDiscussForum.Image = Resources.btn_inactive_discussion_forums; | ||
+ | } | ||
+ | |||
+ | private void btnWiki_Click(object sender, EventArgs e) | ||
+ | { | ||
+ | Process.Start("http://wiki.thinkgeo.com/wiki/Map_Suite_Services_Edition"); | ||
+ | } | ||
+ | |||
+ | private void btnWiki_Activate(object sender, EventArgs e) | ||
+ | { | ||
+ | btnWiki.Image = Resources.btn_active_thinkgeo_wiki; | ||
+ | } | ||
+ | |||
+ | private void btnWiki_Deactivate(object sender, EventArgs e) | ||
+ | { | ||
+ | btnWiki.Image = Resources.btn_inactive_thinkgeo_wiki; | ||
+ | } | ||
+ | |||
+ | private void btnContactUs_Click(object sender, EventArgs e) | ||
+ | { | ||
+ | Process.Start("http://gis.thinkgeo.com/Default.aspx?tabid=147"); | ||
+ | } | ||
+ | |||
+ | private void btnContactUs_Activate(object sender, EventArgs e) | ||
+ | { | ||
+ | btnContactUs.Image = Resources.btn_active_contact_us; | ||
+ | } | ||
+ | |||
+ | private void btnContactUs_Deactivate(object sender, EventArgs e) | ||
+ | { | ||
+ | btnContactUs.Image = Resources.btn_inactive_contact_us; | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
====Program.cs==== | ====Program.cs==== | ||
- | ^ Code ^ | ||
- | | <source lang="csharp" line="1">using System; \\ using System.Windows.Forms; \\ \\ static class Program \\ { \\ <nowiki>//</nowiki>/ <summary> \\ <nowiki>//</nowiki>/ The main entry point for the application. \\ <nowiki>//</nowiki>/ </summary> \\ [[STAThread]] \\ static void Main() \\ { \\ Application.EnableVisualStyles(); \\ Application.SetCompatibleTextRenderingDefault(false); \\ Application.Run(new Sample()); \\ } \\ }</source> | | ||
+ | <code csharp> using System; | ||
+ | using System.Windows.Forms; | ||
+ | | ||
+ | static class Program | ||
+ | { | ||
+ | /// <summary> | ||
+ | /// The main entry point for the application. | ||
+ | /// </summary> | ||
+ | [STAThread] | ||
+ | static void Main() | ||
+ | { | ||
+ | Application.EnableVisualStyles(); | ||
+ | Application.SetCompatibleTextRenderingDefault(false); | ||
+ | Application.Run(new Sample()); | ||
+ | } | ||
+ | }</code> | ||
- | ====Sample.cs==== | ||
- | ^ Code ^ | ||
- | | <source lang="csharp" line="1">using System; \\ using System.Drawing; \\ using System.Windows.Forms; \\ using ThinkGeo.MapSuite.Core; \\ \\ public partial class Sample : Form \\ { \\ private MapEngine mapEngine; \\ private Bitmap bitmap; \\ private RectangleShape boundingBox; \\ \\ public Sample() \\ { \\ InitializeComponent(); \\ } \\ \\ private void GenerateCodeForLayer_Load(object sender, EventArgs e) \\ { \\ bitmap = new Bitmap(map.Width, map.Height); \\ mapEngine = new MapEngine(); \\ \\ mapEngine.ShowLogo = true; \\ mapEngine.BackgroundFillBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); \\ \\ ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer("Data\\Countries02.shp"); \\ shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; \\ shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1; \\ shapeFileFeatureLayer.Open(); \\ boundingBox = shapeFileFeatureLayer.GetBoundingBox(); \\ shapeFileFeatureLayer.Close(); \\ \\ mapEngine.StaticLayers.Add(shapeFileFeatureLayer); \\ \\ mapEngine.CurrentExtent = boundingBox; \\ \\ DrawImage(); \\ } \\ \\ private void DrawImage() \\ { \\ mapEngine.OpenAllLayers(); \\ mapEngine.DrawStaticLayers(bitmap, GeographyUnit.DecimalDegree); \\ mapEngine.CloseAllLayers(); \\ \\ map.Image = bitmap; \\ } \\ \\ private void ToolBar_ButtonClick(object sender, ToolBarButtonClickEventArgs e) \\ { \\ switch (e.Button.Tag.ToString()) \\ { \\ case "Zoom In": \\ mapEngine.CurrentExtent.ScaleDown(50); \\ break; \\ case "Zoom Out": \\ mapEngine.CurrentExtent.ScaleUp(50); \\ break; \\ case "Full Extent": \\ mapEngine.CurrentExtent = boundingBox; \\ break; \\ case "Pan Left": \\ mapEngine.CurrentExtent = ExtentHelper.Pan(mapEngine.CurrentExtent, PanDirection.Left, 20); \\ break; \\ case "Pan Right": \\ mapEngine.CurrentExtent = ExtentHelper.Pan(mapEngine.CurrentExtent, PanDirection.Right, 20); \\ break; \\ case "Pan Up": \\ mapEngine.CurrentExtent = ExtentHelper.Pan(mapEngine.CurrentExtent, PanDirection.Up, 20); \\ break; \\ case "Pan Down": \\ mapEngine.CurrentExtent = ExtentHelper.Pan(mapEngine.CurrentExtent, PanDirection.Down, 20); \\ break; \\ default: \\ break; \\ } \\ DrawImage(); \\ } \\ \\ private void map_ClientSizeChanged(object sender, EventArgs e) \\ { \\ if (map.Width > bitmap.Width || map.Height > bitmap.Height) \\ { \\ bitmap = new Bitmap(map.Width, map.Height); \\ double scale = new ZoomLevelSet().GetZoomLevel(mapEngine.CurrentExtent, map.Width, GeographyUnit.DecimalDegree).Scale; \\ mapEngine.CurrentExtent = ExtentHelper.SnapToZoomLevel((RectangleShape)mapEngine.CurrentExtent.CloneDeep(), GeographyUnit.DecimalDegree, map.Width, map.Height, new ZoomLevelSet()); \\ mapEngine.CurrentExtent = ExtentHelper.ZoomToScale(scale, mapEngine.CurrentExtent, GeographyUnit.DecimalDegree, map.Width, map.Height); \\ DrawImage(); \\ } \\ } \\ \\ private void btnGenerateCode_Click(object sender, EventArgs e) \\ { \\ if (mapEngine.StaticLayers.Count == 1) \\ { \\ Layer layer = mapEngine.StaticLayers[[0]]; \\ \\ GeoCodeGenerator codeGenerator = new GeoCodeGenerator(); \\ string code = codeGenerator.GenerateCode(layer); \\ generatedCodeTextBox.Text = code; \\ } \\ } \\ } \\ \\ </source> | | ||
+ | ====Sample.cs==== | ||
+ | <code csharp> using System; | ||
+ | using System.Drawing; | ||
+ | using System.Windows.Forms; | ||
+ | using ThinkGeo.MapSuite.Core; | ||
+ | | ||
+ | public partial class Sample : Form | ||
+ | { | ||
+ | private MapEngine mapEngine; | ||
+ | private Bitmap bitmap; | ||
+ | private RectangleShape boundingBox; | ||
+ | | ||
+ | public Sample() | ||
+ | { | ||
+ | InitializeComponent(); | ||
+ | } | ||
+ | | ||
+ | private void GenerateCodeForLayer_Load(object sender, EventArgs e) | ||
+ | { | ||
+ | bitmap = new Bitmap(map.Width, map.Height); | ||
+ | mapEngine = new MapEngine(); | ||
+ | | ||
+ | mapEngine.ShowLogo = true; | ||
+ | mapEngine.BackgroundFillBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); | ||
+ | | ||
+ | ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer("Data | ||
+ | Countries02.shp"); | ||
+ | shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; | ||
+ | shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1; | ||
+ | shapeFileFeatureLayer.Open(); | ||
+ | boundingBox = shapeFileFeatureLayer.GetBoundingBox(); | ||
+ | shapeFileFeatureLayer.Close(); | ||
+ | | ||
+ | mapEngine.StaticLayers.Add(shapeFileFeatureLayer); | ||
+ | | ||
+ | mapEngine.CurrentExtent = boundingBox; | ||
+ | | ||
+ | DrawImage(); | ||
+ | } | ||
+ | | ||
+ | private void DrawImage() | ||
+ | { | ||
+ | mapEngine.OpenAllLayers(); | ||
+ | mapEngine.DrawStaticLayers(bitmap, GeographyUnit.DecimalDegree); | ||
+ | mapEngine.CloseAllLayers(); | ||
+ | | ||
+ | map.Image = bitmap; | ||
+ | } | ||
+ | | ||
+ | private void ToolBar_ButtonClick(object sender, ToolBarButtonClickEventArgs e) | ||
+ | { | ||
+ | switch (e.Button.Tag.ToString()) | ||
+ | { | ||
+ | case "Zoom In": | ||
+ | mapEngine.CurrentExtent.ScaleDown(50); | ||
+ | break; | ||
+ | case "Zoom Out": | ||
+ | mapEngine.CurrentExtent.ScaleUp(50); | ||
+ | break; | ||
+ | case "Full Extent": | ||
+ | mapEngine.CurrentExtent = boundingBox; | ||
+ | break; | ||
+ | case "Pan Left": | ||
+ | mapEngine.CurrentExtent = ExtentHelper.Pan(mapEngine.CurrentExtent, PanDirection.Left, 20); | ||
+ | break; | ||
+ | case "Pan Right": | ||
+ | mapEngine.CurrentExtent = ExtentHelper.Pan(mapEngine.CurrentExtent, PanDirection.Right, 20); | ||
+ | break; | ||
+ | case "Pan Up": | ||
+ | mapEngine.CurrentExtent = ExtentHelper.Pan(mapEngine.CurrentExtent, PanDirection.Up, 20); | ||
+ | break; | ||
+ | case "Pan Down": | ||
+ | mapEngine.CurrentExtent = ExtentHelper.Pan(mapEngine.CurrentExtent, PanDirection.Down, 20); | ||
+ | break; | ||
+ | default: | ||
+ | break; | ||
+ | } | ||
+ | DrawImage(); | ||
+ | } | ||
+ | | ||
+ | private void map_ClientSizeChanged(object sender, EventArgs e) | ||
+ | { | ||
+ | if (map.Width > bitmap.Width || map.Height > bitmap.Height) | ||
+ | { | ||
+ | bitmap = new Bitmap(map.Width, map.Height); | ||
+ | double scale = new ZoomLevelSet().GetZoomLevel(mapEngine.CurrentExtent, map.Width, GeographyUnit.DecimalDegree).Scale; | ||
+ | mapEngine.CurrentExtent = ExtentHelper.SnapToZoomLevel((RectangleShape)mapEngine.CurrentExtent.CloneDeep(), GeographyUnit.DecimalDegree, map.Width, map.Height, new ZoomLevelSet()); | ||
+ | mapEngine.CurrentExtent = ExtentHelper.ZoomToScale(scale, mapEngine.CurrentExtent, GeographyUnit.DecimalDegree, map.Width, map.Height); | ||
+ | DrawImage(); | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | private void btnGenerateCode_Click(object sender, EventArgs e) | ||
+ | { | ||
+ | if (mapEngine.StaticLayers.Count == 1) | ||
+ | { | ||
+ | Layer layer = mapEngine.StaticLayers[0]; | ||
+ | | ||
+ | GeoCodeGenerator codeGenerator = new GeoCodeGenerator(); | ||
+ | string code = codeGenerator.GenerateCode(layer); | ||
+ | generatedCodeTextBox.Text = code; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | </code> |