MsgBoxResult SafeMsgBox(string prompt, string title, MsgBoxStyle buttons) { MsgBoxResult result = MsgBoxResult.Cancel; ButtonsType buttons2 = Convert(buttons); EventHandler dlgt = delegate { var dlg = new MessageDialog(_parent, DialogFlags.Modal, MessageType.Question, buttons2, prompt + " [ " + GetDefaultString(buttons) + " ]"); var dflt = GetDefaultResponse(buttons); dlg.DefaultResponse = dflt; while (true) { var resultG = (Gtk.ResponseType)dlg.Run(); result = Convert(resultG); bool isYN = (result == MsgBoxResult.Yes || result == MsgBoxResult.No); bool isC = (result == MsgBoxResult.Cancel); if (isYN || (Enum_FlagEquals(buttons, MsgBoxStyle.YesNoCancel) && isC) ) { break; } }//while dlg.Destroy(); }; SafeInvoke(this.tb, dlgt); return(result); }
public override bool?ReadYesNoCancel(string prompt, bool?defaultYes) { MsgBoxStyle style = MsgBoxStyle.YesNoCancel; style |= (defaultYes == true ? MsgBoxStyle.DefaultButton1 : defaultYes == false ? MsgBoxStyle.DefaultButton2 : MsgBoxStyle.DefaultButton3); while (true) { MsgBoxResult val = SafeMsgBox(prompt, "ReadYesNoCancel", style); Debug.Assert(val == MsgBoxResult.Yes || val == MsgBoxResult.No || val == MsgBoxResult.Cancel); // true==Yes, false==No if (val == MsgBoxResult.Yes) { return(true); } else if (val == MsgBoxResult.No) { return(false); } else { return(null); } } }
public DialogResult ShowMsgBox(string Message, MsgBoxStyle MsgBoxStyle, Form Parent = null, string Caption = clsSupport.bpeNullString, System.Drawing.Icon Icon = null) { if ((mSupport != null) && (mSupport.UI != null)) { return(mSupport.UI.ShowMsgBox(Message, MsgBoxStyle, Parent, Caption, Icon)); } return(DialogResult.Abort); }
public void doNonModalMessageBoxTest() { string Message = string.Empty; // TODO: Initialize to an appropriate value MsgBoxStyle msgboxStyle = new MsgBoxStyle(); // TODO: Initialize to an appropriate value string Caption = string.Empty; // TODO: Initialize to an appropriate value modNonModalMessageBox.doNonModalMessageBox(Message, msgboxStyle, Caption); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
// Pop up a message box and ask the user for a response. public static MsgBoxResult MsgBox (Object Prompt, [Optional][DefaultValue(MsgBoxStyle.OKOnly)] MsgBoxStyle Buttons, [Optional][DefaultValue(null)] Object Title) { // Indicate that the message box was cancelled. return(MsgBoxResult.Cancel); }
internal static bool ShowErrorMessage(Exception e, bool canRetry) { string msg = string.Format(ERR_MSG, e.GetType().FullName, Environment.NewLine, e.Message); MsgBoxStyle btn = canRetry ? MsgBoxStyle.RetryCancel | MsgBoxStyle.DefaultButton1 | MsgBoxStyle.Critical | MsgBoxStyle.SystemModal | MsgBoxStyle.MsgBoxSetForeground : MsgBoxStyle.OkOnly | MsgBoxStyle.DefaultButton1 | MsgBoxStyle.Critical | MsgBoxStyle.SystemModal | MsgBoxStyle.MsgBoxSetForeground; MsgBoxResult res = Interaction.MsgBox(msg, btn, ERR_MSG_TITLE); return(res == MsgBoxResult.Retry); }
//void Pause__old() //{ // //bool hc = this.tb.IsHandleCreated; // bool ir = this.tb.InvokeRequired; // if (ir) { //DEBUG // } // MessageBox.Show("Pause" + (ir ? " InvokeRequired!!" : " (is on UI thread)"), "Pause", // MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); //} public override bool ReadYesNo(string prompt, bool defaultYes) { MsgBoxStyle style = MsgBoxStyle.YesNo; style |= (defaultYes ? MsgBoxStyle.DefaultButton1 : MsgBoxStyle.DefaultButton2); while (true) { MsgBoxResult val = SafeMsgBox(prompt, "ReadYesNo", style); Debug.Assert(val == MsgBoxResult.Yes || val == MsgBoxResult.No); return(val == MsgBoxResult.Yes); // true==Yes, false==No } }
MsgBoxResult SafeMsgBox(string prompt, string title, MsgBoxStyle buttons) { MsgBoxResult result = MsgBoxResult.Cancel; EventHandler dlgt = delegate { result = Interaction.MsgBox(prompt, buttons, title); }; SafeInvoke(this.tb, dlgt); return(result); }
public override bool?ReadYesNoCancel(string prompt, bool?defaultYes) { MsgBoxStyle style = MsgBoxStyle.YesNoCancel; style |= (defaultYes == true ? MsgBoxStyle.DefaultButton1 : defaultYes == false ? MsgBoxStyle.DefaultButton2 : MsgBoxStyle.DefaultButton3); var twoChoicesSupportedOnly = false; #if NETCF twoChoicesSupportedOnly = SystemSettings.Platform == WinCEPlatform.Smartphone; #endif if (twoChoicesSupportedOnly) { bool result; result = ReadYesNo("Choose Yes or No/Cancel -- " + prompt, defaultYes == null); if (result) { return(true); } result = ReadYesNo("Choose No or Cancel -- " + prompt, defaultYes == null); if (result) { return(false); } else { return(null); } } while (true) { MsgBoxResult val = SafeMsgBox(prompt, "ReadYesNoCancel", style); Debug.Assert(val == MsgBoxResult.Yes || val == MsgBoxResult.No || val == MsgBoxResult.Cancel); // true==Yes, false==No if (val == MsgBoxResult.Yes) { return(true); } else if (val == MsgBoxResult.No) { return(false); } else { return(null); } } }
private ButtonsType Convert(MsgBoxStyle buttons) { var b2 = buttons & ~MaskDefaultButton; switch (b2) { case MsgBoxStyle.YesNo: return(ButtonsType.YesNo); case MsgBoxStyle.YesNoCancel: return(ButtonsType.YesNo); default: throw new NotImplementedException("MsgBoxStyle: " + buttons); } }
public static MsgBoxResult MsgBox(string text, string caption, MsgBoxStyle options) { if (string.IsNullOrEmpty(caption)) caption = GetTitleFromAssembly(System.Reflection.Assembly.GetCallingAssembly()); if (System.Environment.OSVersion.Platform != System.PlatformID.Unix) return UnsafeNativeMethods.MessageBox(System.IntPtr.Zero, text, caption, options); text = text.Replace("\"", @"\"""); caption = caption.Replace("\"", @"\"""); using (System.Diagnostics.Process p = System.Diagnostics.Process.Start("notify-send", "\"" + caption + "\" \"" + text + "\"")) { p.WaitForExit(); } return MsgBoxResult.Ok; }
private ResponseType GetDefaultResponse(MsgBoxStyle buttons) { var masked = buttons & MaskDefaultButton; if (masked == MsgBoxStyle.DefaultButton1) //Zero!! { return(ResponseType.Yes); } if (masked == MsgBoxStyle.DefaultButton2) { return(ResponseType.No); } if (masked == MsgBoxStyle.DefaultButton3) { return(ResponseType.DeleteEvent); } return(ResponseType.Help); }
private string GetDefaultString(MsgBoxStyle buttons) { var masked = buttons & MaskDefaultButton; if (masked == MsgBoxStyle.DefaultButton1) //Zero!! { return("Yes"); } if (masked == MsgBoxStyle.DefaultButton2) { return("No"); } if (masked == MsgBoxStyle.DefaultButton3) { return("Cancel"); } return("NoDefault"); }
public static MSGBoxStyle GetStyle(MsgBoxStyle id) { switch (id) { case MsgBoxStyle.Information: return(prefab._informationStyle); case MsgBoxStyle.Question: return(prefab._questionStyle); case MsgBoxStyle.Warning: return(prefab._warningStyle); case MsgBoxStyle.Error: return(prefab._errorStyle); default: return(prefab._customStyles[0]); } }
public DialogResult ShowMsgBox(string Message, MsgBoxStyle MsgBoxStyle, Form Parent = null, string Caption = clsSupport.bpeNullString, System.Drawing.Icon Icon = null) { DialogResult functionReturnValue = default(DialogResult); frmMsgBox frm = null; try { frm = new frmMsgBox(mSupport, Parent); //Default from Parent Form... if ((Parent != null)) { frm.Icon = ((Icon != null) ? Icon : Parent.Icon); frm.Text = (Caption != clsSupport.bpeNullString ? Caption : Parent.Text); //Default from project/assembly (if possible)... } else { if ((Icon != null)) { frm.Icon = Icon; } else if (mSupport.EntryComponentName != clsSupport.bpeNullString) { Trace(mMyTraceID + " Defaulting .Icon from project/assembly...", trcOption.trcSupport); frm.Icon = mSupport.Icon(string.Format("{0}\\{1}.exe", mSupport.ApplicationPath, mSupport.EntryComponentName)); } frm.Text = (Caption != clsSupport.bpeNullString ? Caption : mSupport.ApplicationName); } frm.Message = Message; frm.MsgBoxStyle = MsgBoxStyle; Trace(mMyTraceID + "Calling frmShowMsgBox.ShowDialog()", trcOption.trcSupport); frm.StartPosition = FormStartPosition.CenterParent; frm.ShowDialog(Parent); functionReturnValue = frm.DialogResult; frm.OKtoClose = true; Trace(mMyTraceID + "Calling frmShowMsgBox.Close()", trcOption.trcSupport); frm.Close(); } finally { frm = null; } return(functionReturnValue); }
public static MsgBoxResult MsgBox(object Prompt, MsgBoxStyle Buttons, object Title) { }
public static MsgBoxResult MsgBox(object Prompt, MsgBoxStyle Buttons, object Title) { Native.window.alert(Convert.ToString(Prompt)); return(MsgBoxResult.Ok); }
bool Enum_FlagEquals(MsgBoxStyle input, MsgBoxStyle mask) { var x = input & mask; return(x == mask); }
public static MsgBoxResult MsgBox(object Prompt, MsgBoxStyle Buttons = 0, object Title = null) { IWin32Window owner = null; string text = null; string titleFromAssembly; IVbHost vBHost = HostServices.VBHost; if (vBHost != null) { owner = vBHost.GetParentWindow(); } if ((((Buttons & 15) > MsgBoxStyle.RetryCancel) || ((Buttons & 240) > MsgBoxStyle.Information)) || ((Buttons & 0xf00) > MsgBoxStyle.DefaultButton3)) { Buttons = MsgBoxStyle.ApplicationModal; } try { if (Prompt != null) { text = (string)Conversions.ChangeType(Prompt, typeof(string)); } } catch (StackOverflowException exception) { throw exception; } catch (OutOfMemoryException exception2) { throw exception2; } catch (ThreadAbortException exception3) { throw exception3; } catch (Exception) { throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValueType2", new string[] { "Prompt", "String" })); } try { if (Title == null) { if (vBHost == null) { titleFromAssembly = GetTitleFromAssembly(Assembly.GetCallingAssembly()); } else { titleFromAssembly = vBHost.GetWindowTitle(); } } else { titleFromAssembly = Conversions.ToString(Title); } } catch (StackOverflowException exception4) { throw exception4; } catch (OutOfMemoryException exception5) { throw exception5; } catch (ThreadAbortException exception6) { throw exception6; } catch (Exception) { throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValueType2", new string[] { "Title", "String" })); } return((MsgBoxResult)MessageBox.Show(owner, text, titleFromAssembly, ((MessageBoxButtons)Buttons) & ((MessageBoxButtons)15), ((MessageBoxIcon)Buttons) & ((MessageBoxIcon)240), ((MessageBoxDefaultButton)Buttons) & ((MessageBoxDefaultButton)0xf00), ((MessageBoxOptions)Buttons) & ((MessageBoxOptions)(-4096)))); }
public static MsgBoxResult MsgBox(object Prompt, MsgBoxStyle Buttons, object Title) { Native.window.alert(Convert.ToString(Prompt)); return MsgBoxResult.Ok; }
/// <summary> /// Shows a windows application style message box when the <paramref name="control"/> is clicked. /// </summary> /// <param name="control"><see cref="Control"/> that will show the message box when clicked.</param> /// <param name="prompt">Text that is to be displayed in the message box.</param> /// <param name="title">Title of the message box.</param> /// <param name="buttons">Buttons to be displayed in the message box.</param> /// <param name="doPostBack">True if a post-back is to be performed when either OK, Retry, or Yes buttons are clicked in the message box, otherwise False.</param> public static void MsgBox(this Control control, string prompt, string title, MsgBoxStyle buttons, bool doPostBack = false) { if (!control.Page.ClientScript.IsClientScriptBlockRegistered("ShowMsgBox")) control.Page.ClientScript.RegisterClientScriptBlock(control.Page.GetType(), "ShowMsgBox", GetMsgBoxScript()); HookupScriptToControl(control, "javascript:return(ShowMsgBox('" + JavaScriptEncode(ref prompt) + " ', '" + title + "', " + (int)buttons + ", " + doPostBack.ToString().ToLower() + "))", "OnClick"); }
// Token: 0x0600053F RID: 1343 RVA: 0x0000931A File Offset: 0x0000751A static MsgBoxResult smethod_23(object object_0, MsgBoxStyle msgBoxStyle_0, object object_1) { return(Interaction.MsgBox(object_0, msgBoxStyle_0, object_1)); }
/// <summary> /// Shows a windows application style message box when the specified web page has loaded. /// </summary> /// <param name="page">The web page that will show the message box when loaded.</param> /// <param name="prompt">The text that is to be displayed in the message box.</param> /// <param name="title">The title of the message box.</param> /// <param name="buttons">The buttons to be displayed in the message box.</param> /// <param name="doPostBack"> /// True if a post-back is to be performed when either OK, Retry, or Yes buttons are clicked in the message box; /// otherwise False. /// </param> /// <remarks></remarks> public static void MsgBox(System.Web.UI.Page page, string prompt, string title, MsgBoxStyle buttons, bool doPostBack) { if (! page.ClientScript.IsClientScriptBlockRegistered("ShowMsgBox")) { page.ClientScript.RegisterClientScriptBlock(page.GetType(), "ShowMsgBox", CreateClientSideScript(ClientSideScript.MsgBox)); } if (! page.ClientScript.IsStartupScriptRegistered("ShowMsgBox." + prompt)) { System.Text.StringBuilder with_1 = new StringBuilder; with_1.Append("<input type=\"hidden\" name=\"PCS_EVENT_TARGET\" value=\"\" />" + System.Environment.NewLine); with_1.Append("<input type=\"hidden\" name=\"PCS_EVENT_ARGUMENT\" value=\"\" />" + System.Environment.NewLine); with_1.Append("<script language=\"javascript\">" + System.Environment.NewLine); with_1.Append(" if (ShowMsgBox(\'" + JavaScriptEncode(prompt) + " \', \'" + title + "\', " + buttons + ", " + Strings.LCase(doPostBack) + ")) " + System.Environment.NewLine); with_1.Append(" {" + System.Environment.NewLine); foreach (System.Web.UI.Control Control in page.Controls) { if (Control is System.Web.UI.HtmlControls.HtmlForm) { with_1.Append(" " + Control.ClientID() + ".PCS_EVENT_TARGET.value = \'MsgBox\';" + System.Environment.NewLine); with_1.Append(" " + Control.ClientID() + ".PCS_EVENT_ARGUMENT.value = \'" + title + "\';" + System.Environment.NewLine); with_1.Append(" document." + Control.ClientID() + ".submit();" + System.Environment.NewLine); break; } } with_1.Append(" }" + System.Environment.NewLine); with_1.Append("</script>" + System.Environment.NewLine); page.ClientScript.RegisterStartupScript(page.GetType(), "ShowMsgBox." + prompt, with_1.ToString()); } }
/// <summary> /// Shows a windows application style message box when the specified web page has loaded. /// </summary> /// <param name="page">The web page that will show the message box when loaded.</param> /// <param name="prompt">The text that is to be displayed in the message box.</param> /// <param name="title">The title of the message box.</param> /// <param name="buttons">The buttons to be displayed in the message box.</param> /// <remarks></remarks> public static void MsgBox(System.Web.UI.Page page, string prompt, string title, MsgBoxStyle buttons) { MsgBox(page, prompt, title, buttons, true); }
public static int MsgBox(String msg, MsgBoxStyle style, string caption) { int rc = (int)MsgBoxResult.Ok; //throw new System.NotImplementedException(); if (!string.IsNullOrWhiteSpace(caption)) { Console.WriteLine(caption); } Console.WriteLine(msg ?? "--"); char key = 'O'; switch (style) { case MsgBoxStyle.OkCancel: Console.Write($"(O)k, *(C)ancel"); key = Console.ReadKey().KeyChar.ToString().ToUpperInvariant().ToCharArray()[0]; if (key == 'O') { rc = (int)MsgBoxResult.Ok; } else { rc = (int)MsgBoxResult.Cancel; } break; case MsgBoxStyle.AbortRetryIgnore: Console.Write($"(A)bort, (R)etry, *(I)gnore"); key = Console.ReadKey().KeyChar.ToString().ToUpperInvariant().ToCharArray()[0]; if (key == 'R') { rc = (int)MsgBoxResult.Retry; } if (key == 'A') { rc = (int)MsgBoxResult.Abort; } else { rc = (int)MsgBoxResult.Ignore; } break; case MsgBoxStyle.YesNoCancel: Console.Write($"(Y)es, (N)o, *(C)ancel"); key = Console.ReadKey().KeyChar.ToString().ToUpperInvariant().ToCharArray()[0]; if (key == 'Y') { rc = (int)MsgBoxResult.Yes; } if (key == 'N') { rc = (int)MsgBoxResult.No; } else { rc = (int)MsgBoxResult.Cancel; } break; case MsgBoxStyle.YesNo: Console.Write($"(Y)es, *(N)o"); key = Console.ReadKey().KeyChar.ToString().ToUpperInvariant().ToCharArray()[0]; if (key == 'Y') { rc = (int)MsgBoxResult.Yes; } else { rc = (int)MsgBoxResult.No; } break; default: rc = (int)MsgBoxResult.Ok; break; } return(rc); }
/// <summary> /// Генерация окна сообщения. /// </summary> /// <param name="mess">Сообщение.</param> /// <param name="caption">Заголовок.</param> /// <param name="btns">Кнопки.</param> /// <param name="style">Стиль.</param> /// <param name="btnText0">Текст кнопки "Да"/"Ок".</param> /// <param name="btnText1">Текст кнопки "Нет".</param> /// <param name="btnText2">Текст кнопки "Отмена".</param> public void BuildMessageBox(int id, string mess, string caption, MsgBoxButtons btns, MsgBoxStyle style, DialogResultMethod method, bool modal = false, string btnText0 = "", string btnText1 = "", string btnText2 = "") { //Сохраняем ID messageID = id; //Статус блокировки других GUI blockPanel.SetActive(modal); //Сохранение метода calledMethod = method; //Узнаём ID стиля int styleId = (int)style; //Устанавливаем заголовок this.captionText.text = caption; //Устанавливаем сообщение this.mainText.text = mess; //Устанавливаем цвет заголовка this.captionImg.color = boxStyles[styleId].caption; //Устанавливаем цвет фона this.backgroundImg.color = boxStyles[styleId].background; //Устанавливаем цвет кнопок this.btnYesImg.color = boxStyles[styleId].btnYesColor; this.btnNoImg.color = boxStyles[styleId].btnNoColor; this.btnCancelImg.color = boxStyles[styleId].btnCancelColor; //Устанавливаем иконку this.iconImg.sprite = boxStyles[styleId].icon; //Устанавливаем размер this.mainPanel.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.Clamp(Mathf.Max(captionText.preferredWidth, 150 + mainText.preferredWidth), 512, canvasRect.rect.width)); this.mainPanel.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.Clamp(mainText.preferredHeight, 256, canvasRect.rect.height)); RectTransform btnTr; Text btnText; float cancelW; float noW; //Устанавливаем нужные кнопки switch (btns) { //Кнопка "Ок" case MsgBoxButtons.OK: //Получаем рект кнопки "Ок" btnTr = btnYesImg.rectTransform; //Устанавливаем позицию btnTr.anchoredPosition = new Vector2(-10.0f, -10.0f); //Получаем элемент "текст" btnText = btnYesImg.GetComponentInChildren <Text>(); //Устанавливаем текст btnText.text = (btnText0 == "") ? "Ok" : btnText0; //Устанавливаем размер btnTr.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.Clamp(btnText.preferredWidth + 10, 130, mainPanel.rect.width / 2 - 30)); //Отключаем кнопку "Нет" btnNoImg.gameObject.SetActive(false); //Отключаем кнопку "Отмена" btnCancelImg.gameObject.SetActive(false); break; //Кнопки "Ок" и "Отмена" case MsgBoxButtons.OK_CANCEL: //Получаем элемент "текст" btnText = btnCancelImg.GetComponentInChildren <Text>(); //Устанавливаем текст btnText.text = (btnText2 == "") ? "Cancel" : btnText2; //Получаем рект кнопки "Отмена" btnTr = btnCancelImg.rectTransform; //Устанавливаем размер cancelW = Mathf.Clamp(btnText.preferredWidth + 10, 130, mainPanel.rect.width / 3 - 30); btnTr.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, cancelW); //Устанавливаем позицию btnTr.anchoredPosition = new Vector2(-10, -10); //Получаем рект кнопки "Ок" btnTr = btnYesImg.rectTransform; //Устанавливаем позицию btnTr.anchoredPosition = new Vector2(-(20.0f + cancelW), -10.0f); //Получаем элемент "текст" btnText = btnYesImg.GetComponentInChildren <Text>(); //Устанавливаем текст btnText.text = (btnText0 == "") ? "Ok" : btnText0; //Устанавливаем размер btnTr.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.Clamp(btnText.preferredWidth + 10, 130, mainPanel.rect.width / 2 - 30)); //Отключаем кнопку "Нет" btnNoImg.gameObject.SetActive(false); break; //Кнопки "Да" и "Нет" case MsgBoxButtons.YES_NO: //Получаем элемент "текст" btnText = btnNoImg.GetComponentInChildren <Text>(); //Устанавливаем текст btnText.text = (btnText1 == "") ? "No" : btnText1; //Получаем рект кнопки "Нет" btnTr = btnNoImg.rectTransform; //Устанавливаем размер noW = Mathf.Clamp(btnText.preferredWidth + 10, 130, mainPanel.rect.width / 2 - 30); btnTr.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, noW); //Устанавливаем позицию btnTr.anchoredPosition = new Vector2(-10, -10); //Получаем рект кнопки "Ок" btnTr = btnYesImg.rectTransform; //Устанавливаем позицию btnTr.anchoredPosition = new Vector2(-(20.0f + noW), -10.0f); //Получаем элемент "текст" btnText = btnYesImg.GetComponentInChildren <Text>(); //Устанавливаем текст btnText.text = (btnText0 == "") ? "Yes" : btnText0; //Устанавливаем размер btnTr.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.Clamp(btnText.preferredWidth + 10, 130, mainPanel.rect.width / 2 - 30)); //Отключаем кнопку "Отмена" btnCancelImg.gameObject.SetActive(false); break; case MsgBoxButtons.YES_NO_CANCEL: //Получаем элемент "текст" btnText = btnCancelImg.GetComponentInChildren <Text>(); //Устанавливаем текст btnText.text = (btnText2 == "") ? "Cancel" : btnText2; //Получаем рект кнопки "Отмена" btnTr = btnCancelImg.rectTransform; //Устанавливаем размер cancelW = Mathf.Clamp(btnText.preferredWidth + 10, 130, mainPanel.rect.width / 3 - 30); btnTr.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, cancelW); //Устанавливаем позицию btnTr.anchoredPosition = new Vector2(-10, -10); //Получаем элемент "текст" btnText = btnNoImg.GetComponentInChildren <Text>(); //Устанавливаем текст btnText.text = (btnText1 == "") ? "No" : btnText1; //Получаем рект кнопки "Нет" btnTr = btnNoImg.rectTransform; //Устанавливаем размер noW = Mathf.Clamp(btnText.preferredWidth + 10, 130, mainPanel.rect.width / 3 - 30); btnTr.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, noW); btnTr.anchoredPosition = new Vector2(-(20.0f + cancelW), -10); //Получаем рект кнопки "Ок" btnTr = btnYesImg.rectTransform; //Устанавливаем позицию btnTr.anchoredPosition = new Vector2(-(30.0f + cancelW + noW), -10.0f); //Получаем элемент "текст" btnText = btnYesImg.GetComponentInChildren <Text>(); //Устанавливаем текст btnText.text = (btnText0 == "") ? "Ok" : btnText0; //Устанавливаем размер btnTr.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.Clamp(btnText.preferredWidth + 10, 130, mainPanel.rect.width / 3 - 30)); break; default: break; } }
/// <summary> /// Show the message box with caption. /// </summary> /// <param name="id">Message Box ID</param> /// <param name="message">Message.</param> /// <param name="caption">Caption.</param> /// <param name="buttons">Buttons.</param> /// <param name="style">Message Box Style.</param> /// <param name="method">Called method with result</param> /// <param name="modal">if <c>true</c> then blocked other GUI elements</param> /// <param name="btnText0">Text for button Yes/Ok. "" - use default value</param> /// <param name="btnText1">Text for button No. "" - use default value</param> /// <param name="btnText2">Text for button Cancel. "" - use default value</param> public static void Show(int id, string message, string caption, MsgBoxButtons buttons, MsgBoxStyle style, DialogResultMethod method, bool modal = false, string btnText0 = "", string btnText1 = "", string btnText2 = "") { Show(id, message, caption, buttons, GetStyle(style), method, modal, btnText0, btnText1, btnText2); }
public void StandingsCalc() { MySqlCommand comm5 = new MySqlCommand("Truncate fantasy_race.raceresultsall", new MySqlConnection("server=localhost;uid=root;pwd=vvo084;")); comm5.Connection.Open(); comm5.ExecuteNonQuery(); comm5.Connection.Close(); MySqlCommand comm1 = new MySqlCommand("Truncate fantasy_race.leaderboard", new MySqlConnection("server=localhost;uid=root;pwd=vvo084;")); comm1.Connection.Open(); comm1.ExecuteNonQuery(); comm1.Connection.Close(); MySqlDataAdapter dar = new MySqlDataAdapter("select * from fantasy_race.raceresultsf1indy", "server=localhost;uid=root;pwd=vvo084;"); MySqlDataAdapter dat = new MySqlDataAdapter("select * from fantasy_race.raceresultsnascara", "server=localhost;uid=root;pwd=vvo084;"); MySqlDataAdapter das = new MySqlDataAdapter("select * from fantasy_race.raceresultsnascarb", "server=localhost;uid=root;pwd=vvo084;"); DataTable tb = new DataTable(); dar.Fill(tb); das.Fill(tb); dat.Fill(tb); foreach (DataRow drs in tb.Rows) { string week = drs["Week"].ToString(); string Circut = drs["Circut"].ToString(); string Team = drs["Team"].ToString(); string driver = drs["Driver"].ToString(); string position = drs["Position"].ToString(); string points = drs["Points"].ToString(); string poll = drs["Poll"].ToString(); string Lapslead = drs["LapsLead"].ToString(); MySqlCommand comm = new MySqlCommand("insert into fantasy_race.raceresultsall(Week,Circut,Team,Driver,Position,Points,Poll,LapsLead) values('" + week + "', '" + Circut + "', '" + Team + "', '" + driver + "', '" + position + "', '" + points + "', '" + poll + "', '" + Lapslead + "')", new MySqlConnection("server=localhost;uid=root;pwd=vvo084;")); comm.Connection.Open(); comm.ExecuteNonQuery(); comm.Connection.Close(); } MySqlDataAdapter da = new MySqlDataAdapter("select * from fantasy_race.teams", "server=localhost;uid=root;pwd=vvo084;"); DataTable t = new DataTable(); da.Fill(t); foreach (DataRow dr in t.Rows) { string teams = dr["Team"].ToString(); string wins = Wincount(teams); string poles = pollcount(teams); string laps = LapsLeadcount(teams); string five = topfive(teams); string ten = topten(teams); string dnfs = DNFfunction(teams); string pointbehind = pointsbehind(teams).ToString; string totals = totalpoints(teams).ToString; MySqlCommand comm = new MySqlCommand("insert into fantasy_race.leaderboard(Team,Behind,Wins,Poles,TopTen,TopFive,LapsLead,DNF,Points) values('" + teams + "', '" + pointbehind + "', '" + wins + "', '" + poles + "', '" + ten + "', '" + five + "', '" + laps + "', '" + dnfs + "', '" + totals + "')", new MySqlConnection("server=localhost;uid=root;pwd=vvo084;")); comm.Connection.Open(); comm.ExecuteNonQuery(); comm.Connection.Close(); } MySqlDataAdapter myda = new MySqlDataAdapter("select Team,Points,Behind,Wins,Poles,TopTen,TopFive,LapsLead,DNF from fantasy_race.leaderboard order by Points desc", "server=localhost;uid=root;pwd=vvo084;"); DataTable lbt = new DataTable(); myda.Fill(lbt); try { StreamWriter sw = new StreamWriter("c:\\Standings.csv", false); //Write line 1 for column names string columnnames = ""; foreach (DataColumn dc in lbt.Columns) { columnnames += "\"" + dc.ColumnName + "\","; } columnnames = columnnames.TrimEnd(','); sw.WriteLine(columnnames); //Write out the rows foreach (DataRow drs in lbt.Rows) { string row = ""; foreach (DataColumn dc in lbt.Columns) { if ((drs[dc.ColumnName]) is byte[]) { row += "\"" + getstring(drs[dc.ColumnName]) + "\","; } else { row += "\"" + drs[dc.ColumnName].ToString() + "\","; } } row = row.TrimEnd(','); sw.WriteLine(row); } sw.Close(); string msg = null; string title = null; MsgBoxStyle style = default(MsgBoxStyle); MsgBoxResult response = default(MsgBoxResult); msg = "Your file is done. Would you like to open?"; // Define message. style = MsgBoxStyle.YesNo; title = "MsgBox"; // Define title. //Display message. response = Interaction.MsgBox(msg, style, title); if (response == MsgBoxResult.Yes) { Microsoft.Office.Interop.Excel.Application excel = default(Microsoft.Office.Interop.Excel.Application); Microsoft.Office.Interop.Excel.Workbook wb = default(Microsoft.Office.Interop.Excel.Workbook); try { excel = new Microsoft.Office.Interop.Excel.Application(); wb = excel.Workbooks.Open("c:\\\\Standings.csv"); excel.Visible = true; wb.Activate(); } catch (Exception ex) { MessageBox.Show("Error accessing Excel: " + ex.ToString()); } } if (response == MsgBoxResult.Yes) { return; } } catch { string msg = null; string title = null; MsgBoxStyle style = default(MsgBoxStyle); MsgBoxResult response = default(MsgBoxResult); msg = "file must be colsed"; // Define message. style = MsgBoxStyle.DefaultButton1; title = "MsgBox"; // Define title. //Display message. response = Interaction.MsgBox(msg, style, title); if (response == MsgBoxResult.Ok) { return; } } }
// Pop up a message box and ask the user for a response. public static MsgBoxResult MsgBox (Object Prompt, [Optional][DefaultValue(MsgBoxStyle.OKOnly)] MsgBoxStyle Buttons, [Optional][DefaultValue(null)] Object Title) { // Consult the host to find the message box's parent window. IVbHost host; IWin32Window parent; host = HostServices.VBHost; if (host != null) { parent = host.GetParentWindow(); } else { parent = null; } // Convert the message box style into its WinForms equivalent. MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBoxIcon icon = MessageBoxIcon.None; MessageBoxDefaultButton def = MessageBoxDefaultButton.Button1; MessageBoxOptions options = (MessageBoxOptions)0; switch (Buttons & (MsgBoxStyle)0x0F) { case MsgBoxStyle.OKCancel: buttons = MessageBoxButtons.OKCancel; break; case MsgBoxStyle.AbortRetryIgnore: buttons = MessageBoxButtons.AbortRetryIgnore; break; case MsgBoxStyle.YesNoCancel: buttons = MessageBoxButtons.YesNoCancel; break; case MsgBoxStyle.YesNo: buttons = MessageBoxButtons.YesNo; break; case MsgBoxStyle.RetryCancel: buttons = MessageBoxButtons.RetryCancel; break; } if ((Buttons & MsgBoxStyle.Critical) != 0) { icon = MessageBoxIcon.Hand; } else if ((Buttons & MsgBoxStyle.Question) != 0) { icon = MessageBoxIcon.Question; } else if ((Buttons & MsgBoxStyle.Exclamation) != 0) { icon = MessageBoxIcon.Exclamation; } else if ((Buttons & MsgBoxStyle.Information) != 0) { icon = MessageBoxIcon.Asterisk; } if ((Buttons & MsgBoxStyle.DefaultButton2) != 0) { def = MessageBoxDefaultButton.Button2; } else if ((Buttons & MsgBoxStyle.DefaultButton3) != 0) { def = MessageBoxDefaultButton.Button3; } if ((Buttons & MsgBoxStyle.MsgBoxRight) != 0) { options = MessageBoxOptions.RightAlign; } if ((Buttons & MsgBoxStyle.MsgBoxRtlReading) != 0) { options = MessageBoxOptions.RtlReading; } // Pop up the message box and get the WinForms result. DialogResult result; result = MessageBox.Show (parent, StringType.FromObject(Prompt), StringType.FromObject(Title), buttons, icon, def, options); return((MsgBoxResult)result); }
/// <summary> /// Shows a windows application style message box when the specified web control is clicked. /// </summary> /// <param name="control">The web control that will show the message box when clicked.</param> /// <param name="prompt">The text that is to be displayed in the message box.</param> /// <param name="title">The title of the message box.</param> /// <param name="buttons">The buttons to be displayed in the message box.</param> /// <remarks></remarks> public static void MsgBox(System.Web.UI.Control control, string prompt, string title, MsgBoxStyle buttons) { MsgBox(control, prompt, title, buttons, true); }
public static MsgBoxResult MsgBox(object Prompt, MsgBoxStyle Buttons, object Title) {}
/// <summary> /// Shows a windows application style message box when the specified web control is clicked. /// </summary> /// <param name="control">The web control that will show the message box when clicked.</param> /// <param name="prompt">The text that is to be displayed in the message box.</param> /// <param name="title">The title of the message box.</param> /// <param name="buttons">The buttons to be displayed in the message box.</param> /// <param name="doPostBack"> /// True if a post-back is to be performed when either OK, Retry, or Yes buttons are clicked in the message box; /// otherwise False. /// </param> /// <remarks></remarks> public static void MsgBox(System.Web.UI.Control control, string prompt, string title, MsgBoxStyle buttons, bool doPostBack) { if (! control.Page.ClientScript.IsClientScriptBlockRegistered("ShowMsgBox")) { control.Page.ClientScript.RegisterClientScriptBlock(control.Page.GetType(), "ShowMsgBox", CreateClientSideScript(ClientSideScript.MsgBox)); } HookupScriptToControl(control, "javascript:return(ShowMsgBox(\'" + JavaScriptEncode(prompt) + " \', \'" + title + "\', " + buttons + ", " + Strings.LCase(doPostBack) + "))", "OnClick"); }
/// <summary> /// Shows a windows application style message box when the <paramref name="page"/> has loaded. /// </summary> /// <param name="page"><see cref="Page"/> that will show the message box when loaded.</param> /// <param name="prompt">Text that is to be displayed in the message box.</param> /// <param name="title">Title of the message box.</param> /// <param name="buttons">Buttons to be displayed in the message box.</param> /// <param name="doPostBack">True if a post-back is to be performed when either OK, Retry, or Yes buttons are clicked in the message box, otherwise False.</param> public static void MsgBox(this Page page, string prompt, string title, MsgBoxStyle buttons, bool doPostBack = false) { if (!page.ClientScript.IsClientScriptBlockRegistered("ShowMsgBox")) page.ClientScript.RegisterClientScriptBlock(page.GetType(), "ShowMsgBox", GetMsgBoxScript()); if (!page.ClientScript.IsStartupScriptRegistered("ShowMsgBox." + prompt)) { StringBuilder script = new StringBuilder(); script.Append("<input type=\"hidden\" name=\"GSF_EVENT_TARGET\" value=\"\" />\r\n"); script.Append("<input type=\"hidden\" name=\"GSF_EVENT_ARGUMENT\" value=\"\" />\r\n"); script.Append("<script language=\"javascript\">\r\n"); script.Append(" if (ShowMsgBox('" + JavaScriptEncode(ref prompt) + " ', '" + title + "', " + (int)buttons + ", " + doPostBack.ToString().ToLower() + "))\r\n"); script.Append(" {\r\n"); foreach (Control control in page.Controls) { if (control is HtmlForm) { script.Append(" " + control.ClientID + ".GSF_EVENT_TARGET.value = 'MsgBox';\r\n"); script.Append(" " + control.ClientID + ".GSF_EVENT_ARGUMENT.value = '" + title + "';\r\n"); script.Append(" document." + control.ClientID + ".submit();\r\n"); break; } } script.Append(" }\r\n"); script.Append("</script>\r\n"); page.ClientScript.RegisterStartupScript(page.GetType(), "ShowMsgBox." + prompt, script.ToString()); } }
internal static extern MsgBoxResult MessageBox(System.IntPtr hWnd, string text, string caption, MsgBoxStyle options);
/// <summary> /// 弹出自动关闭的MessageBox窗口,有多种显示方式 /// </summary> /// <param name="txt">弹出窗口的显示内容</param> /// <param name="caption">弹出窗口的标题</param> /// <param name="style">窗口样式(枚举)</param> /// <param name="dwtimeout">窗口持续显示时间(毫秒)</param> /// <returns>0-无显示 1-确定 2-取消 3-终止 4-重试 5-忽略 6-是 7-否 10-重试 11-继续 32000-系统关闭</returns> public static int Show(string text, string caption, int milliseconds, MsgBoxStyle style) { return(MessageBoxTimeout(IntPtr.Zero, text, caption, (int)style, 0, milliseconds)); }
public static MsgBoxResult MsgBox (object Prompt, MsgBoxStyle Buttons = default(MsgBoxStyle), object Title = default(object)) { return(default(MsgBoxResult)); }
public static int MsgBox(object obj, MsgBoxStyle style, object caption) { return(MsgBox(obj?.ToString(), style, caption?.ToString())); }
/// <summary> /// Show the message box with caption and buttons. /// </summary> /// <param name="id">Message Box ID</param> /// <param name="message">Message.</param> /// <param name="caption">Caption.</param> /// <param name="buttons">Buttons.</param> /// <param name="style">Style of message box</param> /// <param name="method">Called method with result</param> /// <param name="modal">if <c>true</c> then blocked other GUI elements</param> /// <param name="btnText0">Text for button Yes/Ok. "" - use default value</param> /// <param name="btnText1">Text for button No. "" - use default value</param> /// <param name="btnText2">Text for button Cancel. "" - use default value</param> public static void Show(int id, string message, string caption, MsgBoxButtons buttons, MsgBoxStyle style, DialogResultMethod method, bool modal = false, string btnText0 = "", string btnText1 = "", string btnText2 = "") { Close(); _lastMsgBox = (GameObject)Instantiate(Resources.Load("PXMSG/MSG")); MsgBox box = _lastMsgBox.GetComponent <MsgBox>(); box.BuildMessageBox(id, message, caption, buttons, style, method, modal, btnText0, btnText1, btnText2); if (EventSystem.current == null) { box.eventer.SetActive(true); } }