Example #1
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            long newNtol = assignPriorities.Ntol;

            // User has configured ntol to be zero. Check this is what they want (since it is practically useless).
            if (newNtol == 0)
            {
                DialogResult dialogResult;
                using (var dlg = new WarningDialog(Messages.HA_NTOL_ZERO_QUERY,
                                                   ThreeButtonDialog.ButtonYes,
                                                   new ThreeButtonDialog.TBDButton(Messages.NO_BUTTON_CAPTION, DialogResult.No, selected: true))
                {
                    WindowTitle = Messages.HIGH_AVAILABILITY
                })
                {
                    dialogResult = dlg.ShowDialog(this);
                }
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }

            if (assignPriorities.ChangesMade || newNtol != originalNtol)
            {
                // Set the new restart priorities.
                // This includes a pool-wide database sync to ensure the changed HA settings are communicated to all hosts
                new SetHaPrioritiesAction(this.pool.Connection, assignPriorities.GetChangedStartupOptions(), newNtol, false).RunAsync();
            }
            this.Close();
        }
Example #2
0
        private bool AllSelectedHostsConnected()
        {
            var disconnectedServerNames = new List <string>();

            foreach (PatchingHostsDataGridViewRow row in dataGridViewHosts.Rows)
            {
                if ((int)row.Cells[POOL_CHECKBOX_COL].Value > UNCHECKED && row.IsPoolOrStandaloneHost)
                {
                    IXenConnection connection = ((IXenObject)row.Tag).Connection;
                    if (connection == null || !connection.IsConnected)
                    {
                        disconnectedServerNames.Add(((IXenObject)row.Tag).Name());
                    }
                }
            }

            if (disconnectedServerNames.Count > 0)
            {
                using (var dlg = new WarningDialog(string.Format(Messages.UPDATES_WIZARD_DISCONNECTED_SERVER, Helpers.StringifyList(disconnectedServerNames)))
                {
                    WindowTitle = Messages.UPDATES_WIZARD
                })
                {
                    dlg.ShowDialog(this);
                }
                return(false);
            }
            return(true);
        }
Example #3
0
        protected override AsyncAction CreateAction(out bool cancelled)
        {
            AsyncAction action = null;

            if (patch != null && diskSpaceReq.CanCleanup)
            {
                Program.Invoke(Program.MainWindow, delegate()
                {
                    using (var dlg = new WarningDialog(diskSpaceReq.GetSpaceRequirementsMessage(),
                                                       new ThreeButtonDialog.TBDButton(Messages.YES, DialogResult.Yes, selected: true),
                                                       ThreeButtonDialog.ButtonNo))
                    {
                        if (dlg.ShowDialog() == DialogResult.Yes)
                        {
                            action = new CleanupDiskSpaceAction(this.Server, patch, true);
                        }
                    }
                });
            }
            else
            {
                Program.Invoke(Program.MainWindow, delegate()
                {
                    using (var dlg = new WarningDialog(diskSpaceReq.GetSpaceRequirementsMessage()))
                        dlg.ShowDialog();
                });
            }
            cancelled = action == null;

            return(action);
        }
Example #4
0
        private void buttonPassthrough_Click(object sender, EventArgs e)
        {
            if (selectedRow == null)
            {
                return;
            }

            var pusb = selectedRow.Pusb;

            var message = pusb.passthrough_enabled
                ? Messages.DIALOG_USB_USAGE_DISABLE_PASSTHROUGH
                : Messages.DIALOG_USB_USAGE_ENABLE_PASSTHROUGH;

            var yesText = pusb.passthrough_enabled
                ? Messages.DIALOG_USB_USAGE_OKBUTTON_DISABLE
                : Messages.DIALOG_USB_USAGE_OKBUTTON_ENABLE;

            using (var dialog = new WarningDialog(message,
                                                  new ThreeButtonDialog.TBDButton(yesText, DialogResult.Yes, ThreeButtonDialog.ButtonType.ACCEPT, true),
                                                  ThreeButtonDialog.ButtonNo))
            {
                if (dialog.ShowDialog(this) == DialogResult.Yes)
                {
                    new SetUsbPassthroughAction(pusb, !pusb.passthrough_enabled).RunAsync();
                }
            }
        }
        protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel)
        {
            if (direction == PageLoadedDirection.Forward)
            {
                if (!AllSelectedHostsConnected())
                {
                    dataGridView1.Invalidate();
                    cancel = true;
                    return;
                }

                foreach (var selectedMaster in SelectedMasters)
                {
                    if (!(selectedMaster.Connection.Session.IsLocalSuperuser || selectedMaster.Connection.Session.Roles.Any(role => role.name_label == Role.MR_ROLE_POOL_ADMIN)))
                    {
                        using (var dlg = new WarningDialog(string.Format(Messages.RBAC_UPGRADE_WIZARD_MESSAGE,
                                                                         selectedMaster.Connection.Username, selectedMaster.Name()))
                        {
                            WindowTitle = Messages.ROLLING_POOL_UPGRADE
                        })
                        {
                            dlg.ShowDialog(this);
                        }

                        cancel = true;
                        return;
                    }
                }
            }
        }
Example #6
0
        private void WatchForClose(Process _extAppProcess)
        {
            TimeSpan gracePeriod = new TimeSpan(0, 0, (int)_menuItemFeature.ShellCmd.DisposeTime);
            DateTime start       = DateTime.Now;

            while (DateTime.Now - start < gracePeriod)
            {
                if (_extAppProcess.HasExited)
                {
                    return;
                }

                Thread.Sleep(1000);
            }
            if (!_extAppProcess.HasExited)
            {
                Program.Invoke(Program.MainWindow, delegate
                {
                    using (var d = new WarningDialog(string.Format(Messages.FORCE_CLOSE_PLUGIN_PROMPT, _menuItemFeature.ToString()),
                                                     new ThreeButtonDialog.TBDButton(Messages.FORCE_CLOSE, DialogResult.Yes),
                                                     new ThreeButtonDialog.TBDButton(Messages.ALLOW_TO_CONTINUE, DialogResult.No))
                    {
                        HelpNameSetter = "ProcessForceClosePrompt"
                    })
                    {
                        if (d.ShowDialog(Program.MainWindow) == DialogResult.Yes && !_extAppProcess.HasExited)
                        {
                            _extAppProcess.Kill();
                        }
                    }
                });
            }
        }
Example #7
0
        protected override void OnShown(EventArgs e)
        {
            // Check for broken SRs
            List <string> brokenSRs = new List <string>();

            foreach (SR sr in xenConnection.Cache.SRs)
            {
                if (sr.HasPBDs() && sr.IsBroken() && !sr.IsToolsSR() && sr.shared)
                {
                    brokenSRs.Add(sr.NameWithoutHost());
                }
            }

            if (brokenSRs.Count > 0)
            {
                using (var dlg = new WarningDialog(String.Format(Messages.HA_SRS_BROKEN_WARNING, String.Join("\n", brokenSRs.ToArray())))
                {
                    WindowTitle = Messages.HIGH_AVAILABILITY
                })
                {
                    dlg.ShowDialog(this);
                }
            }

            base.OnShown(e);
        }
        private void AddTask()
        {
            WlbEditScheduledTask addTask = new WlbEditScheduledTask(_newTaskId--, WlbScheduledTask.WlbTaskActionType.SetOptimizationMode);
            DialogResult         dr      = addTask.ShowDialog();

            if (DialogResult.OK == dr)
            {
                WlbScheduledTask newTask = addTask.Task;
                newTask.Owner         = _pool.Connection.Username;
                newTask.LastTouchedBy = _pool.Connection.Username;
                newTask.AddTaskParameter("PoolUUID", _pool.uuid);

                WlbScheduledTask checkTask = CheckForDuplicateTask(newTask);
                if (null != checkTask)
                {
                    using (var dlg = new WarningDialog(Messages.WLB_TASK_SCHEDULE_CONFLICT_BLURB)
                    {
                        WindowTitle = Messages.WLB_TASK_SCHEDULE_CONFLICT_TITLE
                    })
                    {
                        dlg.ShowDialog(this);
                    }
                    SelectTask(checkTask.TaskId);
                }
                else
                {
                    _scheduledTasks.TaskList.Add(newTask.TaskId.ToString(), newTask);
                    PopulateListView();
                    _hasChanged = true;
                }
            }
        }
        private void RelocateVmWithHa(AsyncAction action, VM vm, Host host, int start, int end, int recommendationId)
        {
            bool setDoNotRestart = false;

            if (vm.HaPriorityIsRestart())
            {
                try
                {
                    XenAPI.VM.assert_agile(action.Session, vm.opaque_ref);
                }
                catch (Failure)
                {
                    // VM is not agile, but it is 'Protected' by HA. This is an inconsistent state (see CA-20820).
                    // Tell the user the VM will be started without HA protection.
                    Program.Invoke(Program.MainWindow, delegate()
                    {
                        using (var dlg = new WarningDialog(String.Format(Messages.HA_INVALID_CONFIG_RESUME, Helpers.GetName(vm).Ellipsise(500)))
                        {
                            WindowTitle = Messages.HIGH_AVAILABILITY
                        })
                        {
                            dlg.ShowDialog(Program.MainWindow);
                        }
                    });

                    // Set the VM to 'Do not restart'.
                    XenAPI.VM.set_ha_restart_priority(action.Session, vm.opaque_ref, XenAPI.VM.RESTART_PRIORITY_DO_NOT_RESTART);
                    setDoNotRestart = true;
                }
            }

            if (!setDoNotRestart && vm.HasSavedRestartPriority())
            {
                // If HA is turned on, setting ha_always_run will cause the VM to be started by itself
                // but when the VM fails to start we want to know why, so we do a VM.start here too.
                // This will fail with a power state exception if HA has already started the VM - but in
                // that case we don't care, since the VM successfully started already.
                SetHaProtection(true, action, vm, start, end);
                try
                {
                    DoAction(action, vm, host, start, end, recommendationId);
                }
                catch (Failure f)
                {
                    if (f.ErrorDescription.Count == 4 && f.ErrorDescription[0] == Failure.VM_BAD_POWER_STATE && f.ErrorDescription[3] == "running")
                    {
                        // The VM started successfully via HA
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            else
            {
                // HA off: just do a regular start
                DoAction(action, vm, host, start, end, recommendationId);
            }
        }
Example #10
0
        private void deleteSavedSearch_Click(object sender, EventArgs e)
        {
            var item = sender as ToolStripItem;

            if (item == null)
            {
                return;
            }

            var search = item.Tag as Search;

            if (search == null)
            {
                return;
            }

            using (var dlog = new WarningDialog(String.Format(Messages.DELETE_SEARCH_PROMPT, search.Name),
                                                ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
            {
                WindowTitle = String.Format(Messages.DELETE_SEARCH, search.Name)
            })
            {
                if (dlog.ShowDialog(this) == DialogResult.Yes)
                {
                    new SearchAction(search, SearchAction.Operation.delete).RunAsync();
                }
            }
        }
Example #11
0
        private bool Uncompress()
        {
            _unzipFileIn = FilePath;
            if (string.IsNullOrEmpty(_unzipFileIn))
            {
                return(false);
            }

            _unzipFileOut = Path.Combine(Path.GetDirectoryName(_unzipFileIn), Path.GetFileNameWithoutExtension(_unzipFileIn));

            var msg = string.Format(Messages.UNCOMPRESS_APPLIANCE_DESCRIPTION,
                                    Path.GetFileName(_unzipFileOut), Path.GetFileName(_unzipFileIn));

            using (var dlog = new WarningDialog(msg, ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo))
            {
                if (dlog.ShowDialog(this) == DialogResult.Yes)
                {
                    LongProcessWrapper(() => _unzipWorker.RunWorkerAsync(),
                                       string.Format(Messages.IMPORT_WIZARD_UNCOMPRESSING, Path.GetFileName(_unzipFileIn).Ellipsise(50)));
                    return(m_textBoxFile.Text == _unzipFileOut);
                }

                return(false);
            }
        }
        private bool AllSelectedHostsConnected()
        {
            var disconnectedServerNames = new List <string>();

            foreach (UpgradeDataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Checked == CheckState.Checked && ((row.Tag is Host && !row.HasPool) || row.Tag is Pool))
                {
                    IXenConnection connection = ((IXenObject)row.Tag).Connection;

                    if (connection == null || !connection.IsConnected)
                    {
                        disconnectedServerNames.Add(((IXenObject)row.Tag).Name());
                    }
                }
            }

            if (disconnectedServerNames.Count > 0)
            {
                using (var dlg = new WarningDialog(string.Format(Messages.ROLLING_UPGRADE_DISCONNECTED_SERVER, Helpers.StringifyList(disconnectedServerNames)))
                {
                    WindowTitle = Messages.ROLLING_POOL_UPGRADE
                })
                {
                    dlg.ShowDialog(this);
                }
                return(false);
            }
            return(true);
        }
        // TODO:这一块需要后期切换到XMLProcess类中
        // 加载XML
        public void loadXML(string xmlPath)
        {
            if (!System.IO.File.Exists(xmlPath))
            {
                WarningDialog resultNoExist = new WarningDialog("文件不存在", DLLDefine.IconFolder + "Error_96px.png");
                resultNoExist.ShowDialog();
                return;
            }

            XDocument xdoc = XDocument.Load(xmlPath);

            var elements = from n in xdoc.Descendants("device")
                           select new
            {
                name     = n.Element("name").Value,
                type     = n.Element("taskinfo").Element("type").Value,
                subtype1 = n.Element("taskinfo").Element("subtype1").Value,
                subtype2 = n.Element("taskinfo").Element("subtype2").Value,
                number   = n.Element("taskinfo").Element("number").Value,
                startX   = n.Element("roiinfo").Element("startX").Value,
                startY   = n.Element("roiinfo").Element("startY").Value,
                width    = n.Element("roiinfo").Element("width").Value,
                height   = n.Element("roiinfo").Element("height").Value
            };

            dataGridView.DataSource = elements.ToList();

            // 只有在XML加载的时候才能添加
            buttonAppend.Enabled = true;
        }
Example #14
0
        public bool FiberChannelScan(IWin32Window owner, IXenConnection connection, out List <FibreChannelDevice> devices)
        {
            devices = new List <FibreChannelDevice>();

            Host master = Helpers.GetMaster(connection);

            if (master == null)
            {
                return(false);
            }

            var action = new FibreChannelProbeAction(master, SrType);

            using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Marquee))
                dialog.ShowDialog(owner); //Will block until dialog closes, action completed

            if (!action.Succeeded)
            {
                return(false);
            }

            devices = action.FibreChannelDevices;
            if (devices != null && devices.Count > 0)
            {
                return(true);
            }

            using (var dlg = new WarningDialog(Messages.FIBRECHANNEL_NO_RESULTS))
                dlg.ShowDialog();

            return(false);
        }
Example #15
0
        /// <summary>
        /// Called in the 'connect new server and add to pool' action after the server has connected
        /// and its cache has been populated. Adds the new server to the pool.
        /// </summary>
        private void dialog_CachePopulated(IXenConnection conn)
        {
            // A new connection was successfully made: add the new server to its destination pool.
            Host hostToAdd = Helpers.GetMaster(conn);

            if (hostToAdd == null)
            {
                log.Debug("hostToAdd is null while joining host to pool in AddNewHostToPoolCommand: this should never happen!");
                return;
            }

            // Check newly-connected host is not in pool
            Pool hostPool = Helpers.GetPool(conn);

            MainWindowCommandInterface.Invoke(delegate
            {
                if (hostPool != null)
                {
                    string text = String.Format(Messages.HOST_ALREADY_IN_POOL, hostToAdd.Name(), _pool.Name(), hostPool.Name());

                    using (var dlg = new WarningDialog(text)
                    {
                        WindowTitle = Messages.POOL_JOIN_IMPOSSIBLE
                    })
                        dlg.ShowDialog(Program.MainWindow);
                }
                else
                {
                    new AddHostToPoolCommand(MainWindowCommandInterface, new Host[] { hostToAdd }, _pool, false).Execute();
                }
            });
        }
Example #16
0
        /// <summary>
        /// Find which items from a list need some action, and get permission to perform the action.
        /// </summary>
        /// <typeparam name="T">Type of the items</typeparam>
        /// <param name="itemsToFixup">List of items</param>
        /// <param name="msgSingle">Dialog message when one item needs action. {0} will be substituted for the name of the item.</param>
        /// <param name="msgMultiple">Dialog message when more than one item needs action. {0} will be substituted for a list of the items.</param>
        /// <param name="defaultYes">Whether the default button should be Proceed (as opposed to Cancel)</param>
        /// <param name="helpName">Help ID for the dialog</param>
        /// <returns>Whether permission was obtained (also true if no items needed action)</returns>
        public static bool GetPermissionFor <T>(List <T> itemsToFixup, string msgSingle, string msgMultiple, bool defaultYes, string helpName)
        {
            if (Program.RunInAutomatedTestMode)
            {
                return(true);
            }

            if (itemsToFixup.Count > 0)
            {
                string msg = itemsToFixup.Count == 1
                    ? string.Format(msgSingle, itemsToFixup[0])
                    : string.Format(msgMultiple, string.Join("\n", itemsToFixup.ConvertAll(item => item.ToString()).ToArray()));

                using (var dlg = new WarningDialog(msg,
                                                   new ThreeButtonDialog.TBDButton(Messages.PROCEED, DialogResult.Yes, selected: defaultYes),
                                                   new ThreeButtonDialog.TBDButton(Messages.CANCEL, DialogResult.No, selected: !defaultYes))
                {
                    HelpName = helpName
                })
                {
                    return(dlg.ShowDialog(Program.MainWindow) == DialogResult.Yes);
                }
            }
            return(true);
        }
Example #17
0
        /// <summary>
        /// 按钮点击事件(导航到假条保存界面)
        /// </summary>
        private async void button_ok_Click(object sender, RoutedEventArgs e)
        {
            SetArg();
            if (CheckArg() == true)
            {
                if (IsFinished())
                {
                    await isLongTimeDialong.ShowAsync();
                }
                else
                {
                    checkDataDialong = new CheckDataDialog(arg);
                    checkDataDialong.PrimaryButtonClick += new TypedEventHandler <ContentDialog, ContentDialogButtonClickEventArgs>(CheckDate_PrimaryButton);
                    await checkDataDialong.ShowAsync();

                    await isLongTimeDialong.ShowAsync();
                }
            }
            else
            {
                //重置参数
                arg = new Arg();

                //显示ContentDialog
                var warningDialog = new WarningDialog();
                await warningDialog.ShowAsync();
            }
        }
Example #18
0
        /**
         * Ensures that the "cfg" and "custom" folders exist under the "tf" directory. If not, they
         * will be silently created. If an attempted creation fails, the user will be alerted with
         * a dialog box.
         *
         * path: The path to the "tf" folder.
         *
         * Returns false if an attempt to create the appropriate subdirectories fails.
         * Throws an Exception if an unexpected error occurs.
         */
        private static bool VerifyTFSubdirectories(String path)
        {
            String cfg    = Path.Combine(path, "cfg");
            String custom = Path.Combine(path, "custom");

            // Despite being idempotent, only attempt the creation of the subdirectories if they are
            // confirmed to be missing. This is to reduce the chances of running into an exception.
            if (!Directory.Exists(cfg) || !Directory.Exists(custom))
            {
                try {
                    Directory.CreateDirectory(cfg);
                    Directory.CreateDirectory(custom);
                }
                catch (Exception) {
                    var dialog = new WarningDialog();
                    dialog.Display("The TF2 install path is missing the 'cfg' or 'custom' folder."
                                   + " The installer attempted to create this for you, but was"
                                   + " unable. Please open your 'Team Fortress 2\\tf' directory and"
                                   + " create these two folders, then re-run the installer.");
                    return(false);
                }
            }

            return(true);
        }
Example #19
0
        protected override AsyncAction CreateAction(out bool cancelled)
        {
            Program.AssertOnEventThread();

            DialogResult dialogResult;

            using (var dlg = new WarningDialog(string.Format(Messages.CONFIRM_DELETE_VM, VM.Name(), VM.Connection.Name),
                                               ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
            {
                WindowTitle = Messages.ACTION_SHUTDOWN_AND_DESTROY_VM_TITLE
            })
            {
                dialogResult = dlg.ShowDialog();
            }
            if (dialogResult == DialogResult.Yes)
            {
                cancelled = false;
                List <VM> vms = new List <VM> {
                    VM
                };
                return(new ShutdownAndDestroyVMsAction(VM.Connection, vms));
            }

            cancelled = true;
            return(null);
        }
Example #20
0
        public VMSnapshotCreateAction GetCreateSnapshotAction()
        {
            if (GetSelection().ContainsOneItemOfType <VM>())
            {
                VM vm = (VM)GetSelection()[0].XenObject;

                if (CanExecute(vm))
                {
                    using (VmSnapshotDialog dialog = new VmSnapshotDialog(vm))
                    {
                        if (dialog.ShowDialog(Parent) != DialogResult.Cancel && dialog.SnapshotName != null)
                        {
                            Program.Invoke(Program.MainWindow, () => Program.MainWindow.ConsolePanel.setCurrentSource(vm));
                            return(new VMSnapshotCreateAction(vm, dialog.SnapshotName, dialog.SnapshotDescription, dialog.SnapshotType,
                                                              (vmToSnapshot, username, password) =>
                                                              Program.MainWindow.ConsolePanel.Snapshot(
                                                                  vmToSnapshot, username, password)));
                        }
                    }
                }
                else
                {
                    using (var dlg = new WarningDialog(Messages.TAKE_SNAPSHOT_ERROR))
                        dlg.ShowDialog(MainWindowCommandInterface.Form);
                }
            }
            return(null);
        }
Example #21
0
        private ChangeMemorySettingsAction ConfirmAndCalcActions(long mem)
        {
            if (vm.memory_static_max / Util.BINARY_MEGA == mem / Util.BINARY_MEGA)
            {
                // don't want to show warning dialog just for rounding errors
                mem = vm.memory_static_max;
            }
            else if (vm.power_state != vm_power_state.Halted)
            {
                var msg = vm.has_ballooning() && !Helpers.FeatureForbidden(vm, Host.RestrictDMC)
                    ? Messages.CONFIRM_CHANGE_MEMORY_MAX_SINGULAR
                    : Messages.CONFIRM_CHANGE_MEMORY_SINGULAR;

                using (var dlg = new WarningDialog(msg,
                                                   ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo))
                {
                    if (dlg.ShowDialog(this) != DialogResult.Yes)
                    {
                        return(null);
                    }
                }
            }

            return(new ChangeMemorySettingsAction(vm,
                                                  string.Format(Messages.ACTION_CHANGE_MEMORY_SETTINGS, vm.Name()),
                                                  vm.memory_static_min, mem, mem, mem,
                                                  VMOperationCommand.WarningDialogHAInvalidConfig, VMOperationCommand.StartDiagnosisForm, true));
        }
        // 添加设备按钮
        private void buttonAppend_Click(object sender, EventArgs e)
        {
            comBoxItem comtype = (comBoxItem)comboBoxType.SelectedItem;
            comBoxItem comsub1 = (comBoxItem)comboBoxsub1.SelectedItem;
            comBoxItem comsub2 = (comBoxItem)comboBoxsub2.SelectedItem;
            TaskInfo   task    = new TaskInfo(comtype.Value, comsub1.Value, comsub2.Value, (int)numericUpDownnum.Value);

            ROIInfo roi = new ROIInfo((uint)numericUpDownStartX.Value, (uint)numericUpDownStartY.Value, (uint)numericUpDownwidth.Value, (uint)numericUpDownheight.Value);

            string devicename = textBoxgetname.Text;

            // 需要另外增添的文本
            string AddtitionCnotext = null;

            if (DLLDefine.sg_task_pointer == comtype.Value)
            {
                AddtitionCnotext = ((int)numericUpDownpointerLow.Value).ToString() + "," + ((int)numericUpDownPointerhigh.Value).ToString() + "," + textBoxpointerUnit.Text;
            }
            else if (DLLDefine.sg_task_knob == comtype.Value)
            {
                AddtitionCnotext = richTextBoxKnobitem.Text;
            }


            xmlProcess.appendDevice(textBoxXMLpath.Text, devicename, task, roi, AddtitionCnotext);

            loadXML(textBoxXMLpath.Text);
            WarningDialog resultOK = new WarningDialog("添加成功");

            resultOK.ShowDialog();
        }
Example #23
0
        private void toolStripButtonCancel_Click(object sender, EventArgs e)
        {
            if (dataGridViewConversions.SelectedRows.Count == 1 && dataGridViewConversions.SelectedRows[0] is ConversionRow row)
            {
                using (var dlog = new WarningDialog(Messages.CONVERSION_CANCEL_CONFIRM,
                                                    ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo))
                {
                    if (dlog.ShowDialog(this) == DialogResult.No)
                    {
                        return;
                    }
                }

                ThreadPool.QueueUserWorkItem(obj =>
                {
                    try
                    {
                        _conversionClient.CancelConversion(row.Conversion);
                    }
                    catch (Exception ex)
                    {
                        log.Error($"Cannot cancel conversion {row.Conversion.Id}.", ex);

                        Program.Invoke(this, () =>
                        {
                            statusLabel.Image = Images.StaticImages._000_error_h32bit_16;
                            statusLabel.Text  = Messages.CONVERSION_CANCEL_FAILURE;
                            statusLinkLabel.Reset();
                        });
                    }
                });
            }
        }
Example #24
0
        /// <summary>
        /// Shows a confirmation dialog.
        /// </summary>
        /// <returns>True if the user clicked Yes.</returns>
        private bool ShowConfirmationDialog()
        {
            if (Program.RunInAutomatedTestMode)
            {
                return(true);
            }

            var buttonYes = new ThreeButtonDialog.TBDButton(
                string.IsNullOrEmpty(ConfirmationDialogYesButtonLabel) ? Messages.YES_BUTTON_CAPTION : ConfirmationDialogYesButtonLabel,
                DialogResult.Yes);

            var buttonNo = new ThreeButtonDialog.TBDButton(
                string.IsNullOrEmpty(ConfirmationDialogNoButtonLabel) ? Messages.NO_BUTTON_CAPTION : ConfirmationDialogNoButtonLabel,
                DialogResult.No,
                selected: ConfirmationDialogNoButtonSelected);

            using (var dialog = new WarningDialog(ConfirmationDialogText, buttonYes, buttonNo)
            {
                WindowTitle = ConfirmationDialogTitle
            })
            {
                if (!string.IsNullOrEmpty(ConfirmationDialogHelpId))
                {
                    dialog.HelpNameSetter = ConfirmationDialogHelpId;
                }

                return(dialog.ShowDialog(Parent ?? Program.MainWindow) == DialogResult.Yes);
            }
        }
Example #25
0
        private void toolStripButtonClear_Click(object sender, EventArgs e)
        {
            using (var dlog = new WarningDialog(Messages.CONVERSION_CLEAR_HISTORY_CONFIRM,
                                                ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo))
            {
                if (dlog.ShowDialog(this) == DialogResult.No)
                {
                    return;
                }
            }

            toolStripButtonClear.Enabled = false;

            ThreadPool.QueueUserWorkItem(obj =>
            {
                try
                {
                    _conversionClient.ClearConversionHistory();
                }
                catch (Exception ex)
                {
                    log.Error("Cannot clear conversion history.", ex);

                    Program.Invoke(this, () =>
                    {
                        statusLabel.Image = Images.StaticImages._000_error_h32bit_16;
                        statusLabel.Text  = Messages.CONVERSION_CLEAR_HISTORY_FAILURE;
                        statusLinkLabel.Reset();
                        toolStripButtonClear.Enabled = true;
                    });
                }
            });
        }
        private void EditTask(WlbScheduledTask task)
        {
            WlbScheduledTask     editTask   = task.Clone();
            WlbEditScheduledTask taskEditor = new WlbEditScheduledTask(editTask);
            DialogResult         dr         = taskEditor.ShowDialog();

            if (DialogResult.OK == dr)
            {
                WlbScheduledTask checkTask = CheckForDuplicateTask(editTask);
                if (null != checkTask)
                {
                    using (var dlg = new WarningDialog(Messages.WLB_TASK_SCHEDULE_CONFLICT_BLURB)
                    {
                        WindowTitle = Messages.WLB_TASK_SCHEDULE_CONFLICT_TITLE
                    })
                    {
                        dlg.ShowDialog(this);
                    }
                    SelectTask(checkTask.TaskId);
                }
                else
                {
                    editTask.LastTouchedBy = _pool.Connection.Username;
                    editTask.LastTouched   = DateTime.UtcNow;
                    _scheduledTasks.TaskList[editTask.TaskId.ToString()] = editTask;
                    PopulateListView();
                    _hasChanged = true;
                }
            }
        }
        private void CheckDiskSpace(IXenConnection conn, Session session, string path)
        {
            try
            {
                var checkSpaceForUpload = new CheckDiskSpaceForPatchUploadAction(Helpers.GetMaster(conn), path, true);
                inProgressAction = checkSpaceForUpload;
                checkSpaceForUpload.RunExternal(session);
            }
            catch (NotEnoughSpaceException e)
            {
                if (!e.DiskSpaceRequirements.CanCleanup)
                {
                    throw;
                }

                var dialogResult = Program.Invoke(invokingControl, (Func <DialogResult>)(() =>
                {
                    using (var d = new WarningDialog(e.DiskSpaceRequirements.GetSpaceRequirementsMessage(),
                                                     ThreeButtonDialog.ButtonOK, ThreeButtonDialog.ButtonCancel))
                    {
                        return(d.ShowDialog(invokingControl));
                    }
                }
                                                                                         ), null);

                if (dialogResult is DialogResult dr && dr == DialogResult.OK)
                {
                    new CleanupDiskSpaceAction(e.DiskSpaceRequirements.Host, null, true).RunExternal(session);
                }
 private void EnableTask(WlbScheduledTask task)
 {
     //If we are trying to enable the task, check to see if it is a duplicate before allowing it
     if (!task.Enabled)
     {
         //We need to pretend the task is enabled to check for duplicates
         WlbScheduledTask enabledTask = task.Clone();
         enabledTask.Enabled = true;
         WlbScheduledTask checkTask = CheckForDuplicateTask(enabledTask);
         //if it's a duplicate task, display warning and return
         if (null != checkTask)
         {
             using (var dlg = new WarningDialog(Messages.WLB_TASK_SCHEDULE_CONFLICT_BLURB)
             {
                 WindowTitle = Messages.WLB_TASK_SCHEDULE_CONFLICT_TITLE
             })
             {
                 dlg.ShowDialog(this);
             }
             SelectTask(checkTask.TaskId);
             return;
         }
     }
     task.Enabled = !task.Enabled;
     PopulateListView();
     _hasChanged = true;
 }
        private void BtInstall_Click(object sender, RoutedEventArgs e)
        {
            var ww = new WarningDialog
            {
                ShowActivated = true,
                Owner         = Application.Current.MainWindow,
            };

            ww.ShowDialog();

            if (ww.Abort)
            {
                return;
            }

            ScheduleGrid.IsEnabled     = false;
            BtInstall.IsEnabled        = false;
            DetailsExpander.IsExpanded = false;
            DetailsExpander.IsEnabled  = false;
            SetStatus(ScheduleStatus.Orange);

            SqlCe.SetAutoEnforceFlag(true);
            SqlCe.DeleteServiceSchedule();
            SqlCe.UpdateSupData("STD", string.Empty);

            CcmUtils.InstallAllAppsAndUpdates();

            if (_pipeClient == null)
            {
                _pipeClient = new PipeClient();
            }

            _pipeClient.Send("SetRed", "01DB94E3-90F1-43F4-8DDA-8AEAF6C08A8E");
            Globals.Log.Information("Sent icon switch command to tray.");
        }
        private void SkipFailedActions()
        {
            var skippableWorkers = failedWorkers.Where(w => w.FirstFailedSkippableAction != null).ToList();
            var msg = string.Join(Environment.NewLine, skippableWorkers.Select(w => w.FirstFailedSkippableAction.Title));

            using (var dlg = new WarningDialog(string.Format(skippableWorkers.Count > 1 ? Messages.MESSAGEBOX_SKIP_RPU_STEPS : Messages.MESSAGEBOX_SKIP_RPU_STEP, msg),
                                               ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
            {
                WindowTitle = ParentForm != null ? ParentForm.Text : Messages.XENCENTER
            })
            {
                if (dlg.ShowDialog(this) != DialogResult.Yes)
                {
                    return;
                }
            }

            panel1.Visible = false;

            foreach (var worker in skippableWorkers)
            {
                failedWorkers.Remove(worker);
                worker.RunWorkerAsync();
            }

            _thisPageIsCompleted = false;
            _cancelEnabled       = true;
            OnPageUpdated();
        }
Example #31
0
 protected virtual void OnDelUserClicked(object sender, System.EventArgs e)
 {
     if (ftreeviewUsers.IsSelected())
     {
     lock(_helper)
     {
         _helper.User = (User)ftreeviewUsers.SelectedObject;
         _helper.StartAsyncCall(_helper.DeleteUser);
     }
     }
     else
     {
     WarningDialog wdialog = new WarningDialog();
     wdialog.Message = "Please select an user first";
     wdialog.Present();
     }
 }
 public override void PopulateGUI()
 {
     if (logon)
     {
         if (loginEvent != null)
         {
             loginEvent(this, null);
         }
     }
     else
     {
         WarningDialog wd = new WarningDialog();
         wd.Message = "Login incorrect";
         wd.Run();
         Gtk.Application.Quit();
     }
 }
 protected void Logged()
 {
     if (logon)
     {
         waitWindow.Hide();
         waitWindow.Stop();
         waitWindow.Destroy();
         loginEvent();
     }
     else
     {
         waitWindow.Hide();
         waitWindow.Stop();
         waitWindow.Destroy();
         WarningDialog wd = new WarningDialog();
         if (!connectionFailure)
         {
             //wd. a.textviewDesc.Buffer.Text = "Nombre de Usuario o Contraseña erróneos";
             //a.labelMsg.Text = "Error: Acceso Denegado";
         }
         wd.Present();
     }
 }
        private async void FaceDetectionButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            // Inform the user if we do not have a Microsoft face service key and then exit without doing anything
            if (AppSettings.FaceApiKey == "")
            {
                var messageDialog = new Windows.UI.Popups.MessageDialog("You need a Microsoft Face API service key, which you define in settings, to use facial recognition.");
                await messageDialog.ShowAsync();
                return;
            }
       
            if (SetCameraButton.IsEnabled)
            {
                // Make sure the user accepts privacy implications.
                var dialog = new WarningDialog();
                await dialog.ShowAsync();
                if (dialog.WarningAccept == false)
                {
                    return;
                }
            }

            bool result = await _presence.EnableFaceDetection();
            if (result)
            {
                _presence.FilterOnFace += UserFilterFromDetection;
                CountBox.Visibility = Visibility.Visible;
                if (!_currentlyFiltered)
                {
                    ImageWarningBox.Visibility = Visibility.Visible;
                }
            }
            else
            {
                _presence.FilterOnFace -= UserFilterFromDetection;
                CountBox.Visibility = Visibility.Collapsed;
                ImageWarningBox.Visibility = Visibility.Collapsed;
            }

            // Update the face detection icon depending on whether the effect exists or not
            FaceDetectionDisabledIcon.Visibility = (result != true) ? Visibility.Visible : Visibility.Collapsed;
            FaceDetectionEnabledIcon.Visibility = (result == true) ? Visibility.Visible : Visibility.Collapsed;
            SetCameraButton.IsEnabled = (result != true);
        }
 private void TransferCompleted(object sender, EventArgs e)
 {
     ResponsiveEnum transferType = (ResponsiveEnum)sender;
     waitDialog.Stop();
     waitDialog.Destroy();
     if (transferSuccess) // FIXME: transferSuccess must be syncrhonized
      	{
         if (transferType == ResponsiveEnum.Read)
         {
             this.PopulateGUI(); // FIXME: this could freeze, it is not resonsible
         }
         else
         {
             InfoDialog idialog = new InfoDialog();
             idialog.Message = "Operation Sucess";
             idialog.Present();
         }
         if (parentWindow != null)
         {
             parentWindow.Present();
         }
     }
     else
     {
         warningDialog = new WarningDialog();
         string msg = "";
         foreach (string i in exceptionsMsgPool.Values)
             msg += i + "\n";
      		warningDialog.Message = msg;
      		warningDialog.QuitOnOk = false;
         warningDialog.Present();
      	}
      	if (this.transferCompleteEventHandler != null)
      	{
      	    transferCompleteEventHandler(sender, (ThreadEventArgs)e);
      	}
     OnAsyncCallStop(sender, (ThreadEventArgs)e);
 }