Esempio n. 1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            mainViewModel = new MainViewModel(WpfMap);
            DataContext   = mainViewModel;

            // Load the sample data
            ChartsManagmentWindow    chartsManagmentWindow    = new ChartsManagmentWindow();
            ChartsManagmentViewModel chartsManagmentViewModel = ((ChartsManagmentViewModel)chartsManagmentWindow.DataContext);

            chartsManagmentViewModel.LoadFile(defaultSampleDataFile);
            chartsManagmentViewModel.SelectedItems.Add(chartsManagmentViewModel.SelectedItem);
            chartsManagmentViewModel.HandleOkCommand();
        }
 private void HandleToolBarMessage(ToolBarMessage message)
 {
     if (message != null && !string.IsNullOrEmpty(message.Action))
     {
         switch (message.Action.ToLower())
         {
         case "loadcharts":
         {
             var window = new ChartsManagmentWindow();
             window.Owner = Application.Current.MainWindow;
             window.ShowDialog();
         }
         break;
         }
     }
 }
        public override void Handle(Window owner, MapView map, MenuItemMessage message)
        {
            switch (message.MenuItem.Action.ToLowerInvariant())
            {
            case "loadcharts":
            {
                var window = new ChartsManagmentWindow();
                window.Owner = owner;
                window.ShowDialog();
            }
            break;

            case "unloadcharts":
            {
                if (map.Overlays.Contains(chartsOverlayName))
                {
                    if (MessageBox.Show("Do you want to unload all the charts?", string.Empty, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        if (map.Overlays.Contains(chartsOverlayName))
                        {
                            GeoCollection <Layer> layers = (map.Overlays[chartsOverlayName] as LayerOverlay).Layers;
                            foreach (Layer layer in layers)
                            {
                                layer.Close();
                            }
                            layers.Clear();

                            ChartMessage chartMessage = new ChartMessage(ChartsManagmentViewModel.Instance.Charts);
                            Messenger.Default.Send <ChartMessage>(chartMessage, "UnloadCharts");
                            ChartsManagmentViewModel.Instance.Charts.Clear();
                            ChartsManagmentViewModel.Instance.SelectedItem = null;
                            ChartsManagmentViewModel.Instance.SelectedItems.Clear();
                        }

                        if (map.Overlays.Contains(boundingBoxPreviewOverlayName))
                        {
                            ((InMemoryFeatureLayer)((LayerOverlay)map.Overlays[boundingBoxPreviewOverlayName]).Layers[0]).InternalFeatures.Clear();
                        }
                        map.Refresh();
                    }
                }
            }
            break;
            }
        }