internal void MoveDown(SettingsPathViewModel pathVM) { ObservableCollection <SettingsPath> paths = GetPaths(pathVM); var index = paths.IndexOf(pathVM.SettingsPath); paths.Move(index, index + 1); }
private void BuildPathViewModels(ObservableCollection<SettingsPath> source, ObservableCollection<SettingsPathViewModel> destination, SettingsPathType type) { destination.Clear(); for (int i = 0; i < source.Count; ++i) { var vm = new SettingsPathViewModel(source[i], type); vm.IsAdded = true; destination.Add(vm); } }
private void BuildPathViewModels(ObservableCollection <SettingsPath> source, ObservableCollection <SettingsPathViewModel> destination, SettingsPathType type) { destination.Clear(); for (int i = 0; i < source.Count; ++i) { var vm = new SettingsPathViewModel(source[i], type); vm.IsAdded = true; destination.Add(vm); } }
internal SettingsPathViewModel BeginAddPath(SettingsPathType type) { var vm = new SettingsPathViewModel(new SettingsPath(), type); vm.IsAdded = false; vm.IsEditing = true; if (type == SettingsPathType.Components) { ComponentPaths.Add(vm); } else { TypePaths.Add(vm); } return(vm); }
void Collection_Changed(ObservableCollection <SettingsPath> sender, ObservableCollection <SettingsPathViewModel> destination, SettingsPathType type, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { switch (e.Action) { case System.Collections.Specialized.NotifyCollectionChangedAction.Add: { var vm = new SettingsPathViewModel(e.NewItems[0] as SettingsPath, type); vm.IsAdded = true; destination.Add(vm); }; break; case System.Collections.Specialized.NotifyCollectionChangedAction.Move: { destination.Move(e.OldStartingIndex, e.NewStartingIndex); } break; case System.Collections.Specialized.NotifyCollectionChangedAction.Remove: { destination.RemoveAt(e.OldStartingIndex); } break; case System.Collections.Specialized.NotifyCollectionChangedAction.Replace: { var vm = new SettingsPathViewModel(e.NewItems[0] as SettingsPath, type); vm.IsAdded = true; destination[e.OldStartingIndex] = vm; } break; case System.Collections.Specialized.NotifyCollectionChangedAction.Reset: { BuildPathViewModels(sender, destination, type); } break; default: break; } }
internal void FinalizeAddPath(SettingsPathViewModel vm) { if (!string.IsNullOrWhiteSpace(vm.Path)) { if (vm.PathType == SettingsPathType.Components) { ComponentPaths.Remove(vm); m_settings.ComponentPaths.Add(new SettingsPath(false, vm.Path)); } else if (vm.PathType == SettingsPathType.Type) { TypePaths.Remove(vm); m_settings.TypePaths.Add(new SettingsPath(false, vm.Path)); } else if (vm.PathType == SettingsPathType.Package) { PackagePaths.Remove(vm); m_settings.PackagePaths.Add(new SettingsPath(false, vm.Path)); } } }
private ObservableCollection <SettingsPath> GetPaths(SettingsPathViewModel pathVM) { ObservableCollection <SettingsPath> paths = null; if (pathVM.PathType == SettingsPathType.Components) { paths = m_settings.ComponentPaths; } else if (pathVM.PathType == SettingsPathType.Type) { paths = m_settings.TypePaths; } else if (pathVM.PathType == SettingsPathType.Package) { paths = m_settings.PackagePaths; } else { throw new InvalidOperationException("Unknown enum value"); } return(paths); }
void Collection_Changed(ObservableCollection<SettingsPath> sender, ObservableCollection<SettingsPathViewModel> destination, SettingsPathType type, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { switch (e.Action) { case System.Collections.Specialized.NotifyCollectionChangedAction.Add: { var vm = new SettingsPathViewModel(e.NewItems[0] as SettingsPath, type); vm.IsAdded = true; destination.Add(vm); }; break; case System.Collections.Specialized.NotifyCollectionChangedAction.Move: { destination.Move(e.OldStartingIndex, e.NewStartingIndex); } break; case System.Collections.Specialized.NotifyCollectionChangedAction.Remove: { destination.RemoveAt(e.OldStartingIndex); } break; case System.Collections.Specialized.NotifyCollectionChangedAction.Replace: { var vm = new SettingsPathViewModel(e.NewItems[0] as SettingsPath, type); vm.IsAdded = true; destination[e.OldStartingIndex] = vm; } break; case System.Collections.Specialized.NotifyCollectionChangedAction.Reset: { BuildPathViewModels(sender, destination, type); } break; default: break; } }
private ObservableCollection<SettingsPath> GetPaths(SettingsPathViewModel pathVM) { ObservableCollection<SettingsPath> paths = null; if (pathVM.PathType == SettingsPathType.Components) { paths = m_settings.ComponentPaths; } else if (pathVM.PathType == SettingsPathType.Type) { paths = m_settings.TypePaths; } else if (pathVM.PathType == SettingsPathType.Package) { paths = m_settings.PackagePaths; } else { throw new InvalidOperationException("Unknown enum value"); } return paths; }
internal void Delete(SettingsPathViewModel pathVM) { ObservableCollection<SettingsPath> paths = GetPaths(pathVM); paths.Remove(pathVM.SettingsPath); }
internal void MoveDown(SettingsPathViewModel pathVM) { ObservableCollection<SettingsPath> paths = GetPaths(pathVM); var index = paths.IndexOf(pathVM.SettingsPath); paths.Move(index, index + 1); }
internal SettingsPathViewModel BeginAddPath(SettingsPathType type) { var vm = new SettingsPathViewModel(new SettingsPath(), type); vm.IsAdded = false; vm.IsEditing = true; if (type == SettingsPathType.Components) ComponentPaths.Add(vm); else TypePaths.Add(vm); return vm; }
internal void Delete(SettingsPathViewModel pathVM) { ObservableCollection <SettingsPath> paths = GetPaths(pathVM); paths.Remove(pathVM.SettingsPath); }