/// <summary> /// Handles the corresponding event. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> void _guildForm_JoinRequested(GuildForm sender, EventArgs e) { var ib = new InputBox(GUIManager, "Enter guild name", "Enter the name of the guild you want to join.", MessageBoxButton.OkCancel); ib.OptionSelected += delegate(Control s, EventArgs<MessageBoxButton> e2) { var c = s as InputBox; if (c == null || e2.Item1 != MessageBoxButton.Ok || Socket == null) return; var input = c.InputText; if (string.IsNullOrEmpty(input)) return; using (var pw = ClientPacket.Say(string.Format("/joinguild \"{0}\"", input))) { Socket.Send(pw, ClientMessageType.Chat); } }; }
/// <summary> /// Creates a <see cref="InputBox"/> that only accepts numeric values. /// </summary> /// <param name="guiManager">The GUI manager this <see cref="Control"/> will be managed by.</param> /// <param name="text">The message box's title text.</param> /// <param name="message">The message to display.</param> /// <param name="buttonTypes">The <see cref="MessageBoxButton"/>s to display. Default is <see cref="MessageBoxButton.OkCancel"/></param> /// <param name="maxWidth">The maximum width of the created <see cref="MessageBox"/>. If less than or equal to 0, then /// the <see cref="MessageBox.DefaultMaxWidth"/> will be used instead. Default is 0.</param> /// <returns>An <see cref="InputBox"/> that only accepts numeric values.</returns> public static InputBox CreateNumericInputBox(IGUIManager guiManager, string text, string message, MessageBoxButton buttonTypes = MessageBoxButton.OkCancel, int maxWidth = 0) { var ret = new InputBox(guiManager, text, message, buttonTypes, maxWidth); ret.InputControl.AllowKeysHandler = TextEventArgsFilters.IsDigitFunc; ret.InputText = "0"; return ret; }