DisplayGpxFiles.zip

Sample.cs

 using System;  
 using System.Windows;  
 using ThinkGeo.MapSuite.Core;  
 using ThinkGeo.MapSuite.WpfDesktopEdition;  
 using System.IO;  
 
 namespace DisplayASimpleMap  
 {  
     public partial class Sample : Window  
     {  
         public Sample()  
         {  
             InitializeComponent();  
         }  
 
         private void Window_Loaded(object sender, RoutedEventArgs e)  
         {  
 
             Map1.MapUnit = GeographyUnit.DecimalDegree;  
             Map1.MapTools.Logo.IsEnabled = true;  
             Map1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);  
 
             string[] dwgFiles = Directory.GetFiles(@"..\..\Data\");  
             foreach (string dwgFile in dwgFiles)  
             {  
                 sampleFileListBox.Items.Add(Path.GetFileName(dwgFile));  
             }  
             // Display the first file in the list  
             sampleFileListBox.SelectedIndex = 0;  
         }  
 
         private void sampleFileListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)  
         {  
             GpxFeatureLayer shapeLayer = new GpxFeatureLayer(@"..\..\Data\" + sampleFileListBox.SelectedItem.ToString());  
 
             ValueStyle pointStyle = new ValueStyle();  
             pointStyle.ColumnName = "IsWayPoint";  
             pointStyle.ValueItems.Add(new ValueItem("0", PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.SimpleColors.Red, 4)));  
             pointStyle.ValueItems.Add(new ValueItem("1", PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.SimpleColors.Green, 8)));  
             LineStyle roadstyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.Black, 1, true);  
 
             shapeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(pointStyle);  
             shapeLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(roadstyle);  
             shapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
 
             GpxFeatureLayer textLayer = new GpxFeatureLayer(@"..\..\Data\" + sampleFileListBox.SelectedItem.ToString());  
             TextStyle labelStyle = TextStyles.CreateSimpleTextStyle("name", "Arial", 8, DrawingFontStyles.Bold, GeoColor.SimpleColors.Black);  
             labelStyle.PointPlacement = PointPlacement.UpperCenter;  
             labelStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping;  
             labelStyle.YOffsetInPixel = 8;  
 
             textLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(labelStyle);  
             textLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
 
             WorldMapKitWmsWpfOverlay worldMapKitWmsWpfOverlay = new WorldMapKitWmsWpfOverlay();  
             Map1.Overlays.Add(worldMapKitWmsWpfOverlay);  
 
             LayerOverlay layerOverlay = new LayerOverlay();  
             layerOverlay.Layers.Add(shapeLayer);  
             layerOverlay.Layers.Add(textLayer);  
             Map1.Overlays.Add(layerOverlay);  
 
             shapeLayer.Open();  
             Map1.CurrentExtent = shapeLayer.GetBoundingBox();  
 
             Map1.Refresh();  
         }  
     }  
 }