private static DialogResult ShowMessageBox(string message, string caption, MessageButtons buttons, MessageBoxIcon icon) { var messageBoxButtons = buttons == MessageButtons.YesNo ? MessageBoxButtons.YesNo : buttons == MessageButtons.OKCancel ? MessageBoxButtons.OKCancel : MessageBoxButtons.OK; var result = MessageBox.Show(message, caption, messageBoxButtons, icon); switch (result) { default: case System.Windows.Forms.DialogResult.None: return(DialogResult.None); case System.Windows.Forms.DialogResult.OK: return(DialogResult.OK); case System.Windows.Forms.DialogResult.Cancel: return(DialogResult.Cancel); case System.Windows.Forms.DialogResult.Yes: return(DialogResult.Yes); case System.Windows.Forms.DialogResult.No: return(DialogResult.No); } }
public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { try { this.progressCounter.ProcessMessage(messageType, messageRecord); this.progressBar.Value = (int)(this.progressBar.Minimum + this.progressCounter.Progress * (this.progressBar.Maximum - this.progressBar.Minimum)); this.progressLabel.Text = "" + (int)Math.Round(100 * this.progressCounter.Progress) + "%"; switch (messageType) { case InstallMessage.Error: case InstallMessage.Warning: case InstallMessage.Info: string message = String.Format("{0}: {1}", messageType, messageRecord); this.LogMessage(message); break; } if (this.canceled) { this.canceled = false; return MessageResult.Cancel; } } catch (Exception ex) { this.LogMessage(ex.ToString()); this.LogMessage(ex.StackTrace); } Application.DoEvents(); return MessageResult.OK; }
private async Task ShowLocalizedDialogFormat(Message request, MessageButtons buttons, CancellationToken ct) { TaskUtilities.AssertIsOnBackgroundThread(); var response = await ShowDialog(new RContext[0], GetLocalizedString(request), buttons, ct); await RespondAsync(request, ct, response); }
public static DialogResponse Show( string text, string title = "", MessageButtons buttons = MessageButtons.Ok) { return Show(null, text, title, buttons); }
public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { try { this.progressCounter.ProcessMessage(messageType, messageRecord); this.progressBar.Value = this.progressBar.Minimum + this.progressCounter.Progress * (this.progressBar.Maximum - this.progressBar.Minimum); this.progressLabel.Content = "" + (int)Math.Round(100 * this.progressCounter.Progress) + "%"; switch (messageType) { case InstallMessage.Error: case InstallMessage.Warning: case InstallMessage.Info: string message = String.Format("{0}: {1}", messageType, messageRecord); this.LogMessage(message); break; } if (this.canceled) { this.canceled = false; return(MessageResult.Cancel); } } catch (Exception ex) { this.LogMessage(ex.ToString()); this.LogMessage(ex.StackTrace); } return(MessageResult.OK); }
/// <summary> /// Class constructor. /// </summary> public MessageProperties(string[] lines, MessageButtons buttons = MessageButtons.OK, double size = 24, int timeoutSecs = -1) { Lines = lines.Select(l => new TextLine(l, size)).ToArray(); Buttons = buttons; ButtonIndex = buttons >= MessageButtons.CancelOK ? 1 : 0; TimeoutTime = timeoutSecs > 0 ? DateTime.Now.AddSeconds(timeoutSecs) : DateTime.Now.AddHours(24); }
protected virtual async Task <bool> TryHandleCommandAsyncInternal(IProjectTree rDataNode) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); MessageButtons messageResult = VsAppShell.Current.ShowMessage(string.Format(CultureInfo.CurrentCulture, Resources.LoadWorkspaceIntoGlobalEnvironment, rDataNode.FilePath), MessageButtons.YesNo); if (messageResult == MessageButtons.No) { return(true); } var session = _workflowProvider.GetOrCreate().RSession; using (var evaluation = await session.BeginEvaluationAsync()) { try { await evaluation.LoadWorkspaceAsync(rDataNode.FilePath); } catch (RException ex) { var message = string.Format(CultureInfo.CurrentCulture, Resources.LoadWorkspaceFailedMessageFormat, rDataNode.FilePath, ex.Message); VsAppShell.Current.ShowErrorMessage(message); } catch (OperationCanceledException) { } } return(true); }
public static DialogResponse Show( string text, string title = "", MessageButtons buttons = MessageButtons.Ok) { return(Show(null, text, title, buttons)); }
public void SetButtonImage(MessageButtons button, Image image) { switch (button) { case MessageButtons.OK: btnOK.SetChildImage(image); break; case MessageButtons.Cancel: btnCancel.SetChildImage(image); break; case MessageButtons.Retry: btnRetry.SetChildImage(image); break; case MessageButtons.Yes: btnYes.SetChildImage(image); break; case MessageButtons.No: btnNo.SetChildImage(image); break; case MessageButtons.Restart: btnRestart.SetChildImage(image); break; default: throw new ArgumentOutOfRangeException("button"); } }
internal static bool Show(string message, string title, MessageButtons buttons) { MessageBoxButtons messsageBoxButtons; switch (buttons) { case MessageButtons.OkCancel: messsageBoxButtons = MessageBoxButtons.OKCancel; break; case MessageButtons.YesNo: messsageBoxButtons = MessageBoxButtons.YesNo; break; default: messsageBoxButtons = MessageBoxButtons.OK; break; } //TODO(adam): add displaying to custom form for auto-sizing, etc Lettering.MoveWindowToTop(); DialogResult result = MessageBox.Show(message, title, messsageBoxButtons); return(result == DialogResult.OK || result == DialogResult.Yes); }
/// <summary> /// Shows message window. /// </summary> /// <param name="mainWindow">Required param. Gets form information</param> /// <param name="title">Required param. Message title</param> /// <param name="prompt">Required param. Message prompt</param> /// <param name="messageButtons">Optional param. Message buttons. Default OK</param> /// <returns></returns> public static MessageResult Show(Window mainWindow, string title, string prompt, MessageButtons messageButtons = MessageButtons.OK, MessageIcon messageIcon = MessageIcon.None) { _mainWindow = mainWindow; emptyWindow = new Window(); //emptyWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; emptyWindow.WindowState = mainWindow.WindowState; emptyWindow.Height = _mainWindow.Height; emptyWindow.Width = mainWindow.Width; emptyWindow.Top = mainWindow.Top; emptyWindow.Left = mainWindow.Left; emptyWindow.WindowStyle = WindowStyle.None; emptyWindow.ResizeMode = ResizeMode.NoResize; emptyWindow.Background = new SolidColorBrush(Colors.Transparent); emptyWindow.AllowsTransparency = true; emptyWindow.ShowInTaskbar = false; var content = mainWindow.Content; if (content is Grid) { Grid grd = (Grid)content; base_grid = new Grid() { Name = "grd_message" }; RowDefinition rd = new RowDefinition(); rd.Height = new GridLength(10, GridUnitType.Star); ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(10, GridUnitType.Star); base_grid.RowDefinitions.Add(rd); base_grid.ColumnDefinitions.Add(cd); CreateMainGrid(emptyWindow, title, prompt, messageButtons, messageIcon); base_grid.Children.Add(main_grid); emptyWindow.Content = base_grid; emptyWindow.ShowDialog(); } return Result; }
public MessageButtons ShowMessage(string message, MessageButtons buttons, MessageType messageType = MessageType.Information) { LastShownMessage = message; if (buttons == MessageButtons.YesNo || buttons == MessageButtons.YesNoCancel) { return MessageButtons.Yes; } return MessageButtons.OK; }
private async Task <string> ShowDialog(RContext[] contexts, string message, MessageButtons buttons, CancellationToken ct) { TaskUtilities.AssertIsOnBackgroundThread(); MessageButtons input = await _callbacks.ShowDialog(contexts, message, buttons, ct); ct.ThrowIfCancellationRequested(); string response; switch (input) { case MessageButtons.No: response = "N"; break; case MessageButtons.Cancel: response = "C"; break; case MessageButtons.Yes: response = "Y"; break; default: { var error = Invariant($"YesNoCancel: callback returned an invalid value: {input}"); Trace.Fail(error); throw new InvalidOperationException(error); } } return(response); }
/// <summary> /// Class constructor. /// </summary> public MessageProperties(TextLine[] lines, MessageButtons buttons = MessageButtons.OK, int timeoutSecs = -1) { Lines = lines; Buttons = buttons; ButtonIndex = buttons >= MessageButtons.CancelOK ? 1 : 0; TimeoutTime = timeoutSecs > 0 ? DateTime.Now.AddSeconds(timeoutSecs) : DateTime.Now.AddHours(24); }
public MessageBoxContent(string t_message, MessageType t_type, MessageButtons t_buttons) { Message = t_message; MessageType = t_type; MessageButtons = t_buttons; ShowMessageBox(); }
public static MessageResult Show(string message, string title, MessageButtons buttons, MessageIcon icon) { AppDialogMessage dialog = new AppDialogMessage(message, title, buttons, icon); dialog.ShowDialog(); return(dialog.Result); }
/* * Method that create a messagebox with the message and some of the standard button configurations */ public static int SetMessageBox(string strMessage, string strTitle, MessageButtons mesType) { #if UNITY_EDITOR || UNITY_STANDALONE return(ShowMessage(strMessage, strTitle, (int)mesType)); #else return(0); #endif }
public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { object result = this._mainWindow.Dispatcher.Invoke( DispatcherPriority.Send, new Func <MessageResult>(() => this._mainWindow.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton))); return((MessageResult)result); }
public MessageButtons ShowMessage(string message, MessageButtons buttons, MessageType messageType = MessageType.Information) { LastShownMessage = message; if (buttons == MessageButtons.YesNo || buttons == MessageButtons.YesNoCancel) { return(MessageButtons.Yes); } return(MessageButtons.OK); }
public MessageBoxCustom(string Message, MessageTypeBox Type, MessageButtons Buttons, bool autoClose = false) { InitializeComponent(); //auto close window after x seconds if (autoClose == true) { dispatcherTimer.Tick -= dispatcherTimer_Tick; dispatcherTimer.Tick += dispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 5); dispatcherTimer.Start(); } txtMessage.Text = Message; switch (Type) { case MessageTypeBox.Info: txtTitle.Text = "Info"; break; case MessageTypeBox.Confirmation: txtTitle.Text = "Confirmation"; break; case MessageTypeBox.Success: { txtTitle.Text = "Success"; } break; case MessageTypeBox.Warning: txtTitle.Text = "Warning"; break; case MessageTypeBox.Error: { txtTitle.Text = "Error"; } break; } switch (Buttons) { case MessageButtons.OkCancel: btnYes.Visibility = Visibility.Collapsed; btnNo.Visibility = Visibility.Collapsed; break; case MessageButtons.YesNo: btnOk.Visibility = Visibility.Collapsed; btnCancel.Visibility = Visibility.Collapsed; break; case MessageButtons.Ok: btnOk.Visibility = Visibility.Visible; btnCancel.Visibility = Visibility.Collapsed; btnYes.Visibility = Visibility.Collapsed; btnNo.Visibility = Visibility.Collapsed; break; } }
MessageResult OnUIUpdate(InstallMessage messageType, string message, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { if (cancelled && installing) { installing = false; return(MessageResult.Cancel); } return(MessageResult.OK); }
public ShowDialogTaskEventArgs(Task t, string message, string title, MessageButtons buttons, DialogResponse defResponse = DialogResponse.Other) : base(t) { this.Message = message; this.Title = title; this.Buttons = buttons; this.Response = defResponse; }
public static MessageResult ExternalUILogger( InstallMessage messageType, string message, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { Console.WriteLine("{0}: {1}", messageType, message); return(MessageResult.None); }
public static MessageResult ExternalUILogger( InstallMessage messageType, string message, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { Console.WriteLine("{0}: {1}", messageType, message); return MessageResult.None; }
/// <summary> /// Processes information and progress messages sent to the user interface. /// </summary> /// <param name="messageType">Message type.</param> /// <param name="messageRecord">Record that contains message data.</param> /// <param name="buttons">Message box buttons.</param> /// <param name="icon">Message box icon.</param> /// <param name="defaultButton">Message box default button.</param> /// <returns>Result of processing the message.</returns> public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { // Synchronously send the message to the setup wizard window on its thread. object result = this._mainWindow.Dispatcher.Invoke( DispatcherPriority.Send, new Func <MessageResult>(() => this._mainWindow.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton))); return((MessageResult)result); }
private static MessageResults ShowDialog( String message, String title, MessageButtons button, MessageIcons icon, ImageSource image, SkinBundle bundle) { MessageDialogEx dlg = new MessageDialogEx { Title = title, lblMessage = { Text = message }, icon = icon, imgIcon = { Source = MessageIconHelper.GetIcon(icon, bundle) } }; if (dlg.imgIcon.Source == null) { if (image != null) { dlg.imgIcon.Source = image; } } switch (button) { case MessageButtons.OK: dlg.btnOK.Visibility = Visibility.Visible; break; case MessageButtons.OKCancel: dlg.btnOK.Visibility = Visibility.Visible; dlg.btnCancel.Visibility = Visibility.Visible; break; case MessageButtons.YesNo: dlg.btnYes.Visibility = Visibility.Visible; dlg.btnNo.Visibility = Visibility.Visible; break; case MessageButtons.YesNoCancel: dlg.btnYes.Visibility = Visibility.Visible; dlg.btnNo.Visibility = Visibility.Visible; dlg.btnCancel.Visibility = Visibility.Visible; break; default: throw new NotImplementedException(); } if (bundle != null) { bundle.SetBundle(dlg); } dlg.ShowDialog(); return(dlg.Result); }
internal CsMessage(Types type, object content, string title, MessageButtons button, [CallerMemberName] string methodName = null, [CallerFilePath] string classFilePath = null, [CallerLineNumber] int classLineNumber = 0) { _time = DateTime.Now; _type = type; _content = content; _title = title; _messageButton = button; _code = new CodePosition(methodName, classFilePath, classLineNumber); _messageId = SmallHash.FromString(_content.ToString()); _iD = SmallHash.FromString(new[] {Code.PositionId, MessageId}.Join("")); }
/// <summary> /// 메시지 출력 /// ctl 가 null 이 아니면 RegisterStartupScript 로 스크립트 추가되어지므로 호출후 Response.End()등으로 실행중지시 출력되어지지 않습니다. /// </summary> /// <param name="messageBoxDisplayKind">출력타입</param> /// <param name="title">메시지 캡션</param> /// <param name="text">메시지</param> /// <param name="messageType">메시지타입</param> /// <param name="messageButton">버튼타입</param> /// <param name="ctl">렌더링되는 페이지</param> /// <param name="returnUrl">메시지출력후 이동할 url</param> /// <param name="endResponse">프로세스 종료여부</param> public static void MessageBox(MessageBoxDisplayKind messageBoxDisplayKind, string title, string text, MessageType messageType, MessageButtons messageButton, System.Web.UI.Control ctl, string returnUrl = "", bool endResponse = false) { MessageBox(messageBoxDisplayKind, title, text, messageType, messageButton, (ctl != null) ? ctl.Page : null, returnUrl, endResponse); }
public MaterialMessageBox(string Message, MessageType Type, MessageButtons Buttons, bool isProgress = false) { InitializeComponent(); txtMessage.Text = Message; switch (Type) { case MessageType.Info: txtTitle.Text = "Info"; break; case MessageType.Confirmation: txtTitle.Text = "Confirmation"; break; case MessageType.Success: txtTitle.Text = "Success"; break; case MessageType.Warning: txtTitle.Text = "Warning"; break; case MessageType.Error: txtTitle.Text = "Error"; break; } switch (Buttons) { case MessageButtons.OkCancel: btnYes.Visibility = Visibility.Collapsed; btnNo.Visibility = Visibility.Collapsed; break; case MessageButtons.YesNo: btnOk.Visibility = Visibility.Collapsed; btnCancel.Visibility = Visibility.Collapsed; break; case MessageButtons.Ok: btnOk.Visibility = Visibility.Visible; btnCancel.Visibility = Visibility.Collapsed; btnYes.Visibility = Visibility.Collapsed; btnNo.Visibility = Visibility.Collapsed; break; case MessageButtons.None: btnOk.Visibility = Visibility.Collapsed; btnCancel.Visibility = Visibility.Collapsed; btnYes.Visibility = Visibility.Collapsed; btnNo.Visibility = Visibility.Collapsed; //this.DialogResult = false; break; } if (isProgress) { btnClose.Visibility = Visibility.Collapsed; } }
/// <summary> /// Processes information and progress messages sent to the user interface. /// </summary> /// <param name="messageType">Message type.</param> /// <param name="messageRecord">Record that contains message data.</param> /// <param name="buttons">Message box buttons.</param> /// <param name="icon">Message box icon.</param> /// <param name="defaultButton">Message box default button.</param> /// <returns>Result of processing the message.</returns> public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { // Synchronously send the message to the setup wizard window on its thread. var result = setupWizard.Dispatcher.Invoke(DispatcherPriority.Send, new Func <MessageResult>(delegate() { return(setupWizard.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton)); })); return((MessageResult)result); }
private async Task ShowDialog(Message request, MessageButtons buttons, CancellationToken ct) { TaskUtilities.AssertIsOnBackgroundThread(); request.ExpectArguments(2); var contexts = GetContexts(request); var s = request.GetString(1, "s", allowNull: true); var response = await ShowDialog(contexts, s, buttons, ct); await RespondAsync(request, ct, response); }
public MessageBoxCustom(string Message, MessageType Type, MessageButtons Buttons) { InitializeComponent(); txtMessage.Text = Message; switch (Type) { case MessageType.Info: txtTitle.Text = "Info"; iconInfo.Visibility = Visibility.Visible; break; case MessageType.Confirmation: txtTitle.Text = "Confirmation"; iconConfirm.Visibility = Visibility.Visible; break; case MessageType.Success: txtTitle.Text = "Success"; iconSuccess.Visibility = Visibility.Visible; break; case MessageType.Warning: txtTitle.Text = "Warning"; iconWarning.Visibility = Visibility.Visible; break; case MessageType.Error: txtTitle.Text = "Error"; iconError.Visibility = Visibility.Visible; break; } ; switch (Buttons) { case MessageButtons.OkCancel: btnYes.Visibility = Visibility.Collapsed; btnNo.Visibility = Visibility.Collapsed; break; case MessageButtons.YesNo: btnOk.Visibility = Visibility.Collapsed; btnCancel.Visibility = Visibility.Collapsed; break; case MessageButtons.Ok: btnOk.Visibility = Visibility.Visible; btnCancel.Visibility = Visibility.Collapsed; btnYes.Visibility = Visibility.Collapsed; btnNo.Visibility = Visibility.Collapsed; break; } ; }
public static DialogResponse Show( IWindow owner, string text, string title = "", MessageButtons buttons = MessageButtons.Ok) { return ConvertResultEnum(System.Windows.Forms.MessageBox.Show( owner as IWin32Window, text, title, ConvertButtonsEnum(buttons))); }
public NotifMsg(string id, string caption, string text, int timeOutMs, MessageType type, MessageButtons buttons, object info) { Id = id; Caption = caption; Text = text; TimeoutMs = timeOutMs; Type = type; Buttons = buttons; Height = 110; Width = 400; Info = info; }
public static DialogResponse Show( IWindow owner, string text, string title = "", MessageButtons buttons = MessageButtons.Ok) { return(ConvertResultEnum(System.Windows.Forms.MessageBox.Show( owner as IWin32Window, text, title, ConvertButtonsEnum(buttons)))); }
public AppDialogMessage(string message, string title, MessageButtons buttons, MessageIcon icon) { InitializeComponent(); CenterOnParent(); this.message = message; this.Title = title; this.buttons = buttons; this.icon = icon; Loaded += OnLoaded; }
public MessageButton(MessageButtons button, bool selected, bool cancelButton) { this.button = button; Selected = selected; this.cancelButton = cancelButton; Text = button.GetDisplayName(); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Selectable, true); TabStop = true; using (var g = CreateGraphics()) MeasureSize(g); }
/// <summary> /// Processes the message. /// </summary> /// <param name="messageType">Type of the message.</param> /// <param name="messageRecord">The message record.</param> /// <param name="buttons">The buttons.</param> /// <param name="icon">The icon.</param> /// <param name="defaultButton">The default button.</param> /// <returns></returns> public override MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { switch (messageType) { case InstallMessage.ActionStart: { try { //messageRecord[0] - is reserved for FormatString value string message = null; bool simple = true; if (simple) { for (int i = messageRecord.FieldCount - 1; i > 0; i--) { message = messageRecord[i].ToString(); } } else { message = messageRecord.FormatString; if (message.IsNotEmpty()) { for (int i = 1; i < messageRecord.FieldCount; i++) { message = message.Replace("[" + i + "]", messageRecord[i].ToString()); } } else { message = messageRecord[messageRecord.FieldCount - 1].ToString(); } } if (message.IsNotEmpty()) currentAction.Text = message; } catch { } } break; } return MessageResult.OK; }
public static DialogResponse Show( IWindow parent, string text, string title = "", MessageButtons buttons = MessageButtons.Ok) { switch (Program.Toolkit) { case WindowToolkit.WinForms: return WinGUI.WinFormsMessageBox.Show(parent, text, title, buttons); case WindowToolkit.GtkSharp: return GTKGUI.GTKMessageBox.Show(parent, text, title, buttons); default: throw new NotImplementedException(); } }
/// <summary> /// Called when R wants to display generic Windows MessageBox. /// Graph app may call Win32 API directly rather than going via R API callbacks. /// </summary> /// <returns>Pressed button code</returns> public async Task<MessageButtons> ShowDialog(IReadOnlyList<IRContext> contexts, string s, bool isEvaluationAllowed, MessageButtons buttons, CancellationToken ct) { await Console.Error.WriteAsync(s); while (true) { string r = await ReadLineAsync(" [yes/no/cancel]> ", isEvaluationAllowed, ct); if (r.StartsWith("y", StringComparison.InvariantCultureIgnoreCase)) { return MessageButtons.Yes; } if (r.StartsWith("n", StringComparison.InvariantCultureIgnoreCase)) { return MessageButtons.No; } if (r.StartsWith("c", StringComparison.InvariantCultureIgnoreCase)) { return MessageButtons.Cancel; } await Console.Error.WriteAsync("Invalid input, try again!"); } }
static MessageBoxButtons ConvertButtonsEnum(MessageButtons mButtons) { switch (mButtons) { case MessageButtons.Ok: return MessageBoxButtons.OK; case MessageButtons.OkCancel: return MessageBoxButtons.OKCancel; case MessageButtons.RetryCancel: return MessageBoxButtons.RetryCancel; case MessageButtons.YesNo: return MessageBoxButtons.YesNo; default: return MessageBoxButtons.OK; } }
public override MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { switch (messageType) { case InstallMessage.ActionStart: { try { var message = messageRecord[messageRecord.FieldCount - 1].ToString(); if (message.IsNotEmpty()) currentAction.Text = message; } catch { } } break; } return MessageResult.OK; }
public static MessageResult ExternalUIRecordLogger( InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { if (messageRecord != null) { if (messageRecord.FormatString.Length == 0 && messageRecord.FieldCount > 0) { messageRecord.FormatString = "1: [1] 2: [2] 3: [3] 4: [4] 5: [5]"; } Console.WriteLine("{0}: {1}", messageType, messageRecord.ToString()); } else { Console.WriteLine("{0}: (null)", messageType); } return MessageResult.None; }
public static DialogResponse Show( IWindow owner, string text, string title = "", MessageButtons buttons = MessageButtons.Ok) { ResponseType response = ResponseType.None; Gtk.MessageDialog dialog = new Gtk.MessageDialog( (owner is Dialog ? owner as Dialog : owner as Window), DialogFlags.Modal, MessageType.Other, ConvertButtonsEnum(buttons), text); dialog.Title = title; dialog.Response += (o, args) => { response = args.ResponseId; dialog.Destroy(); }; dialog.Run(); return ConvertResultEnum(response); }
/*.Show( (owner is Dialog ? owner as Dialog : owner as Window), text, title, ConvertButtonsEnum(buttons)) */ private static ButtonsType ConvertButtonsEnum(MessageButtons buttons) { switch (buttons) { case MessageButtons.Ok: return ButtonsType.Ok; case MessageButtons.OkCancel: return ButtonsType.OkCancel; case MessageButtons.RetryCancel: return ButtonsType.OkCancel; case MessageButtons.YesNo: return ButtonsType.YesNo; case MessageButtons.YesNoCancel: return ButtonsType.YesNo; default: return ButtonsType.Ok; } }
/// <summary> /// Processes information and progress messages sent to the user interface. /// <para> This method directly mapped to the /// <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI.ProcessMessage" />.</para> /// </summary> /// <param name="messageType">Type of the message.</param> /// <param name="messageRecord">The message record.</param> /// <param name="buttons">The buttons.</param> /// <param name="icon">The icon.</param> /// <param name="defaultButton">The default button.</param> /// <returns></returns> public virtual MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { return MessageResult.OK; }
/// <summary> /// Displays message with specified buttons in a host-specific UI /// </summary> public Task<MessageButtons> ShowMessageAsync(string message, MessageButtons buttons, CancellationToken cancellationToken) => _coreShell.ShowMessageAsync(message, buttons, cancellationToken);
private async Task ShowDialog(Message request, bool allowEval, MessageButtons buttons, CancellationToken ct) { TaskUtilities.AssertIsOnBackgroundThread(); request.ExpectArguments(2); var contexts = GetContexts(request); var s = request.GetString(1, "s", allowNull: true); MessageButtons input; try { _canEval = allowEval; input = await _callbacks.ShowDialog(contexts, s, _canEval, buttons, ct); } finally { _canEval = false; } ct.ThrowIfCancellationRequested(); string response; switch (input) { case MessageButtons.No: response = "N"; break; case MessageButtons.Cancel: response = "C"; break; case MessageButtons.Yes: response = "Y"; break; default: { FormattableString error = $"YesNoCancel: callback returned an invalid value: {input}"; Trace.Fail(Invariant(error)); throw new InvalidOperationException(Invariant(error)); } } await RespondAsync(request, ct, response); }
public virtual Task<MessageButtons> ShowMessage(string message, MessageButtons buttons) { return Task.FromResult(MessageButtons.OK); }
private MessageResult OnMessage(InstallMessage messageType, Deployment.WindowsInstaller.Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { switch (messageType) { case InstallMessage.FatalExit: case InstallMessage.Error: return this.OnError(messageRecord); case InstallMessage.Warning: return this.OnWarning(messageRecord); case InstallMessage.User: return this.OnInformation(messageRecord); default: return MessageResult.None; } }
/* * Method that create a warning messagebox with the message and some of the standard button configurations */ public static int SetWarningMessage(string strMessage, MessageButtons mesType) { return ShowWarningMessage(strMessage, (int)mesType); }
/// <summary> /// Creating buttons /// </summary> /// <param name="messageButton"></param> /// <returns></returns> static StackPanel CreateButtons(MessageButtons messageButton) { StackPanel stc2 = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right, }; Grid.SetRow(stc2, 2); if (messageButton == MessageButtons.OK) { CButton btn_ok = new CButton(); btn_ok.Content = "OK"; btn_ok.Height = 30; btn_ok.Width = 80; btn_ok.Margin = new Thickness(0, 0, 10, 0); btn_ok.OnClick += CButton_OnClick; stc2.Children.Add(btn_ok); } else if (messageButton == MessageButtons.OKCancel) { for (int i = 1; i <= 2; i++) { CButton btn_ok = new CButton(); btn_ok.Content = (i == 1 ? "OK" : "Cancel"); btn_ok.Height = 30; btn_ok.Width = 80; btn_ok.Margin = new Thickness(0, 0, 10, 0); btn_ok.OnClick += CButton_OnClick; stc2.Children.Add(btn_ok); } } else if (messageButton == MessageButtons.YesNo) { for (int i = 1; i <= 2; i++) { CButton btn_ok = new CButton(); btn_ok.Content = (i == 1 ? "Yes" : "No"); btn_ok.Height = 30; btn_ok.Width = 80; btn_ok.Margin = new Thickness(0, 0, 10, 0); btn_ok.OnClick += CButton_OnClick; stc2.Children.Add(btn_ok); } } else if (messageButton == MessageButtons.IgnoreRetry) { for (int i = 1; i <= 2; i++) { CButton btn_ok = new CButton(); btn_ok.Content = (i == 1 ? "Retry" : "Ignore"); btn_ok.Height = 30; btn_ok.Width = 80; btn_ok.Margin = new Thickness(0, 0, 10, 0); btn_ok.OnClick += CButton_OnClick; stc2.Children.Add(btn_ok); } } else if (messageButton == MessageButtons.YesNoCancel) { for (int i = 1; i <= 3; i++) { CButton btn_ok = new CButton(); btn_ok.Content = (i == 1 ? "Yes" : (i == 2 ? "No" : "Cancel")); btn_ok.Height = 30; btn_ok.Width = 80; btn_ok.Margin = new Thickness(0, 0, 10, 0); btn_ok.OnClick += CButton_OnClick; stc2.Children.Add(btn_ok); } } return stc2; }
/// <summary> /// Creating content of the message /// </summary> /// <param name="_title"></param> /// <param name="_message"></param> /// <param name="window"></param> /// <param name="messageButtons"></param> /// <param name="messageIcon"></param> static void CreateContentGrid(string _title, string _message, Window window, MessageButtons messageButtons = MessageButtons.OK, MessageIcon messageIcon = MessageIcon.None) { content_grid = new Grid(); content_grid.Background = new SolidColorBrush(Colors.White); RowDefinition rd = new RowDefinition(); rd.Height = new GridLength(40, GridUnitType.Star); rd.MinHeight = 40; RowDefinition rd1 = new RowDefinition(); rd1.Height = GridLength.Auto; RowDefinition rd2 = new RowDefinition(); rd2.Height = new GridLength(42, GridUnitType.Star); rd2.MinHeight = 42; ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(50, GridUnitType.Star); ColumnDefinition cd1 = new ColumnDefinition(); cd1.Width = new GridLength(100); content_grid.ColumnDefinitions.Add(cd); content_grid.ColumnDefinitions.Add(cd1); content_grid.RowDefinitions.Add(rd); content_grid.RowDefinitions.Add(rd1); content_grid.RowDefinitions.Add(rd2); //Creating title Label title = new Label() { FontSize = 32, FontWeight = FontWeights.Light, VerticalAlignment = VerticalAlignment.Center, VerticalContentAlignment = System.Windows.VerticalAlignment.Center }; title.Content = _title.ToString(); Grid.SetRow(title, 0); content_grid.Children.Add(title); //Creating message StackPanel stc = new StackPanel(); Grid.SetRow(stc, 1); TextBlock message = new TextBlock() { Margin = new Thickness(5, 5, 5, 5), FontSize = 16, TextWrapping = TextWrapping.Wrap }; //message.MaxHeight = _mainWindow.Height - 120; message.Text = _message; message.TextWrapping = TextWrapping.Wrap; ScrollViewer scroll = new ScrollViewer(); scroll.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; scroll.Content = message; scroll.MaxHeight = _mainWindow.Height - 120; stc.Children.Add(scroll); content_grid.Children.Add(stc); //Creating message Icon StackPanel stc1 = new StackPanel(); Grid.SetRow(stc1, 1); Grid.SetColumn(stc1, 1); switch (messageIcon) { case MessageIcon.Exclamation: stc1.Children.Add(new Icons.Controls.ExclamationMark()); break; case MessageIcon.Error: stc1.Children.Add(new Icons.Controls.Error()); break; case MessageIcon.Information: stc1.Children.Add(new Icons.Controls.InformationMark()); break; case MessageIcon.Question: stc1.Children.Add(new Icons.Controls.QuestionMark()); break; } content_grid.Children.Add(stc1); //Creating buttons //StackPanel stc2 = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right, }; //Grid.SetRow(stc2, 2); //CButton btn_ok = new CButton(); //btn_ok.Content = "OK"; //btn_ok.Height = 30; //btn_ok.Width = 80; //btn_ok.Margin = new Thickness(0, 0, 10, 0); //btn_ok.OnClick += CButton_Loaded_1; //stc2.Children.Add(); content_grid.Children.Add(CreateButtons(messageButtons)); content_grid.Width = (window.Width * 70 / 100); Grid.SetRow(content_grid, 1); Grid content_grid1 = new Grid(); content_grid1.Background = new SolidColorBrush(Colors.White); Grid.SetRow(content_grid1, 1); main_grid.Children.Add(content_grid1); main_grid.Children.Add(content_grid); }
/// <summary> /// Creating main grid /// </summary> /// <param name="window"></param> /// <param name="title"></param> /// <param name="prompt"></param> /// <param name="messageButtons"></param> static void CreateMainGrid(Window window, string title, string prompt, MessageButtons messageButtons, MessageIcon messageIcon) { main_grid = new Grid(); RowDefinition rd = new RowDefinition(); rd.Height = new GridLength(32, GridUnitType.Star); RowDefinition rd1 = new RowDefinition(); rd1.Height = GridLength.Auto; RowDefinition rd2 = new RowDefinition(); rd2.Height = new GridLength(32, GridUnitType.Star); main_grid.RowDefinitions.Add(rd); main_grid.RowDefinitions.Add(rd1); main_grid.RowDefinitions.Add(rd2); CreateBackgroundGrid(); CreateContentGrid(title, prompt, window, messageButtons, messageIcon); }
/// <summary> /// Processes information and progress messages sent to the user interface. /// </summary> /// <param name="messageType">Message type.</param> /// <param name="messageRecord">Record that contains message data.</param> /// <param name="buttons">Message box buttons.</param> /// <param name="icon">Message box icon.</param> /// <param name="defaultButton">Message box default button.</param> /// <returns>Result of processing the message.</returns> public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { // Synchronously send the message to the setup wizard window on its thread. object result = this.setupWizard.Dispatcher.Invoke(DispatcherPriority.Send, new Func<MessageResult>(delegate() { return this.setupWizard.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton); })); return (MessageResult) result; }
public MessageButtons ShowMessage(string message, MessageButtons buttons) { return MessageButtons.OK; }
/// <summary> /// Called when R wants to display generic Windows MessageBox. /// Graph app may call Win32 API directly rather than going via R API callbacks. /// </summary> /// <returns>Pressed button code</returns> async Task<MessageButtons> IRCallbacks.ShowDialog(IReadOnlyList<IRContext> contexts, string s, bool isEvaluationAllowed, MessageButtons buttons, CancellationToken ct) { await TaskUtilities.SwitchToBackgroundThread(); if (isEvaluationAllowed) { await EvaluateAll(contexts, true, ct); } else { Mutated?.Invoke(this, EventArgs.Empty); } if (_hostClientApp != null) { return await _hostClientApp.ShowMessage(s, buttons); } return MessageButtons.OK; }
/* * Method that create a messagebox with the message and some of the standard button configurations */ public static int SetMessageBox(string strMessage, string strTitle, MessageButtons mesType) { return ShowMessage(strMessage, strTitle, (int)mesType); }
public MessageResult ShowWarning(IntPtr intPtr, string text, string headline, MessageButtons messageButtons, string learningId) { return Interop.Messaging.WsMessage.ShowMessage(intPtr, text, messageButtons, MessageBranding.WsDefault, MessageType.WsWarnIcon, headline, -1,learningId); }
public virtual Task<MessageButtons> ShowMessageAsync(string message, MessageButtons buttons, CancellationToken cancellationToken) { return Task.FromResult(MessageButtons.OK); }