private void SetView(object item) { if (!(item is BachupGroup)) { if (item is BachupItem) { BachupItem bi = (BachupItem)item; Settings.LastOpened = bi.ID; SelectedViewModel = new BachupItemView() { DataContext = new BachupItemViewModel(bi) }; return; } SelectedViewModel = new HomePageView(); } else { BachupGroup bg = (BachupGroup)item; Settings.LastOpened = bg.ID; SelectedViewModel = new BachupGroupView() { DataContext = new BachupGroupViewModel(bg) }; return; } }
private void Add(object parameter) { if (CheckRequirements()) { BachupGroup bg = new BachupGroup(Name); DialogHost.CloseDialogCommand.Execute(bg, null); } }
public EditBachupGroupViewModel(BachupGroup bg) { CancelCommand = new RelayCommand(Cancel); SaveCommand = new RelayCommand(Save); ShowMessage = false; Message = ""; _bachupGroup = bg; Name = bg.Name; }
public AddBachupItemViewModel(BachupGroup bachupGroup) { AddCommand = new RelayCommand(Add); CancelCommand = new RelayCommand(Cancel); AddSourceFileCommand = new RelayCommand(AddSourceFile); AddSourceFolderCommand = new RelayCommand(AddSourceFolder); _bachupGroup = bachupGroup; ShowMessage = false; }
public BachupGroupViewModel(BachupGroup BachupGroupInput) { EditBachupGroupCommand = new RelayCommand(EditBachupGroup); DeleteBachupGroupCommand = new RelayCommand(DeleteBachupGroup); AddBachupItemCommand = new RelayCommand(AddBachupItem); CellEditedCommand = new RelayCommand(CellEdited); CellValueChangedCommand = new RelayCommand(CellValueChanged); AddDestinationCommand = new RelayCommand(AddDestination); DeleteDestinationCommand = new RelayCommand(DeleteDestination); ShowDestinationCommand = new RelayCommand(ShowDestination); RunAllCommand = new RelayCommand(RunAll); _bachupGroup = BachupGroupInput; UpdateView(); }
private async void CellEdited(object o) { DataGridCellEditEndingEventArgs args = o as DataGridCellEditEndingEventArgs; BachupItem bachupItem = args.EditingElement.DataContext as BachupItem; string newValue = bachupItem.Name; bachupItem.Name = _oldValue; if (_oldValue == newValue) { return; } BachupGroup bg = MainViewModel.Bachup.FirstOrDefault(item => item.ID == bachupItem.BachupGroupID); if (bg.DoesItemExist(newValue)) { AlertView view = new AlertView { DataContext = new AlertViewModel("Name Exists In This Group") }; _ = await DialogHost.Show(view, "RootDialog"); (args.EditingElement as TextBox).Text = _oldValue; return; } if (String.IsNullOrEmpty(newValue) || string.IsNullOrWhiteSpace(newValue)) { var view = new AlertView { DataContext = new AlertViewModel("It Must Have A Name") }; _ = await DialogHost.Show(view, "RootDialog"); (args.EditingElement as TextBox).Text = _oldValue; return; } bachupItem.Name = newValue; (args.EditingElement as TextBox).Text = newValue; MainViewModel.SaveData(); }
private bool CheckRequirements() { if (_name == null) { Message = "Enter a Name"; ShowMessage = true; return(false); } BachupGroup bg = MainViewModel.Bachup.First(group => group.ID == _bachupItem.BachupGroupID); if (bg.DoesItemExist(_name)) { Message = "Item With That Name Exists"; ShowMessage = true; return(false); } ShowMessage = false; return(true); }
private async void DeleteBachup(object parameter) { if (!BachupItem.RunningBachup) { string message = String.Format("Delete {0}", _bachupItem.Name); string submessage = String.Format("This is not reversable. You will lose this bachup item and its history. Source files will remain in place."); var view = new ConfirmChoiceView { DataContext = new ConfirmChoiceViewModel(message, submessage) }; var choice = await DialogHost.Show(view, "RootDialog"); if ((bool)choice == true) { BachupGroup bg = Bachup.ViewModel.MainViewModel.Bachup.Where(o => o.ID.Equals(_bachupItem.BachupGroupID)).Single(); bg.RemoveBachupItem(_bachupItem); MainViewModel.SaveData(); } } // TODO: Show Notification }
public AddDestinationViewModel(BachupGroup bachupGroup) { LinkCommands(); _item = bachupGroup; }