Esempio n. 1
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            VM vm = (VM)selection[0].XenObject;

            Program.Invoke(Program.MainWindow, () => Program.MainWindow.ConsolePanel.setCurrentSource(vm));

            RevertDialog dialog = new RevertDialog(vm, _snapshot.Name());

            if (dialog.ShowDialog() == DialogResult.Yes)
            {
                if (dialog.TakeSnapshot)
                {
                    TakeSnapshotCommand command = new TakeSnapshotCommand(MainWindowCommandInterface, vm);
                    var action = command.GetCreateSnapshotAction();
                    if (action != null)
                    {
                        // if new snapshot taken, then only revert if this succeeded
                        action.Completed += delegate
                        {
                            if (action.Succeeded)
                            {
                                ExecuteRevertAction();
                            }
                        };
                        action.RunAsync();
                    }
                }
                else
                {
                    ExecuteRevertAction();
                }
            }
        }
Esempio n. 2
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            Program.AssertOnEventThread();

            VM  vm = (VM)selection[0].XenObject;
            var snapshotAllowed = vm.allowed_operations.Contains(vm_operations.snapshot);

            Program.MainWindow.ConsolePanel.setCurrentSource(vm);

            using (var dialog = new WarningDialog(string.Format(Messages.SNAPSHOT_REVERT_BLURB, _snapshot.Name()),
                                                  ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
            {
                ShowCheckbox = snapshotAllowed,
                IsCheckBoxChecked = snapshotAllowed,
                CheckboxCaption = Messages.SNAPSHOT_REVERT_NEW_SNAPSHOT
            })
            {
                if (dialog.ShowDialog() != DialogResult.Yes)
                {
                    return;
                }

                if (dialog.IsCheckBoxChecked)
                {
                    TakeSnapshotCommand command = new TakeSnapshotCommand(MainWindowCommandInterface, vm);
                    var action = command.GetCreateSnapshotAction();
                    if (action != null)
                    {
                        // if new snapshot taken, then only revert if this succeeded
                        action.Completed += delegate
                        {
                            if (action.Succeeded)
                            {
                                ExecuteRevertAction();
                            }
                        };
                        action.RunAsync();
                    }
                }
                else
                {
                    ExecuteRevertAction();
                }
            }
        }
Esempio n. 3
0
 private void takeSnapshotToolStripButton_Click(object sender, EventArgs e)
 {
     TakeSnapshotCommand command = new TakeSnapshotCommand(Program.MainWindow, VM);
     command.Execute();
 }
Esempio n. 4
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            VM vm = (VM)selection[0].XenObject;

            Program.Invoke(Program.MainWindow, () => Program.MainWindow.ConsolePanel.setCurrentSource(vm));

            RevertDialog dialog = new RevertDialog(vm, _snapshot.Name);

            if (dialog.ShowDialog() == DialogResult.Yes)
            {
                if (dialog.TakeSnapshot)
                {
                    TakeSnapshotCommand command = new TakeSnapshotCommand(MainWindowCommandInterface, vm);
                    var action = command.GetCreateSnapshotAction();
                    if (action != null)
                    {
                        // if new snapshot taken, then only revert if this succeeded
                        action.Completed += delegate
                        {
                            if (action.Succeeded)
                                ExecuteRevertAction();
                        };
                        action.RunAsync();
                    } 
                }
                else
                {
                    ExecuteRevertAction();
                }
            }
        }