User Tools

Site Tools


map_suite_desktop_for_winforms_quick_start_guide

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
map_suite_desktop_for_winforms_quick_start_guide [2017/02/08 03:42]
tgwikiupdate [Download the Sample]
map_suite_desktop_for_winforms_quick_start_guide [2017/03/15 05:16] (current)
tgwikiupdate
Line 2: Line 2:
  
 <div msgbox> <div msgbox>
-The Winforms ​QuickStart ​Guide will guide you through the process of creating a sample application and will help you become  +The Winforms ​Quickstart ​Guide will guide you through the process of creating a sample application and will help you become  
-familiar with Map Suite. This QuickStart ​Guide supports Map Suite 10.0.0.0 and higherand will show you how to create a Winforms application.+familiar with Map Suite. This Quickstart ​Guide supports Map Suite 10.0.0.0 and higher and will show you how to create a Winforms application.
  
-If you want to build a WPF application,​ please see the [[map_suite_desktop_for_wpf_quick_start_guide|WPF ​QuickStart ​Guide]] instead.+If you want to build a WPF application,​ please see the [[map_suite_desktop_for_wpf_quick_start_guide|WPF ​Quickstart ​Guide]] instead.
 </​div>​ </​div>​
  
Line 12: Line 12:
 even developers inexperienced in Geographic Information Systems (GIS) can have fully functional maps working in minutes. even developers inexperienced in Geographic Information Systems (GIS) can have fully functional maps working in minutes.
  
-The purpose of this guide is to help you get started ​quickly to building your own spatially aware applications. Like any new software, there is some learning to be done. How do we start to learn how to take advantage of the power of Map Suite? The best way is to make a sample application with it.+The purpose of this guide is to help you quickly ​get started building your own spatially aware applications. Like any new software, there is some learning to be done. How do we start to learn how to take advantage of the power of Map Suite? The best way is to make a sample application with it. 
 +\\
  
 ===== Download the Sample ===== ===== Download the Sample =====
-<faicon fa fa-download ​ fa-lg> ​ {{mapsuite10:desktop:​mapsuite_winforms_helloworld.zip|Download Sample Code From This Exercise}} //(1.MB)// +<faicon fa fa-download ​ fa-lg> ​ {{https://github.com/​ThinkGeo/​QuickstartSample-ForWinForms|Download Sample Code From GitHub}} //(1.65 MB)// 
 +\\ 
 +\\
 ===== Setting up the Environment ===== ===== Setting up the Environment =====
-Please following our Map Suite Desktop guide for winforms development environment. 
-Let's start by creating a new Windows Forms Application in Microsoft Visual Studio (2015 or newer) named HelloWorld (see Figure 1). We can create the project with .NET Framework 4.5 or higher. 
  
-{{::mapsuite_helloworld.png}}+Let's start by creating a new Windows Forms Application in Microsoft Visual Studio (2015 or newer) named QuickstartSample(see Figure 1). We can create the project with .NET Framework 4.5 or higher. 
 + 
 +{{mapsuite10:desktop:Map_Suite_WinForms_QSG_NewProject.png}}
 \\ \\
 //Figure 1. Creating a new project in Microsoft Visual Studio.// //Figure 1. Creating a new project in Microsoft Visual Studio.//
 +\\
 +\\
 +
  
-After you created a HelloWorld ​project, we will see a project in the solution, please see Figure 2.+After you created a QuickstartSample ​project, we will see a project in the solution, please see Figure 2.
  
-{{::mapsuite_winforms_helloword_project.png|}}+{{mapsuite10:desktop:Map_Suite_WinForms_QSG_QuickstartProject.png}}
 \\ \\
-//Figure 2. Create Win Forms Project.// 
  
-===== Adding NuGet Package to our Project =====+//Figure 2. Create WinForms Project.//​ 
 +\\ 
 +\\ 
 + 
 +===== Adding ​NuGet Package to our Project =====
  
-You need to add NuGet package for Map Suite Desktop to the “Hello World” project ​which you will work mainly+You need to add the Map Suite Desktop ​for WinForms package ​to the “QuickstartSample” project ​from NuGet 
 Right-click the Reference in Solution Explorer and select “Manage NuGet Packages” (See Figure 3).  Right-click the Reference in Solution Explorer and select “Manage NuGet Packages” (See Figure 3). 
  
-{{::mapsuite_winforms_helloword_references.png}}+{{mapsuite10:desktop:Map_Suite_WinForms_QSG_NuGetManager.png}}
  
 //Figure 3. Refer to Manage NuGet Packages.// //Figure 3. Refer to Manage NuGet Packages.//
 \\ \\
-You can see a NuGet Package management start page in our Microsoft Visual Studio main window.  +\\
-Please type “Desktop” in the search box then press enter. You should see a package list (See Figure 4) in the main window.  +
-In that package list, please select “MapSuiteDesktopForWinForms-BarBone” package and click “Install” button in the right popup.+
  
-{{::​mapsuite_winforms_helloword_nuget_packages.png}}+You can see the NuGet Package management start page in our Microsoft Visual Studio main window.  
 +Ensure that "​Browse"​ is selected and then type “MapSuiteDesktopForWinForms” in the search box then press enter. You should see a package list (See Figure 4) in the main window.  
 +In that package list, please select “MapSuiteDesktopForWinForms-Standard” package and click the “Install” button in the right panel.
  
-//Figure 4. Refer to MapSuiteDesktopForWinForms-BareBone.//+{{mapsuite10:​desktop:​Map_Suite_WinForms_QSG_InstallWinFormsPackage.png}} 
 +//Figure 4. Refer to MapSuiteDesktopForWinForms-Standard.//
 \\ \\
-Now the package is installing into the project. ​ 
 \\ \\
-The "​NetTopologySuite"​ is the third part assembly, so the license acceptance is required. You can click "I Accept"​ to agree the license.+Click “OK” if the message box like Figure 5 pops up.
 \\ \\
-{{::mapsuite10:​desktop:​licenseacceptance.png}}+{{mapsuite10:​desktop:​Map_Suite_WinForms_QSG_ReferenceRreview.png}}
 \\ \\
-Click “OK” if meeting the message box like Figure 5.+//Figure 5. Review package references.//​
 \\ \\
-{{::​mapsuite_winforms_helloword_install.png}} 
- 
-//Figure 5. NuGet installation success.// 
 \\ \\
-Once the package is installed, you can see the message “Successfully installed ​ 
-'​MapSuiteDesktopForWinForms-BareBone 10.0.0'​ to HelloWorld” in your Microsoft Visual Studio Output box.  
-And some Assemblies about Desktop have been added into project references. (See Figure 6). 
  
-{{::mapsuite_winforms_helloword_package_installed.png}} +The "​NetTopologySuite"​ is the third part assembly, so the license acceptance is required. You can click "I Accept"​ to agree the license.(See Figure 6) 
- +\\ 
-//Figure 6. NuGet installation ​result.//+{{mapsuite10:desktop:Map_Suite_WinForms_QSG_PackageLicenseAcceptance.png}} 
 +\\ 
 +//Figure 6. NuGet installation ​success.//
 \\ \\
-In addition to the “MapSuiteDesktopForWinForms-BarBone” package, you also need two other packages named “ThinkGeo.MapSuite.Layers.ShapeFile” and “ThinkGeo.MapSuite.Styles.WorldStreets” to implement our “HelloWorld” application. Type “shapefile” into the search box and select the “ThinkGeo.MapSuite.Layers.ShapeFile” package to add it to the package list. Installing the package is the same as the step for “MapSuiteDesktopForWinForms-BarBone” package. (See Figure 7).  
-{{::​mapsuite_winforms_helloword_install_shapefile.png}} 
- 
-//Figure 7. NuGet ShapeFile installation.//​ 
 \\ \\
-Type “styles.worldstreets” in search box and select the “ThinkGeo.MapSuite.Styles.WorldStreets” package ​ 
-in the package list. Install the package too. (See Figure 8). 
-{{::​mapsuite_winforms_helloword_install_styles.png}} 
  
-//Figure 8NuGet WorldStreets installation.//+Once the package is installed, you can see the message “Successfully installed  
 +'​MapSuiteDesktopForWinForms-Standard'​ to QuickstartSample” in your Microsoft Visual Studio Output box 
 +Some Desktop assemblies have been added into the project references. (See Figure 7).
  
-==== Adding the Map Control to the Toolbar ==== +{{mapsuite10:desktop:Map_Suite_WinForms_QSG_ProjectReferences.png}} 
-**1.** 1. When you first open Microsoft Visual Studio after installing Map Suite, you may not see the controls in the Toolbox.  +\\ 
-You will need to follow these steps to add the controls. Hover on Toolbox and right click anywhere on list of controls.  +//​Figure ​7NuGet installation result.// 
-You will get a pop-up menu. Choose “Choose Items…” (See Figure 9) +\\
- +
-{{::mapsuite_winforms_adding_control.png}} +
- +
-//​Figure ​9.Configure a nuget package address.//+
 \\ \\
  
-**2.** A dialogue box to Choose Toolbox Items will appearYou will need to select the .NET Framework Components tab and then click the Browse buttonFinally navigate to the MapSuiteDesktopForWinForms-BareBone.10.0.0 ​Nuget package ​installation ​folder and select the “ThinkGeo.MapSuite.WinForms.dll” file.+===== Adding the Map Control ​to Your Form ===== 
 +Open ".../​QuickstartSample/​packages/​MapSuiteDesktopForWinForms-Standard.10.0.0/​designtime" ​package folder and drag "ThinkGeo.MapSuite.WinForms.dll" assembly to the Toolbox of Visual Studio.
  
-{{::mapsuite_winforms_choose_item.png}}+{{mapsuite10:desktop:Map_Suite_WinForms_QSG_ControlDesigntime.png}}
  
-//Figure 10.Add ThinkGeo.MapSuite.WinForms.dll to .Net Framework Components.//​ 
-\\ 
  
-**3.** You should now have the Map Control available in your Toolbox as shown in Figure 11 below. +Draw the Map control on the form by clicking on the WinformsMap ​Control object in the Toolbox and  
- +then dragging and dropping (using the left mouse button) to the form. You can resize the map if you desire. You can leave the name of the  
-{{::​mapsuite_winforms_toolbox_control.png}} +Map control ​as winformsMap1. Our map will display in this object.
-\\ +
-//Figure 11. The Map Controls under the Toolbox window.// +
-\\ +
-===== Adding the Map Control to Your Form ===== +
-Draw the Map control on the form by clicking on the Map Control object in the Toolbox and  +
-then dragging and dropping (using the left mouse button) to the size you desire. You can leave the name of the  +
-Map control ​to winformsMap1. Our map will display in it.+
  
-{{::mapsuite_winforms_map.png}}+{{mapsuite10:desktop:Map_Suite_WinForms_QSG_AddMapControl.png}}
  
-===== Map Suite Desktop "Hello World" ===== +===== Map Suite Desktop "QuickstartSample" ===== 
-In creating your “Hello World” sample ​application,​ your first step is to set some references at the very top of your code +In creating your “QuickstartSample" ​application,​ your first step is to set some references at the very top of your code  
-as you will use many classes within that. Let’s ​Open the “Form1.cs” in the project andclick the Form in the opened design box  +as you will use many classes within that. Open the “Form1.cs” in the project and click the form in the opened design box  
-to move to the “View Code” of the FormSet the reference ​like this:+to move to the “View Code” of the formAdd the references ​like this:
 <code csharp> <code csharp>
 using ThinkGeo.MapSuite;​ using ThinkGeo.MapSuite;​
Line 119: Line 106:
 using ThinkGeo.MapSuite.Styles;​ using ThinkGeo.MapSuite.Styles;​
 using ThinkGeo.MapSuite.Shapes;​ using ThinkGeo.MapSuite.Shapes;​
 +using ThinkGeo.MapSuite.Drawing;​
 </​code>​ </​code>​
  
Line 125: Line 113:
   * The borders of every country in the world ("​Countries02.shp"​)   * The borders of every country in the world ("​Countries02.shp"​)
  
-(**NOTE:** The data used in this sample can be found in the attached sample above at "​\Data"​ folder)+(**NOTE:** The data used in this sample can be found in the attached sample above in the "​\Data"​ folder)
  
-Our next step is to define and add our Layers. Here is the code to use for our example. All of the following code can be placed in the ''​Form1_Load''​ event of the form.+Our next step is to define and add our layers. All of the following code can be placed in the ''​Form1_Load''​ event of the form. Here is the code to use for our example
  
 <code csharp> <code csharp>
Line 158: Line 146:
  
     // Set a proper extent for the Map.  ​     // Set a proper extent for the Map.  ​
-    winformsMap1.CurrentExtent = new RectangleShape(0783026);+    winformsMap1.CurrentExtent = new RectangleShape(-13470-567);
  
     // We now need to call the Refresh() method of the Map control so that the Map can redraw based on the data that has been provided.     // We now need to call the Refresh() method of the Map control so that the Map can redraw based on the data that has been provided.
Line 165: Line 153:
 </​code>​ </​code>​
  
-Now it'​s ​time to press F5 to start the application. If you have not setup a developer license, Map Suite Product Center will pop up, and you need to generate your developer ​license by steps like active account -> activate or start evaluation -> continue debugging -> get runtime ​license. For more details, please refer to (http://​wiki.thinkgeo.com/​wiki/​map_suite_developer_license_guide).+Now it is time to press F5 to start the application. If you have not set up a developer license, ​the Map Suite Product Center will pop up. You need to generate your developer license. For more details, please refer to http://​wiki.thinkgeo.com/​wiki/​map_suite_developer_license_guide.
  
-Once developer license is ready, run the application, your map should look like the one below(see Figure 12).+Once the developer license is ready, run the application. Your map should look like the one below(see Figure 12).
  
-{{mapsuite10:​desktop:​2.png}}+{{mapsuite10:​desktop:​Map_Suite_WinForms_QSG_ShowAreaStyle.png}}
 \\ \\
-//Figure 12. A Simple ​map of Europe.//+//Figure 12. A sample ​map of Europe.//
 \\ \\
-So what has occurred here? We have created a layer and added it to the Map, and the Map has rendered ​it according to its default style parameters. Also, we have used ZoomLevel to display the map the way we want.+\\ 
 + 
 +So what has occurred here? We have created a layer and added it to the map and the map has rendered according to its default style parameters. Also, we have used ZoomLevel to display the map the way that we want.
  
-NOTE: It is important that the ''​MapUnit'' ​property of a Map object be set using the ''​GeographyUnit''​ Enumeration. This is because ​Shapefiles ​only store binary vector coordinates,​ which can be in DecimalDegree,​ feet, meters, etc., and our map has no idea about what the unit of measurement is until we set it. This information is normally found somewhere in the documentation or within the supplemental data file as discussed in the section on Shapefiles.+NOTE: It is important that the "MapUnit" ​property of a Map object be set using the "GeographyUnit" enumeration. This is because ​ShapeFiles ​only store binary vector coordinates,​ which can be in DecimalDegree,​ feet, meters, etc. Our map has no idea about what the unit of measurement is until we set it. This information is normally found somewhere in the documentation or within the supplemental data file as discussed in the section on ShapeFiles.
  
 ===== Navigating the Map ===== ===== Navigating the Map =====
-With the above code, not only can you display a map, but you can also navigate it. You can pan by dragging the map, zoom in by double-clicking,​ track zoom in by drawing a rectangle with your left mouse button mouse while holding the shift key, or zoom in and out by using the mouse wheel. Very powerful for just couple lines of code, isn't it?+With the above code, you can both display a map and navigate it. You can pan by dragging the map, zoom in by double-clicking,​ track zoom in by drawing a rectangle with your left mouse button mouse while holding the shift key, or zoom in and out by using the mouse wheel. Very powerful for just couple lines of code, isn't it?
  
 That was an easy start! Now, let's add another Shapefile to the sample so that we will have a total of two layers: That was an easy start! Now, let's add another Shapefile to the sample so that we will have a total of two layers:
Line 216: Line 206:
  
     winformsMap1.Overlays.Add(layerOverlay);​     winformsMap1.Overlays.Add(layerOverlay);​
-    winformsMap1.CurrentExtent = new RectangleShape(0783026);+    winformsMap1.CurrentExtent = new RectangleShape(-13470-567);
  
     winformsMap1.Refresh();​     winformsMap1.Refresh();​
Line 222: Line 212:
 </​code>​ </​code>​
  
-And the result is as following ​(Figure 13):+And the result is as follows ​(Figure 13):
  
-{{mapsuite10:​desktop:​1.png}}+{{mapsuite10:​desktop:​Map_Suite_WinForms_QSG_ShowPointStyle.png}}
 \\ \\
-//Figure 13. Europe ​map with 2 layers.//+//Figure 13. Map of Europe with 2 layers.//
 \\ \\
 +\\
 +
 ===== How to Use GeoTextStyle ===== ===== How to Use GeoTextStyle =====
 ==== TextStyle ==== ==== TextStyle ====
-TextStyle ​are used to label items on map. As every Shapefile ​has a relative .dbf file, which includes descriptions for every record, the most common way to use TextStyles is for labeling. For example, WorldCapital Shapefile'​s corresponding .dbf file contains the field "​CITY_NAME"​. We can use this field to label the cities on our map.+TextStyle ​is used to label items on map. As every ShapeFile ​has a relative .dbf file that includes descriptions for every record, the most common way to use TextStyles is for labeling. For example, WorldCapital Shapefile'​s corresponding .dbf file contains the field "​CITY_NAME"​. We can use this field to label the cities on our map.
  
-{{::mapsuite_winforms_helloword_data.png}}+{{mapsuite10:desktop:Map_Suite_WinForms_QSG_DBFDetails.png}}
  
-Map Suite has many TextStyles built in, which will help us quickly design attractive labels for the cities on our map. We can just pick the TextStyle we like and use it.+Map Suite has many TextStyles built in to help us quickly design attractive labels for the cities on our map. We can just pick the TextStyle we like and use it.
  
 <code csharp> <code csharp>
Line 287: Line 279:
  
     winformsMap1.Overlays.Add(layerOverlay);​     winformsMap1.Overlays.Add(layerOverlay);​
-    winformsMap1.CurrentExtent = new RectangleShape(0783026);+    winformsMap1.CurrentExtent = new RectangleShape(-13470-567);
  
     winformsMap1.Refresh();​     winformsMap1.Refresh();​
Line 293: Line 285:
 </​code>​ </​code>​
  
-The result is as following ​(Figure ​13):+The result is as follows ​(Figure ​14):
  
-{{::mapsuite_winforms_helloword_display3.png}}+{{mapsuite10:desktop:Map_Suite_WinForms_QSG_ShowTextStyle.png}} 
 +\\ 
 +//Figure 14. Map of Europe with a TextStyle.//​ 
 +\\
 \\ \\
-//Figure 13. Europe map with TextStyle.//​ 
  
-Now that we know how to render text and render symbols, let's define two different ZoomLevels in one single layerand create our own custom Style and TextStyle.+Now that we know how to render text and render symbols, let's define two different ZoomLevels in one single layer and create our own custom Style and TextStyle.
  
 <code csharp> <code csharp>
Line 358: Line 352:
  
     winformsMap1.Overlays.Add(layerOverlay);​     winformsMap1.Overlays.Add(layerOverlay);​
-    winformsMap1.CurrentExtent = new RectangleShape(0783026);+    winformsMap1.CurrentExtent = new RectangleShape(-13470-567);
  
     winformsMap1.Refresh();​     winformsMap1.Refresh();​
Line 366: Line 360:
 Can you imagine what the map will look like now? Below is the result. At first it appears like figure 15, and the map changes to figure 8 as you zoom in. Can you imagine what the map will look like now? Below is the result. At first it appears like figure 15, and the map changes to figure 8 as you zoom in.
  
-{{::mapsuite_winforms_helloword_display4.png}}+{{mapsuite10:desktop:Map_Suite_WinForms_QSG_ShowLowZoomLevel.png}}
 \\ \\
-//Figure 15. Europe ​Map with two ZoomLevels, before ​Zoom In.//+//Figure 15. A map of Europe with two ZoomLevels, before ​zooming in.//
  
-{{::mapsuite_winforms_helloword_display5.png}}+{{mapsuite10:desktop:Map_Suite_WinForms_QSG_ShowHeightZoomLevel.png}}
 \\ \\
-//Figure 16. Europe Map with two ZoomLevels, after Zoom In.//+//Figure 16. The same map with two ZoomLevels, after zooming in.//
  
-At this moment, we have complete our scenario, the next thing we want to do is to make it run on another machine ​which doesn’t ​have developer license. ​Runtime ​license is the one we are looking for. Here is guide to generate a runtime license ​to satisfy it, please refer to (http://​wiki.thinkgeo.com/​wiki/​map_suite_runtime_license_guide_for_desktop ​) for details.+This completes ​this scneario. The next thing you might want to do is to make it run on another machine ​that does not have developer license. ​A runtime ​license is the one we are looking for. Here is the guide to generate a runtime licensehttp://​wiki.thinkgeo.com/​wiki/​map_suite_runtime_license_guide_for_desktop.
  
 ==== Notes ==== ==== Notes ====
-Because Desktop Edition uses multi-threading internally for drawing, if you want to change an overlay after the map is initialized,​ you need to lock the overlay first to avoid threading conflicts. For more information,​ please have a look at our “How Do I?” sample applications that come with the product.+Because ​the Desktop Edition uses multi-threading internally for drawing, if you want to change an overlay after the map is initialized,​ you need to lock the overlay first to avoid threading conflicts. For more information,​ please have a look at our “How Do I?” sample applications that come with the product.
 ===== Summary ===== ===== Summary =====
 You now know the basics of using the Map Suite Map control and be able to get started adding functionality into your own applications. Let's recap what we have learned about the object relationships and how the pieces of Map Suite work together: You now know the basics of using the Map Suite Map control and be able to get started adding functionality into your own applications. Let's recap what we have learned about the object relationships and how the pieces of Map Suite work together:
map_suite_desktop_for_winforms_quick_start_guide.1486525361.txt.gz · Last modified: 2017/02/08 03:42 by tgwikiupdate