User Tools

Site Tools


source_code_wpfdesktopeditionsample_customparametersprojection_cs_110124.zip

Source Code WpfDesktopEditionSample CustomParametersProjection CS 110124.zip

App.xaml.cs

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
    {
    }
}

TestWindow.xaml.cs

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);
           }
    }
}
source_code_wpfdesktopeditionsample_customparametersprojection_cs_110124.zip.txt · Last modified: 2015/09/09 03:38 by admin