User Tools

Site Tools


source_code_wpfdesktopeditionsample_customparametersprojection_cs_110124.zip

Differences

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

Link to this comparison view

Next revision
Previous revision
source_code_wpfdesktopeditionsample_customparametersprojection_cs_110124.zip [2015/08/20 03:08]
127.0.0.1 external edit
source_code_wpfdesktopeditionsample_customparametersprojection_cs_110124.zip [2015/09/09 03:38] (current)
admin
Line 1: Line 1:
-====== Source_Code_WpfDesktopEditionSample_CustomParametersProjection_CS_110124.zip ====== 
  
-<​noinclude>​{{article rating}}</​noinclude>​+====== Source Code WpfDesktopEditionSample CustomParametersProjection CS 110124.zip ====== 
 + 
 ====App.xaml.cs==== ====App.xaml.cs====
-^ Code ^ + 
-<source lang="csharp" line="​1"​>using System; ​ ​\\ ​using System.Collections.Generic; ​ ​\\ ​using System.Configuration; ​ ​\\ ​using System.Data; ​ ​\\ ​using System.Linq; ​ ​\\ ​using System.Windows; ​ ​\\ ​ \\ namespace CustomParametersProjection ​ ​\\ ​ ​\\ ​    <​nowiki>​//</​nowiki>​/ <​summary> ​ ​\\ ​    <​nowiki>​//</​nowiki>​/ Interaction logic for App.xaml ​ ​\\ ​    <​nowiki>​//</​nowiki>​/ </​summary> ​ ​\\ ​    public partial class App : Application ​ ​\\ ​     ​\\ ​     ​\\ ​ ​\\ ​</source  |+<code csharp> 
 +using System; 
 +using System.Collections.Generic;​ 
 +using System.Configuration;​ 
 +using System.Data;​ 
 +using System.Linq;​ 
 +using System.Windows;​ 
 +namespace CustomParametersProjection 
 +{ 
 +    ​/// <​summary>​ 
 +    ​/// Interaction logic for App.xaml 
 +    ​/// </​summary>​ 
 +    ​public partial class App : Application 
 +    ​{ 
 +    ​} 
 +} 
 +</code>
  
  
  
 ====TestWindow.xaml.cs==== ====TestWindow.xaml.cs====
-^ Code ^ 
-| <source lang="​csharp"​ line="​1"> ​ \\ using System; ​ \\ using System.Collections.Generic; ​ \\ using System.Linq; ​ \\ using System.Text; ​ \\ using System.IO; ​ \\ using System.Windows; ​ \\ using System.Windows.Controls; ​ \\ using System.Windows.Data; ​ \\ using System.Windows.Documents; ​ \\ using System.Windows.Input; ​ \\ using System.Windows.Media; ​ \\ using System.Windows.Media.Imaging; ​ \\ using System.Windows.Shapes; ​ \\ using System.Collections.ObjectModel; ​ \\ using ThinkGeo.MapSuite.Core; ​ \\ using ThinkGeo.MapSuite.WpfDesktopEdition; ​ \\  \\ namespace CustomParametersProjection ​ \\ {  \\     <​nowiki>//</​nowiki>/​ <​summary> ​ \\     <​nowiki>//</​nowiki>/​ Interaction logic for TestWindow.xaml ​ \\     <​nowiki>//</​nowiki>/​ </​summary> ​ \\     ​public partial class TestWindow : Window ​ \\     ​{ ​ \\         ​public TestWindow() ​ \\         ​{ ​ \\             ​InitializeComponent(); ​ \\         ​} ​ \\  \\         ​private void Window_Loaded(object sender, RoutedEventArgs e)  \\         ​{ ​ \\             ​wpfMap1.MapUnit = GeographyUnit.DecimalDegree; ​ \\  \\             ​WorldMapKitWmsWpfOverlay worldMapKitOverlay = new WorldMapKitWmsWpfOverlay(); ​ \\             ​wpfMap1.Overlays.Add(worldMapKitOverlay); ​ \\  \\             ​ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer(@"​../​../​data/​2000house_districts.shp"​); ​ \\             ​shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle( ​ \\                 ​GeoColor.FromArgb(100,​ GeoColor.StandardColors.Pink),​ GeoColor.StandardColors.Black); ​ \\             ​shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; ​ \\  \\             ​ManagedProj4Projection proj4 = new ManagedProj4Projection(); ​ \\             <​nowiki>//</​nowiki>​Internal projection string from the PRJ file. Note that the false easting value (x_0) has to be expressed in meter for proj4 string. ​ \\             ​string internalProjectionString = "​+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048 +no_defs"; ​ \\             ​proj4.InternalProjectionParametersString = internalProjectionString; ​ \\             <​nowiki>//</​nowiki>​External projection string as Geodetic (WGS84). ​ \\             ​proj4.ExternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326); ​ \\  \\             ​proj4.Open(); ​ \\             ​Vertex projVertex = proj4.ConvertToExternalProjection(747032,​ 1297787); ​ \\             ​proj4.Close(); ​ \\  \\             ​shapeFileFeatureLayer.FeatureSource.Projection = proj4; ​ \\  \\             ​LayerOverlay layerOverlay = new LayerOverlay(); ​ \\             ​layerOverlay.Layers.Add("​HouseDistricts",​ shapeFileFeatureLayer); ​ \\  \\             ​wpfMap1.Overlays.Add(layerOverlay); ​ \\  \\             ​shapeFileFeatureLayer.Open(); ​ \\             ​wpfMap1.CurrentExtent = shapeFileFeatureLayer.GetBoundingBox(); ​ \\             ​shapeFileFeatureLayer.Close(); ​ \\  \\             ​wpfMap1.Refresh(); ​ \\         ​} ​ \\  \\  \\         ​private void wpfMap1_MouseMove(object sender, MouseEventArgs e)  \\         ​{ ​ \\             <​nowiki>//</​nowiki>​Gets the PointShape in world coordinates from screen coordinates. ​ \\             Point point = e.MouseDevice.GetPosition(null); ​ \\  \\             ​ScreenPointF screenPointF = new ScreenPointF((float)point.X,​ (float)point.Y); ​ \\             ​PointShape pointShape = ExtentHelper.ToWorldCoordinate(wpfMap1.CurrentExtent,​ screenPointF,​ (float)wpfMap1.Width,​ (float)wpfMap1.Height); ​ \\  \\             ​textBox1.Text = "X: " + DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(pointShape.X) +  \\                           " ​ Y: " + DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(pointShape.Y); ​ \\  \\            }  \\     ​} ​ \\ }  \\ </​source> ​  | 
  
 +<code csharp>
 +
 +using System;
 +using System.Collections.Generic;​
 +using System.Linq;​
 +using System.Text;​
 +using System.IO;
 +using System.Windows;​
 +using System.Windows.Controls;​
 +using System.Windows.Data;​
 +using System.Windows.Documents;​
 +using System.Windows.Input;​
 +using System.Windows.Media;​
 +using System.Windows.Media.Imaging;​
 +using System.Windows.Shapes;​
 +using System.Collections.ObjectModel;​
 +using ThinkGeo.MapSuite.Core;​
 +using ThinkGeo.MapSuite.WpfDesktopEdition;​
 +namespace CustomParametersProjection
 +{
 +    /// <​summary>​
 +    /// Interaction logic for TestWindow.xaml
 +    /// </​summary>​
 +    public partial class TestWindow : Window
 +    {
 +        public TestWindow()
 +        {
 +            InitializeComponent();​
 +        }
 +        private void Window_Loaded(object sender, RoutedEventArgs e)
 +        {
 +            wpfMap1.MapUnit = GeographyUnit.DecimalDegree;​
 +            WorldMapKitWmsWpfOverlay worldMapKitOverlay = new WorldMapKitWmsWpfOverlay();​
 +            wpfMap1.Overlays.Add(worldMapKitOverlay);​
 +            ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer(@"​../​../​data/​2000house_districts.shp"​);​
 +            shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(
 +                GeoColor.FromArgb(100,​ GeoColor.StandardColors.Pink),​ GeoColor.StandardColors.Black);​
 +            shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;​
 +            ManagedProj4Projection proj4 = new ManagedProj4Projection();​
 +            //Internal projection string from the PRJ file. Note that the false easting value (x_0) has to be expressed in meter for proj4 string.
 +            string internalProjectionString = "​+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048 +no_defs";​
 +            proj4.InternalProjectionParametersString = internalProjectionString;​
 +            //External projection string as Geodetic (WGS84).
 +            proj4.ExternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326);​
 +            proj4.Open();​
 +            Vertex projVertex = proj4.ConvertToExternalProjection(747032,​ 1297787);
 +            proj4.Close();​
 +            shapeFileFeatureLayer.FeatureSource.Projection = proj4;
 +            LayerOverlay layerOverlay = new LayerOverlay();​
 +            layerOverlay.Layers.Add("​HouseDistricts",​ shapeFileFeatureLayer);​
 +            wpfMap1.Overlays.Add(layerOverlay);​
 +            shapeFileFeatureLayer.Open();​
 +            wpfMap1.CurrentExtent = shapeFileFeatureLayer.GetBoundingBox();​
 +            shapeFileFeatureLayer.Close();​
 +            wpfMap1.Refresh();​
 +        }
  
 +        private void wpfMap1_MouseMove(object sender, MouseEventArgs e)
 +        {
 +            //Gets the PointShape in world coordinates from screen coordinates.
 +            Point point = e.MouseDevice.GetPosition(null);​
 +            ScreenPointF screenPointF = new ScreenPointF((float)point.X,​ (float)point.Y);​
 +            PointShape pointShape = ExtentHelper.ToWorldCoordinate(wpfMap1.CurrentExtent,​ screenPointF,​ (float)wpfMap1.Width,​ (float)wpfMap1.Height);​
 +            textBox1.Text = "X: " + DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(pointShape.X) +
 +                          " ​ Y: " + DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(pointShape.Y);​
 +           }
 +    }
 +}
 +</​code>​
source_code_wpfdesktopeditionsample_customparametersprojection_cs_110124.zip.1440040127.txt.gz · Last modified: 2015/09/02 09:11 (external edit)