Пример #1
0
        private void MapsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (Map map in e.NewItems)
                {
                    AddMap(map);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (Map map in e.OldItems)
                {
                    RemoveMap(map);
                }
                break;

            case NotifyCollectionChangedAction.Move:
                int oldIndex = e.OldStartingIndex;
                int newIndex = e.NewStartingIndex;
                if (oldIndex != -1 && newIndex != -1)
                {
                    MapNodeViewModel entry = this.MapNodes[oldIndex];
                    this.MapNodes[oldIndex] = this.MapNodes[newIndex];
                    this.MapNodes[newIndex] = entry;
                }
                break;

            default:
                break;
            }
        }
Пример #2
0
 private void SelectedItemChanged(object item)
 {
     if (typeof(ProjectNodeViewModel).IsAssignableFrom(item.GetType()))
     {
         ProjectNodeViewModel projectViewModel = item as ProjectNodeViewModel;
         this.Session.CurrentProject.Value = projectViewModel.Project;
     }
     else if (typeof(MapNodeViewModel).IsAssignableFrom(item.GetType()))
     {
         MapNodeViewModel mapViewModel = item as MapNodeViewModel;
         this.Session.CurrentMap.Value = mapViewModel.Map;
     }
 }
Пример #3
0
        private void LoadProjectsAndMaps(ObservableCollection <Project> projects, ObservableCollection <Map> maps)
        {
            this.ExplorerNodes.Clear();

            foreach (Project project in projects)
            {
                ProjectNodeViewModel node = new ProjectNodeViewModel(this.eventAggregator, actionHandler, project);
                this.ExplorerNodes.Add(node);
            }
            foreach (Map map in maps)
            {
                MapNodeViewModel node = new MapNodeViewModel(this.eventAggregator, actionHandler, map);
                this.ExplorerNodes.Add(node);
            }
        }
Пример #4
0
        private void CurrentMapsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (Map map in e.NewItems)
                {
                    MapNodeViewModel node = new MapNodeViewModel(this.eventAggregator, actionHandler, map);
                    this.ExplorerNodes.Add(node);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                IEnumerable <MapNodeViewModel> projectViewModels = this.ExplorerNodes.OfType <MapNodeViewModel>();
                foreach (Map map in e.OldItems)
                {
                    MapNodeViewModel toRemove = projectViewModels.FirstOrDefault(entry => entry.Map == map);
                    this.ExplorerNodes.Remove(toRemove);
                }
                break;

            case NotifyCollectionChangedAction.Move:
                int oldIndex = e.OldStartingIndex;
                int newIndex = e.NewStartingIndex;
                if (oldIndex != -1 && newIndex != -1)
                {
                    IProjectExplorerNodeViewModel entry = this.ExplorerNodes[oldIndex];
                    this.ExplorerNodes[oldIndex] = this.ExplorerNodes[newIndex];
                    this.ExplorerNodes[newIndex] = entry;
                }
                break;

            default:
                break;
            }
        }
Пример #5
0
        public void RemoveMap(Map map)
        {
            MapNodeViewModel toRemove = this.MapNodes.FirstOrDefault(entry => entry.Map == map);

            this.MapNodes.Remove(toRemove);
        }
Пример #6
0
        public void AddMap(Map map)
        {
            MapNodeViewModel node = new MapNodeViewModel(this.eventAggregator, this.actionHandler, map);

            this.MapNodes.Add(node);
        }