====== Source Code WpfDesktopEditionSample S57Viewer.zip ======
====MainWindow.xaml.cs====
using System.Globalization;
using System.Windows;
using ThinkGeo.MapSuite.Core;
using ThinkGeo.MapSuite.WpfDesktopEdition;
namespace S57Viewer
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
private MainViewModel mainViewModel;
///
/// Initializes a new instance of the MainWindow class.
///
public MainWindow()
{
InitializeComponent();
Closing += (s, e) => mainViewModel.Cleanup();
}
private void WpfMap_CurrentScaleChanging(object sender, CurrentScaleChangingWpfMapEventArgs e)
{
CurrentScale.Text = string.Format("1:{0:N}", e.CurrentScale);
}
private void WpfMap_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
Point currentPoint = e.GetPosition(WpfMap);
PointShape worldPoint = ExtentHelper.ToWorldCoordinate(WpfMap.CurrentExtent, new ScreenPointF((float)currentPoint.X, (float)currentPoint.Y), (float)WpfMap.ActualWidth, (float)WpfMap.ActualHeight);
CurrentX.Text = worldPoint.X.ToString("f6", CultureInfo.InvariantCulture);
CurrentY.Text = worldPoint.Y.ToString("f6", CultureInfo.InvariantCulture);
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
mainViewModel = new MainViewModel(new MenuItemService(), WpfMap);
DataContext = mainViewModel;
}
}
}
====MainViewModel.cs====
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using ThinkGeo.MapSuite.Core;
using ThinkGeo.MapSuite.WpfDesktopEdition;
namespace S57Viewer
{
public class MainViewModel : ViewModelBase
{
private const string boundingBoxPreviewOverlayName = "BoundingBoxPreview";
private const string chartsOverlayName = "ChartsOverlay";
private const string GraticuleOverlayName = "GraticuleOverlay";
private const string highlightOverlayName = "highlight";
private const string WorldMapOverlayName = "WorldMapOverlay";
private readonly IMenuItemService dataService;
private Collection areaDrawingModes;
private Collection baseMaps;
private InMemoryFeatureLayer boundingBoxPreviewLayer;
private bool canHandleExecute = true;
private ChartSelectedItem chartSelectedItem = new ChartSelectedItem(string.Empty, null);
private ICommand clearSelectionCommand;
private Collection colorSchemas;
private Collection displayCategorys;
private bool isIdentify = false;
private bool isOnLoading;
private WpfMap map;
private Collection