Exemplo n.º 1
0
 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     if (newPoolDialog == null || newPoolDialog.IsDisposed)
     {
         newPoolDialog = new NewPoolDialog(selection.AsXenObjects <Host>());
         newPoolDialog.Show(Program.MainWindow);
     }
     else
     {
         HelpersGUI.BringFormToFront(newPoolDialog);
     }
 }
Exemplo n.º 2
0
        private static void AddError(Form owner, IXenConnection connection, string error, string solution)
        {
            string text = string.Format(Messages.MESSAGEBOX_ERRORTEXT, ((XenConnection)connection).Hostname, error, solution);

            // first check if there is already a dialog showing the same error (CA-97070, CA-88901)
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof(ThreeButtonDialog))
                {
                    ThreeButtonDialog dlg = (ThreeButtonDialog)form;
                    if (dlg.Message == text && dlg.Owner == owner)
                    {
                        HelpersGUI.BringFormToFront(form);
                        return;
                    }
                }
            }

            if (((XenConnection)connection).fromDialog)
            {
                DialogResult dialogResult;
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(SystemIcons.Error, text, Messages.CONNECT_TO_SERVER),
                           new ThreeButtonDialog.TBDButton(Messages.RETRY_BUTTON_LABEL, DialogResult.Retry, ThreeButtonDialog.ButtonType.ACCEPT, true),
                           ThreeButtonDialog.ButtonCancel))
                {
                    dialogResult = dlg.ShowDialog(owner);
                }
                if (DialogResult.Retry == dialogResult)
                {
                    new AddServerDialog(connection, false).Show(owner);
                }
            }
            else
            {
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(
                               SystemIcons.Error,
                               text,
                               Messages.CONNECT_TO_SERVER)))
                {
                    dlg.ShowDialog(owner);
                }
            }
        }
Exemplo n.º 3
0
        private void Execute(Host host, string filepath)
        {
            HelpersGUI.BringFormToFront(MainWindowCommandInterface.Form);

            if (filepath == "")
            {
                // Showing this dialog has the (undocumented) side effect of changing the working directory
                // to that of the file selected. This means a handle to the directory persists, making
                // it undeletable until the program exits, or the working dir moves on. So, save and
                // restore the working dir...
                String oldDir = "";
                try
                {
                    oldDir = Directory.GetCurrentDirectory();
                    OpenFileDialog dialog = new OpenFileDialog();
                    dialog.AddExtension     = true;
                    dialog.Filter           = string.Format("{0} (*.{1})|*.{1}|{2} (*.*)|*.*", Messages.XS_BACKUP_FILES, Branding.BACKUP, Messages.ALL_FILES);
                    dialog.FilterIndex      = 0;
                    dialog.RestoreDirectory = true;
                    dialog.DefaultExt       = Branding.BACKUP;
                    dialog.CheckPathExists  = false;
                    if (dialog.ShowDialog(Parent) == DialogResult.Cancel)
                    {
                        return;
                    }
                    filepath = dialog.FileName;
                }
                finally
                {
                    Directory.SetCurrentDirectory(oldDir);
                }
            }

            if (host == null)
            {
                SelectHostDialog hostdialog = new SelectHostDialog
                {
                    TheHost      = host,
                    TopBlurb     = Messages.BACKUP_SELECT_HOST,
                    TopPicture   = Images.StaticImages.backup_restore_32,
                    HelpString   = "Backup", // don't i18n
                    Text         = Messages.BACKUP_SELECT_HOST_TITLE,
                    OkButtonText = Messages.BACKUP_SELECT_HOST_BUTTON
                };

                hostdialog.FormClosed += delegate
                {
                    if (hostdialog.DialogResult != DialogResult.OK)
                    {
                        return;
                    }
                    host = hostdialog.TheHost;
                    HostBackupRestoreAction action = new HostBackupRestoreAction(host, HostBackupRestoreAction.HostBackupRestoreType.restore, filepath);
                    action.Completed += RestoreAction_Completed;
                    action.RunAsync();
                };
                hostdialog.Show(Parent);
            }
            else
            {
                HostBackupRestoreAction action = new HostBackupRestoreAction(host, HostBackupRestoreAction.HostBackupRestoreType.restore, filepath);
                action.Completed += RestoreAction_Completed;
                action.RunAsync();
            }
        }
Exemplo n.º 4
0
 public void BringToFront()
 {
     HelpersGUI.BringFormToFront(_owner);
 }