예제 #1
0
 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;
     }
 }
예제 #2
0
        private void Add(object parameter)
        {
            if (CheckRequirements())
            {
                BachupGroup bg = new BachupGroup(Name);

                DialogHost.CloseDialogCommand.Execute(bg, null);
            }
        }
예제 #3
0
        public EditBachupGroupViewModel(BachupGroup bg)
        {
            CancelCommand = new RelayCommand(Cancel);
            SaveCommand   = new RelayCommand(Save);

            ShowMessage  = false;
            Message      = "";
            _bachupGroup = bg;
            Name         = bg.Name;
        }
예제 #4
0
        public AddBachupItemViewModel(BachupGroup bachupGroup)
        {
            AddCommand             = new RelayCommand(Add);
            CancelCommand          = new RelayCommand(Cancel);
            AddSourceFileCommand   = new RelayCommand(AddSourceFile);
            AddSourceFolderCommand = new RelayCommand(AddSourceFolder);


            _bachupGroup = bachupGroup;
            ShowMessage  = false;
        }
예제 #5
0
        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();
        }
예제 #6
0
        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();
        }
예제 #7
0
        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);
        }
예제 #8
0
        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
        }
예제 #9
0
 public AddDestinationViewModel(BachupGroup bachupGroup)
 {
     LinkCommands();
     _item = bachupGroup;
 }