public void Show(string sMsg, string sTitle, MsgBoxButton enBtn, string sText) { _bShowTextBox = true; this.sText = sText; _ui_tbText.IsReadOnly = false; this.Show(sMsg, sTitle, enBtn); }
private async Task <MsgBoxButton> DisplayMessage(string message, MsgBoxButton button, int height) { MsgBox.SetButtons(button); MsgBox.Message = message; MsgBox.BoxHeight = height; return(await MsgBox.Show()); }
private async void button_StartSearch_Tapped(object sender, TappedRoutedEventArgs e) { // Проверим что выбран хотя бы один атрибут файла для сравнения при поиске дубликатов if (!(_dataModel.FileCompareOptions.CheckName || _dataModel.FileCompareOptions.CheckSize || _dataModel.FileCompareOptions.CheckContent || _dataModel.FileCompareOptions.CheckCreationDateTime || _dataModel.FileCompareOptions.CheckModificationDateTime)) { await DisplayMessage(_resldr.GetString("NoFileCompareAttributesChecked"), MsgBoxButton.Close, 150); return; } // Проверим есть ли результат предыдущего поиска и если есть покажем предупреждающее сообщение if (_dataModel.DuplicatesCount > 0) { MsgBoxButton pressedbutton = await DisplayMessage(_resldr.GetString("DuplicatedAlreadyFound"), MsgBoxButton.Yes | MsgBoxButton.No, 150); if (pressedbutton == MsgBoxButton.No) { return; } } DisableComandButtons(); await _dataModel.StartSearch(_dataModel.FileCompareOptions.GrouppingAttributes); RequesViewChange(View.SearchResults); }
public void Show(string sMsg, string sTitle, MsgBoxButton enBtn) { _sMsg = sMsg; _sTitle = sTitle; _enBtn = enBtn; this.Show(); }
public MsgBox(string sMsg, string sTitle, MsgBoxButton enBtn) { InitializeComponent(); //this.SizeChanged += new SizeChangedEventHandler(MsgBox_SizeChanged); _sMsg = sMsg; _sTitle = sTitle; _enBtn = enBtn; }
private void AllButton_Click(object sender, RoutedEventArgs e) { if (IsInputCorrect()) { enMsgResult = MsgBoxButton.ALL; this.DialogResult = true; } }
public MsgBoxButton Show(string message, MsgBoxButton buttons = MsgBoxButton.OK, Window ownerWindow = null) { MsgBoxDlg win; MsgBoxVM vm; Create(message, buttons, false, ownerWindow, out win, out vm); win.ShowDialog(); return(win.ClickedButton); }
public MsgBox(Type enType) { if (enType == Type.FileDuration) { InitializeComponent(); _sMsg = g.Controls.sNoticeMsgBox1 + "."; _sTitle = g.Common.sFileTimings; _enBtn = MsgBoxButton.OKALLCancel; _enType = enType; } }
void Create(string message, MsgBoxButton buttons, bool hasDontShowAgain, Window ownerWindow, out MsgBoxDlg win, out MsgBoxVM vm) { win = new MsgBoxDlg(); var winTmp = win; vm = new MsgBoxVM(message, button => winTmp.Close(button)); vm.HasDontShowAgain = hasDontShowAgain; vm.HasOKButton = (buttons & MsgBoxButton.OK) != 0; vm.HasYesButton = (buttons & MsgBoxButton.Yes) != 0; vm.HasNoButton = (buttons & MsgBoxButton.No) != 0; vm.HasCancelButton = (buttons & MsgBoxButton.Cancel) != 0; win.DataContext = vm; win.Owner = ownerWindow ?? appWindow.MainWindow; }
public bool ClickNagMessageBox(string messageBoxCaption, MsgBoxButton button = MsgBoxButton.OK, int maxAttempts = 10) { if (!hasStarted || isFinished || process == null || process.HasExited) { return(false); } var hwnd = IntPtr.Zero; var attempts = 0; do { hwnd = WinAPI.GetHWNDFromPID(process.Id, messageBoxCaption); attempts++; Thread.Sleep(10); } while (hwnd == IntPtr.Zero && attempts < maxAttempts); if (hwnd == IntPtr.Zero || attempts == maxAttempts) { return(false); } else { string strBtn = ""; switch (button) { case MsgBoxButton.OK: strBtn = MSGBOX_OK; break; case MsgBoxButton.YES: strBtn = MSGBOX_YES; break; case MsgBoxButton.NO: strBtn = MSGBOX_NO; break; } attempts = 0; while (!WinAPI.ControlClick(hwnd, strBtn) && attempts < maxAttempts) { Thread.Sleep(100); attempts++; } return(attempts != maxAttempts); } }
public MsgBoxButton?ShowIgnorableMessage(Guid guid, string message, MsgBoxButton buttons, Window?ownerWindow) { if (ignoredMessages.Contains(guid)) { return(null); } Create(message, buttons, true, ownerWindow, out var win, out var vm); win.ShowDialog(); if (win.ClickedButton != MsgBoxButton.None && vm.DontShowAgain) { ignoredMessages.Add(guid); SaveSettings(); } return(win.ClickedButton); }
/// <summary> /// メッセージボックスにボタンを追加する。 /// </summary> /// <returns>メッセージボックスのインスタンス</returns> /// <param name="type">ボタンの種類</param> /// <param name="text">ボタンの文字列</param> /// <param name="action">ボタンを押した時の処理</param> public MsgBox Button(MsgBoxButton type, string text, UnityAction action) { var g = GameObject.Instantiate(ButtonPrototypes[(int)type], ButtonGroup.transform); var gButton = g.GetComponentInChildren <Button>(); var gText = g.GetComponentInChildren <Text>(); gButton.onClick.AddListener(() => { Hide(); action(); }); gText.text = text; g.SetActive(true); ButtonList.Add(g); return(this); }
private void OKButton_Click(object sender, RoutedEventArgs e) { if (null != sText) { sText = _ui_tbText.Text; } if (_bShowDateTimePicker) { dtSelectedDateTime = new DateTime(((DateTime)_ui_dtpDateTime.SelectedDate).Year, ((DateTime)_ui_dtpDateTime.SelectedDate).Month, ((DateTime)_ui_dtpDateTime.SelectedDate).Day, ((DateTime)_ui_tmpDateTime.Value).Hour, ((DateTime)_ui_tmpDateTime.Value).Minute, ((DateTime)_ui_tmpDateTime.Value).Second); } if (IsInputCorrect()) { enMsgResult = MsgBoxButton.OK; this.DialogResult = true; } }
void Create(string message, MsgBoxButton buttons, bool hasDontShowAgain, Window ownerWindow, out MsgBoxDlg win, out MsgBoxVM vm) { win = new MsgBoxDlg(); var winTmp = win; vm = new MsgBoxVM(message, button => winTmp.Close(button)); vm.HasDontShowAgain = hasDontShowAgain; vm.HasOKButton = (buttons & MsgBoxButton.OK) != 0; vm.HasYesButton = (buttons & MsgBoxButton.Yes) != 0; vm.HasNoButton = (buttons & MsgBoxButton.No) != 0; vm.HasCancelButton = (buttons & MsgBoxButton.Cancel) != 0; win.DataContext = vm; win.Owner = ownerWindow ?? appWindow.MainWindow; var vmTmp = vm; win.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, (s, e) => CopyText(vmTmp))); }
public void SetButtons(MsgBoxButton buttons) { ButtonsPanel.Children.Clear(); foreach (MsgBoxButton b in (MsgBoxButton[])Enum.GetValues(typeof(MsgBoxButton))) { if (buttons.HasFlag(b)) { Button newButton = new Button(); newButton.Name = b.ToString(); newButton.Content = b.ToString(); newButton.Width = Math.Max(b.ToString().Length, 5) * 12 + 20; newButton.Style = Application.Current.Resources["CmdButtonStyle"] as Style; newButton.Tapped += button_Tapped; ButtonsPanel.Children.Add(newButton); } } }
/// <summary> /// Shows a message describing the logs (if any) /// </summary> private static void ShowLogMessage(Form owner, IReadOnlyList <ProgressReporter.LogRecord> logs) { if (logs.Count == 1) { // One line messagebox if one log var l = logs[0]; FrmMsgBox.Show(owner, l.Level, l.Message); } else if (logs.Count != 0) { // Messagebox with "details" buttons for multiple logs // (Messagebox icon reflects the highest log level) StringBuilder sb = new StringBuilder(); DataSet <ProgressReporter.LogRecord> ds = new DataSet <ProgressReporter.LogRecord>() { ListSource = logs, ListTitle = "Logs", HandleEdit = DisplayLog, }; ELogLevel max = logs.Max(z => z.Level); string msg; MsgBoxButton[] bts; if (max == ELogLevel.Information) { msg = "Update complete."; bts = new MsgBoxButton[] { new MsgBoxButton(DialogResult.OK), new MsgBoxButton("Details", Resources.MnuNext, DialogResult.Cancel) }; } else { msg = $"One or more {max.ToUiString().ToLower()}s were reported."; bts = new MsgBoxButton[] { new MsgBoxButton("Details", Resources.MnuNext, DialogResult.Cancel), new MsgBoxButton("Ignore", Resources.MnuCancel, DialogResult.OK) }; } if (FrmMsgBox.Show(owner, max.ToUiString(), null, msg, FrmMsgBox.GetIcon(max), bts) == DialogResult.Cancel) { ds.ShowListEditor(owner, FrmBigList.EShow.ReadOnly, null); } } }
public static MessageBoxButton GetButtons4Message(MsgBoxButton buttons) { switch (buttons) { case MsgBoxButton.OK: return(MessageBoxButton.OK); case MsgBoxButton.OKCancel: return(MessageBoxButton.OKCancel); case MsgBoxButton.YesNoCancel: return(MessageBoxButton.YesNoCancel); case MsgBoxButton.YesNo: return(MessageBoxButton.YesNo); default: return(MessageBoxButton.OK); } }
public MsgBox(string sMsg, string sTitle, MsgBoxButton enBtn, DateTime dtMinDate, DateTime dtMaxDate, DateTime dtSelected) : this(sMsg, sTitle, enBtn) { _ui_tmpDateTime.ValueChanged -= _ui_tmpDateTime_ValueChanged; _ui_tmpDateTime.ValueChanged += new RoutedPropertyChangedEventHandler<DateTime?>(_ui_tmpDateTime_ValueChanged); _ui_dtpDateTime.DisplayDateStart = dtMinDate; _ui_dtpDateTime.DisplayDateEnd = dtMaxDate; if (dtSelected < dtMinDate) { _ui_dtpDateTime.SelectedDate = dtMinDate; _ui_tmpDateTime.Value = dtMinDate; } else { _ui_dtpDateTime.SelectedDate = dtSelected; _ui_tmpDateTime.Value = dtSelected; } //_ui_tmpDateTime.Minimum = dtMinDate; //_ui_tmpDateTime.Maximum = dtMaxDate; _bShowDateTimePicker = true; }
public DlgResult ShowMessage(string message, string caption, MsgBoxButton buttons, MsgBoxIcon image) { var dialogResult = default(DlgResult); if (!Dispatcher.CheckAccess()) { Dispatcher.Invoke(() => { dialogResult = ShowMessage(message, caption, buttons, image); }); } else { var window = GetActiveWindow(); var buttons4Box = EnumHelper.GetButtons4Message(buttons); var icon = EnumHelper.GetIcon4Message(image); var result = MessageBox.Show(null, message, caption, buttons4Box, icon); dialogResult = EnumHelper.GetDialogResult(result); } return(dialogResult); }
public MsgBox(string sMsg, string sTitle, MsgBoxButton enBtn, DateTime dtMinDate, DateTime dtMaxDate, DateTime dtSelected) : this(sMsg, sTitle, enBtn) { _ui_tmpDateTime.ValueChanged -= _ui_tmpDateTime_ValueChanged; _ui_tmpDateTime.ValueChanged += new RoutedPropertyChangedEventHandler <DateTime?>(_ui_tmpDateTime_ValueChanged); _ui_dtpDateTime.DisplayDateStart = dtMinDate; _ui_dtpDateTime.DisplayDateEnd = dtMaxDate; _sText = null; if (dtSelected < dtMinDate) { _ui_dtpDateTime.SelectedDate = dtMinDate; _ui_tmpDateTime.Value = dtMinDate; } else { _ui_dtpDateTime.SelectedDate = dtSelected; _ui_tmpDateTime.Value = dtSelected; } //_ui_tmpDateTime.Minimum = dtMinDate; //_ui_tmpDateTime.Maximum = dtMaxDate; _bShowDateTimePicker = true; }
/// <summary> /// 显示一个成功消息框 /// </summary> /// <param name="Title"></param> /// <param name="message"></param> /// <param name="MsgBoxButton"></param> /// <returns></returns> public static MsgBoxResult SuccessShow(string message, string Title = "提示", MsgBoxButton MsgBoxButton = MsgBoxButton.OK) { if (Application.Current == null) { return(MsgBoxResult.Cancel); } return((MsgBoxResult)Application.Current.Dispatcher.Invoke(new Func <MsgBoxResult>(() => { MsgBox msgbox = new MsgBox(); FormattedText ft = new FormattedText(message, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(msgbox.txtbMessage.FontFamily, msgbox.txtbMessage.FontStyle, msgbox.txtbMessage.FontWeight, msgbox.txtbMessage.FontStretch, msgbox.txtbMessage.FontFamily), msgbox.txtbMessage.FontSize, Brushes.Black); msgbox.myTitle.Text = Title; msgbox.txtbMessage.Text = message; msgbox.btnOK.Visibility = Visibility.Visible; if (MsgBoxButton == MsgBoxButton.OKCancel) { msgbox.btnCancel.Visibility = Visibility.Visible; } else { msgbox.btnCancel.Visibility = Visibility.Collapsed; } //msgbox.btnCancel.Focus(); msgbox.imgIcon.Source = new BitmapImage(new Uri("/BITools;component/Images/icon_done.png", UriKind.Relative));; msgbox.ActiveWindowHandle = GetActiveWindow(); //获取父窗体句柄 WindowInteropHelper helper = new WindowInteropHelper(msgbox); helper.Owner = msgbox.ActiveWindowHandle; msgbox.ShowInTaskbar = true; msgbox.ShowDialog(); return msgbox.msgResult; }))); }
private async void OnFileCompareOptionsPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "CheckName" || e.PropertyName == "CheckSize" || e.PropertyName == "CheckCreationDateTime" || e.PropertyName == "CheckModificationDateTime" || e.PropertyName == "CheckContent") { // Если событие возникает в процессе отката изменений параметров то игнорируем его if (_dataModel.FileCompareOptions.IsRollBack) { return; } if (_dataModel.DuplicatesCount == 0) { // Если поиск дубликатов не выполнялся то просто сохраняем новые значения _dataModel.FileCompareOptions.Commit(); return; } string msg = "Changing file compare options will discard current search results.\n Would you like to change file compare options and clear results of last duplicates search?"; MsgBoxButton pressedButton = await DisplayMessage(msg, MsgBoxButton.Yes | MsgBoxButton.No, 200); switch (pressedButton) { case MsgBoxButton.Yes: _dataModel.FileCompareOptions.Commit(); _dataModel.ClearSearchResults(); _dataModel.InvalidateDuplicates(); break; case MsgBoxButton.No: _dataModel.FileCompareOptions.RollBack(); break; } } }
/// <summary> /// Handles button: New test /// </summary> private void _btnNewTest_Click(object sender, EventArgs e) { if (DataSet.ForTests(this._core).ShowListEditor(this) == null) { return; } bool loop2 = false; while (this._core.EvaluationResultFiles.Any(z => !z.HasResults && !z.Hidden)) { var toRun = this._core.EvaluationResultFiles.Where(z => !z.HasResults && !z.Hidden).ToArray(); if (toRun.Length == 0) { return; } MsgBoxButton[] buttons; string msg; if (loop2) { buttons = new MsgBoxButton[] { new MsgBoxButton("Continue", Resources.MnuAccept, DialogResult.Yes), new MsgBoxButton("Later", Resources.MnuAdd, DialogResult.No), new MsgBoxButton("Discard", Resources.MnuDelete, DialogResult.Abort), }; msg = "An error occured but " + toRun.Length.ToString() + " tests are still queued. You can continue running them now, save them for later, or discard them."; } else { buttons = new MsgBoxButton[] { new MsgBoxButton("Now", Resources.MnuAccept, DialogResult.Yes), new MsgBoxButton("Later", Resources.MnuAdd, DialogResult.No) }; msg = toRun.Length.ToString() + " tests are ready to run. You can save these for later or run them now."; } switch (FrmMsgBox.Show(this, "Save Tests", null, msg, Resources.MsgWarning, buttons)) { case DialogResult.Yes: break; case DialogResult.No: default: return; case DialogResult.Abort: this._core.EvaluationResultFiles.RemoveAll(test => !test.HasResults); return; } if (this.Paranoid) { if (string.IsNullOrWhiteSpace(this._core.FileNames.Session)) { FrmMsgBox.ShowError(this, "The evaluations cannot be conducted because the session has not yet been saved. Please return to the main screen and save the session before continuing."); return; } else if (!FrmMsgBox.ShowOkCancel(this, "Save Session", "To avoid data loss the current session must be saved. The current session is \"" + this._core.FileNames.Session + "\".", FrmMsgBox.EDontShowAgainId.SaveBetweenEvaluations, DialogResult.OK)) { return; } } this.BeginWait(this._tlpHeaderParams); try { FrmWait.Show(this, "Please wait", null, z => RunTests(this._core, toRun, z, this.Paranoid)); } catch (Exception ex) { FrmMsgBox.ShowError(this, ex); } finally { this.EndWait(this._tlpHeaderParams); } loop2 = true; } }
public MsgBoxDlg() { this.clickedButton = MsgBoxButton.None; InitializeComponent(); this.IsVisibleChanged += MsgBoxDlg_IsVisibleChanged; }
public MsgBoxDlg() { clickedButton = MsgBoxButton.None; InitializeComponent(); IsVisibleChanged += MsgBoxDlg_IsVisibleChanged; }
private void cancelButton_Click(object sender, RoutedEventArgs e) { this.DialogResult = false; this.ButtonClicked = MsgBoxButton.Cancel; Close(); }
public MsgBoxButton Show(string message, MsgBoxButton buttons = MsgBoxButton.OK, Window ownerWindow = null) => dispatcher.UI(() => MsgBox.Instance.Show(message, buttons, ownerWindow));
public IObservable <MsgBoxResult> ShowMessageBox(System.Windows.Window?owner, string text, string caption, MsgBoxButton button, MsgBoxImage icon) { return(CurrentDispatcher.InvokeAsync(() => (MsgBoxResult)MessageBox.Show(owner ?? _mainWindow, text, caption, (MessageBoxButton)button, (MessageBoxImage)icon))); }
public MsgBoxResult ShowTaskDialog( IWindow owner, string text, string caption, MsgBoxButton button, MsgBoxImage icon, Icon custumIcon) { return ObservableObject.CurrentDispatcher.Invoke( () => { var dialog = new TaskDialog { CenterParent = true, Content = text, ExpandFooterArea = false, ExpandedByDefault = false, MinimizeBox = false, ProgressBarStyle = ProgressBarStyle.None, WindowIcon = custumIcon, WindowTitle = caption, MainInstruction = caption, MainIcon = TranslateIcon(icon) }; TranslateButtons(button, dialog.Buttons); TaskDialogButton clickedButton = dialog.ShowDialog(owner != null ? (Window) owner .TranslateForTechnology () : null); switch (clickedButton.ButtonType) { case ButtonType.Ok: return MsgBoxResult.Ok; case ButtonType.Yes: return MsgBoxResult.Yes; case ButtonType.No: return MsgBoxResult.No; case ButtonType.Cancel: return MsgBoxResult.Cancel; case ButtonType.Close: return MsgBoxResult.Cancel; default: throw new ArgumentOutOfRangeException(); } }); }
public MsgBoxResult ShowMessageBox( IWindow owner, string text, string caption, MsgBoxButton button, MsgBoxImage icon, Icon custumIcon) { Window realWindow = owner == null ? null : (Window)owner.TranslateForTechnology(); return ObservableObject.CurrentDispatcher.Invoke( () => !TaskDialog.OSSupportsTaskDialogs ? (MsgBoxResult) MessageBox.Show( realWindow, text, caption, (MessageBoxButton) button, (MessageBoxImage) icon) : ShowTaskDialog(owner, text, caption, button, icon, custumIcon)); }
private void CancelButton_Click(object sender, RoutedEventArgs e) { enMsgResult = MsgBoxButton.Cancel; this.DialogResult = false; }
/// <summary> /// The show message box. /// </summary> /// <param name="owner"> /// The owner. /// </param> /// <param name="text"> /// The text. /// </param> /// <param name="caption"> /// The caption. /// </param> /// <param name="button"> /// The button. /// </param> /// <param name="icon"> /// The icon. /// </param> /// <param name="custumIcon"> /// The custum icon. /// </param> /// <returns> /// The <see cref="MsgBoxResult" />. /// </returns> /// <exception cref="NotImplementedException"> /// </exception> public MsgBoxResult ShowMessageBox( IWindow owner, string text, string caption, MsgBoxButton button, MsgBoxImage icon, Icon custumIcon) { Contract.Requires<ArgumentNullException>(text != null, "text"); Contract.Requires<ArgumentNullException>(caption != null, "caption"); throw new NotImplementedException(); }
/// <summary> /// The show task dialog. /// </summary> /// <param name="owner"> /// The owner. /// </param> /// <param name="text"> /// The text. /// </param> /// <param name="caption"> /// The caption. /// </param> /// <param name="button"> /// The button. /// </param> /// <param name="icon"> /// The icon. /// </param> /// <param name="custumIcon"> /// The custum icon. /// </param> /// <returns> /// The <see cref="MsgBoxResult" />. /// </returns> public MsgBoxResult ShowTaskDialog( IWindow owner, string text, string caption, MsgBoxButton button, MsgBoxImage icon, Icon custumIcon) { Contract.Requires<ArgumentNullException>(text != null, "text"); Contract.Requires<ArgumentNullException>(caption != null, "caption"); return MsgBoxResult.Cancel; }
public void Show(string sMsg, string sTitle, MsgBoxButton enBtn, string sText) { _bShowTextBox = true; this.sText = sText; this.Show(sMsg, sTitle, enBtn); }
private void TranslateButtons(MsgBoxButton button, [NotNull] TaskDialogItemCollection<TaskDialogButton> buttons) { switch (button) { case MsgBoxButton.OkCancel: buttons.Add(new TaskDialogButton(ButtonType.Ok)); buttons.Add(new TaskDialogButton(ButtonType.Cancel)); break; case MsgBoxButton.Ok: buttons.Add(new TaskDialogButton(ButtonType.Ok)); break; case MsgBoxButton.YesNoCancel: buttons.Add(new TaskDialogButton(ButtonType.Yes)); buttons.Add(new TaskDialogButton(ButtonType.No)); buttons.Add(new TaskDialogButton(ButtonType.Cancel)); break; case MsgBoxButton.YesNo: buttons.Add(new TaskDialogButton(ButtonType.Yes)); buttons.Add(new TaskDialogButton(ButtonType.No)); break; default: throw new ArgumentOutOfRangeException("button"); } }
private void button_Tapped(object sender, TappedRoutedEventArgs e) { _pressedButton = (MsgBoxButton)Enum.Parse(typeof(MsgBoxButton), ((Button)sender).Name); HideControl.Begin(); _stopWating = true; }
private void okButton_Click(object sender, RoutedEventArgs e) { this.DialogResult = true; this.ButtonClicked = MsgBoxButton.OK; Close(); }
public MsgBoxButton Show(string message, MsgBoxButton buttons, Window?ownerWindow) { Create(message, buttons, false, ownerWindow, out var win, out var vm); win.ShowDialog(); return(win.ClickedButton); }
public void Show(string sMsg, string sTitle, MsgBoxButton enBtn, ListBox cLB) { _cListBox = cLB; Show(sMsg, sTitle, enBtn); }
public void Close(MsgBoxButton button) { ClickedButton = button; DialogResult = true; Close(); }