public static ReplyKeyboardMarkup DownloadKeyboard() { KeyboardButton b1 = new KeyboardButton("\U0001f519 Download Modus beenden"); KeyboardButton[] row = new [] { b1 }; return(new ReplyKeyboardMarkup(row, true)); }
static GameRoom() { KeyboardButton [][] def = new KeyboardButton[2][]; def[0] = new KeyboardButton[] { str_players, str_conf }; def[1] = new KeyboardButton[] { str_exit, str_id }; markupDefault = new ReplyKeyboardMarkup(def, true); KeyboardButton [][] adm = new KeyboardButton[3][]; adm[0] = new KeyboardButton[] { str_newgame }; adm[1] = new KeyboardButton[] { str_conf }; adm[2] = new KeyboardButton[] { str_exit, str_id, str_players }; markupAdmin = new ReplyKeyboardMarkup(adm, true); markupList = new ReplyKeyboardMarkup( new KeyboardButton[] { str_list, str_back }, true ); markupBack = new ReplyKeyboardMarkup( new KeyboardButton[] { str_back }, true ); markupShowMe = new ReplyKeyboardMarkup( new KeyboardButton[] { str_showme }, true ); markupShowRemaining = new ReplyKeyboardMarkup( new KeyboardButton[] { str_remaining }, true ); markupHide = new ReplyKeyboardHide() { HideKeyboard = true }; }
// Start is called before the first frame update void Start() { button = GetComponent <Button>(); keyboardButton = GetComponent <KeyboardButton>(); spriteRenderer = GetComponent <SpriteRenderer>(); checkScriptsNull(); }
private async static void Bot_OnMessage(object sender, MessageEventArgs e) { var msg = e.Message; if (msg.Text == "/start") { string texto = $"🙋♂️ Olá *{msg.Chat.FirstName} {msg.Chat.LastName}*. O texto que você enviar será retornado pelo Bot. " + $"Você pode compartilhar a sua *localização* ou o seu *contato*, basta pressionar os botões abaixo."; var RequestReplyKeyboard = new ReplyKeyboardMarkup(new[] { KeyboardButton.WithRequestLocation("📍 Localização"), KeyboardButton.WithRequestContact("👤 Contato"), }); await bot.SendTextMessageAsync( chatId : msg.Chat.Id, text : texto, parseMode : ParseMode.Markdown, replyMarkup : RequestReplyKeyboard); } else if (msg.Type == MessageType.Text) { await bot.SendTextMessageAsync(msg.Chat.Id, $"Olá *{msg.Chat.FirstName}*. \nVocê escreveu: \n*{msg.Text}*", ParseMode.Markdown); } }
public async Task Should_Receive_Contact_Info() { await _fixture.SendTestCaseNotificationAsync(FactTitles.ShouldReceiveContactInfo); await BotClient.SendTextMessageAsync( chatId : _classFixture.PrivateChat, text : "Share your contact info using the keyboard reply markup provided.", replyMarkup : new ReplyKeyboardMarkup( keyboardRow: new[] { KeyboardButton.WithRequestContact("Share Contact"), }, resizeKeyboard: true, oneTimeKeyboard: true ) ); Message contactMessage = await GetMessageFromChat(MessageType.Contact); Assert.NotEmpty(contactMessage.Contact.FirstName); Assert.NotEmpty(contactMessage.Contact.PhoneNumber); Assert.Equal(_classFixture.PrivateChat.Id, contactMessage.Contact.UserId); await BotClient.SendTextMessageAsync( chatId : _classFixture.PrivateChat, text : "Got it. Removing reply keyboard markup...", replyMarkup : new ReplyKeyboardRemove() ); }
public static string _Country_List(Options_Handler handler, out ReplyKeyboardMarkup keyboardButtons) { int start = int.Parse(handler.Url_ext); Telegram_HandlerClient telegram_Handler = new Telegram_HandlerClient(); var country_list = telegram_Handler._Get_Country_List(); int k = start > 0?start:0; KeyboardButton[][] keyboard = new KeyboardButton[100][]; for (int i = 0; i < 100; i++) { if (k < country_list.Length) { keyboard[i] = new KeyboardButton[] { new KeyboardButton(country_list[k].Country_Name + "/" + country_list[k].Country_Native_Name) }; k++; } else { break; } } keyboard = keyboard.Where(x => x != null && !string.IsNullOrEmpty(x[0].Text)).ToArray();; ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup(); replyKeyboardMarkup.OneTimeKeyboard = true; replyKeyboardMarkup.Keyboard = keyboard; keyboardButtons = replyKeyboardMarkup; return("🌎"); }
private ReplyKeyboardMarkup createKeyboard() { var rkm = new ReplyKeyboardMarkup(); //rkm.OneTimeKeyboard = true; KeyboardButton[] kewboardRow = new KeyboardButton[3]; var rows = new List <KeyboardButton[]>(); var cols = new List <KeyboardButton>(); AvailableFilters[] filters = (AvailableFilters[])Enum.GetValues(typeof(AvailableFilters)); rows.Add(new KeyboardButton[] { new KeyboardButton("view gallery") }); for (int i = 0; i < filters.Length; i++) { cols.Add(new KeyboardButton(filters[i].ToString())); if (i % 3 == 0 && i != 0) { rows.Add(cols.ToArray()); cols = new List <KeyboardButton>(); } } rkm.Keyboard = rows.ToArray(); return(rkm); }
public static List <KeyboardButton> TransformToList(this KeyboardButton butt) { List <KeyboardButton> result = new List <KeyboardButton>(); result.Add(butt); return(result); }
private void ButtonPress(KeyboardButton button) { keysAnimation.AddSelectedImage(button.buttonObject.transform.gameObject.GetComponent <Image>()); if (button.isCommandButton) { string keyValue = button.buttonValue; //.transform.gameObject.GetComponent<KeyControl>().keyValue; switch (keyValue) { case "backspace": inputString.RemoveFromEnd(1); textBox.text = inputString.text; UpdateHints(); break; } } else { if (button.buttonValue == " ") { keyboardHints.RemoveAll(); inputString.AddWord(symSpellManager.GetSuggestion(inputString.lastWord)); } else { inputString.Add(button.buttonValue); UpdateHints(); } textBox.text = inputString.text; } }
public KeyboardButton[][] GetKeyboard(List <RefusalType> options) { var rows = Convert.ToInt32(Math.Ceiling((double)options.Count / 2)); var buttons = 2; var keyboardRows = new KeyboardButton[rows][]; int current = 0; for (int i = 0; i < rows; i++) { var keyboardButtons = new KeyboardButton[buttons]; for (int j = 0; j < buttons; j++) { if (options.Count > current) { keyboardButtons[j] = new KeyboardButton(options[current].Name); } else { keyboardButtons[j] = new KeyboardButton(string.Empty); } current++; } keyboardRows[i] = keyboardButtons; } return(keyboardRows); }
private JObject GetButton(KeyboardButton button) { var obj = new JObject { { "text", button.Name } }; if (button.Action is DefaultButtonAction defaultButton) { if (defaultButton.Executor != null) { obj.Add("callback_data", defaultButton.Executor); } else { obj.Add("callback_data", button.Name); } } else if (button.Action is LinkButtonAction linkButtonAction) { obj.Add("url", linkButtonAction.Url); } return(obj); }
/// <summary> /// Requests the contact from the user. /// </summary> /// <param name="buttonText"></param> /// <param name="requestMessage"></param> /// <param name="OneTimeOnly"></param> /// <returns></returns> public async Task <Message> RequestContact(String buttonText = "Send your contact", String requestMessage = "Give me your phone number!", bool OneTimeOnly = true) { var rck = new ReplyKeyboardMarkup(KeyboardButton.WithRequestContact(buttonText)); rck.OneTimeKeyboard = OneTimeOnly; return(await API(a => a.SendTextMessageAsync(this.DeviceId, requestMessage, replyMarkup: rck))); }
private async Task Receive(Message message) { try { var phoneChatId = _phoneChatIds.FirstOrDefault(x => x.ChatId == message.Chat.Id); if (phoneChatId == null && message.Contact == null) { await _botClient.SendTextMessageAsync( chatId : message.Chat, text : "Пожалуйста, расшарьте Ваш номер телефона", replyMarkup : new ReplyKeyboardMarkup( new[] { KeyboardButton.WithRequestContact("Share Contact") }, true, true ) ); _logService.TraceMessage($"Новый пользователь: {message.Chat.Username}"); } else { if (phoneChatId == null) { lock (this) { string phone = message.Contact.PhoneNumber.Replace("+", ""); phoneChatId = new PhoneChatId() { ChatId = message.Chat.Id, Phone = phone, Allowed = _allowedPhoneNumbers.Any(x => x == phone) }; _phoneChatIds.Add(phoneChatId); XmlSerializer xsr = new XmlSerializer(typeof(List <PhoneChatId>)); using (StreamWriter tw = new StreamWriter(_phoneChatIdsFile)) { xsr.Serialize(tw, _phoneChatIds); } } } if (phoneChatId.Allowed) { await _botClient.SendTextMessageAsync( chatId : message.Chat, text : "Вы подключены. Заявки будут высылаться вам автоматически." ); } else { await _botClient.SendTextMessageAsync( chatId : message.Chat, text : "У вас нет доступа" ); } } } catch (Exception e) { _logService.LogError(e); } }
public JObject BuildReplyMarkupKeyboard(KeyboardButton menu, KeyboardPage keyboard, bool isOneTime = false) { var buttons = new JArray(); foreach (var row in keyboard.Rows) { if (row.Buttons.Count < 1) { continue; } buttons.Add(new JArray()); foreach (var button in row.Buttons) { (buttons[buttons.Count - 1] as JArray).Add(GetButton(button)); } } if (menu != null) { buttons.Add(new JArray { GetButton(menu) }); } return(new JObject { { "one_time", isOneTime }, { "buttons", buttons }, { "inline", false } }); }
public ReplyKeyboardMarkup(KeyboardButton[][] keyboard, bool resizeKeyboard = false, bool oneTimeKeyboard = false) { Keyboard = keyboard; ResizeKeyboard = resizeKeyboard; OneTimeKeyboard = oneTimeKeyboard; }
public static IReplyMarkup GetKeyboardForQuestions() { var aButton = new KeyboardButton("A"); var bButton = new KeyboardButton("B"); var cButton = new KeyboardButton("C"); var dButton = new KeyboardButton("D"); var keyboard = new[] { new[] { aButton, bButton }, new[] { cButton, dButton } }; return(new ReplyKeyboardMarkup { Keyboard = keyboard }); }
private static KeyboardButton keys(string txt) { KeyboardButton kb = new KeyboardButton(""); kb.Text = txt; return(kb); }
static ReplyKeyboardMarkup GetKeyboard() { var button1 = new KeyboardButton() { Text = "Расписание" }; var button2 = new KeyboardButton() { Text = "Варианты" }; var firstRow = new List <KeyboardButton>() { button1, button2 }; var button3 = new KeyboardButton() { Text = "На след. неделю" }; var secondRow = new List <KeyboardButton>() { button3 }; var keyboard = new ReplyKeyboardMarkup(new List <List <KeyboardButton> >() { firstRow, secondRow }, resizeKeyboard: true); return(keyboard); }
private ReplyKeyboardMarkup GetPrettiesKeyboardDisplay() { var keyboardButtonsRow1 = new KeyboardButton[] { new KeyboardButton("Текст любви"), new KeyboardButton("Милая история"), }; var keyboardButtonsRow2 = new KeyboardButton[] { new KeyboardButton("Если поругались!") }; var keyboardButtonsRow3 = new KeyboardButton[] { new KeyboardButton("У меня фантазия \nзакончилась(") }; var keyboardButtonsRow4 = new KeyboardButton[] { new KeyboardButton("Назад") }; var rkhm = new ReplyKeyboardMarkup(); rkhm.Keyboard = new KeyboardButton[][] { keyboardButtonsRow1, keyboardButtonsRow2, keyboardButtonsRow3, keyboardButtonsRow4 }; return(rkhm); }
/// <summary> /// Зарегистрировать студента в списке /// </summary> /// <param name="msg">Сообщение</param> public void registerCommand(Message msg) { Storage.Student student = db.Students.Where(a => a.UserID == msg.From.Id).FirstOrDefault(); if (student != null) { client.SendTextMessageAsync(msg.Chat.Id, string.Format("{0}, вы уже зарегистрированы, ваш E-mail: {1}. Для редактирования профиля используется команда /profile", msg.From.FirstName, student.EMail)); } else { // Кнопка для регистрации с запросом номера телефона KeyboardButton b = new KeyboardButton("Отправить телефон") { RequestContact = true }; // Панель кнопок KeyboardButton[] keys = new KeyboardButton[1] { b }; // Разметка ответа var markup = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup(keys, true, true); client.SendTextMessageAsync(msg.Chat.Id, "Для регистрации отправьте мне телефон и после него E-mail", replyMarkup: markup); // Переход в состояние регистрации пользователя SetState(msg.From.Id, BotState.Registration); state[msg.From.Id].PhoneNumber = null; } }
public async ValueTask <ReplyKeyboardMarkup> GenerateKeyBoards() { List <string> regions = await provider.regionService.GetAllRegions(); List <IEnumerable <KeyboardButton> > buttRegions = new List <IEnumerable <KeyboardButton> >(); regions.ForEach((item) => { KeyboardButton button = new KeyboardButton() { Text = item }; buttRegions.Add(button.TransformToList()); }); KeyboardButton butt = new KeyboardButton("Back"); IEnumerable <KeyboardButton> backButton = butt.TransformToList(); buttRegions.Add(backButton); IEnumerable <IEnumerable <KeyboardButton> > resButt = buttRegions; return(new ReplyKeyboardMarkup { Keyboard = resButt, ResizeKeyboard = true }); }
public void AddKeyboardToEnd(KeyboardButton button) { if (_keyboard == null) { _keyboard = new List <List <KeyboardButton> > { new List <KeyboardButton> { button } }; } else { if (_keyboard.Last().Count >= 8) { _keyboard.Add(new List <KeyboardButton> { button }); } else { _keyboard.Last().Add(button); } } }
public static ReplyKeyboardMarkup GetKeyboardMarkup() { KeyboardButton[][] tempKeyboardButtons = new KeyboardButton[][] { new KeyboardButton[] { new KeyboardButton("ДОЛЛАР США (USD)") }, new KeyboardButton[] { new KeyboardButton("ЕВРО (EUR)") }, new KeyboardButton[] { new KeyboardButton("РОССИЙСКИЙ РУБЛЬ (RUB)") }, new KeyboardButton[] { new KeyboardButton("Отмена") } }; List <Currency> Currences = Get("{\"size\":50}"); if (Currences.Count > 0) { Currences = Currences.OrderBy(n => n.name_rus).ToList(); tempKeyboardButtons = new KeyboardButton[Currences.Count + 1][]; for (int i = 0; i < Currences.Count; i++) { tempKeyboardButtons[i] = new KeyboardButton[] { new KeyboardButton(String.Format("{0} ({1})", Currences[i].name_rus, Currences[i].kod)) }; } tempKeyboardButtons[Currences.Count] = new KeyboardButton[] { new KeyboardButton("Отмена") }; } ReplyKeyboardMarkup replyKeyboardMarkupCurrences = new ReplyKeyboardMarkup() { OneTimeKeyboard = true, Keyboard = tempKeyboardButtons }; return(replyKeyboardMarkupCurrences); }
/// <summary> /// Requests the location from the user. /// </summary> /// <param name="buttonText"></param> /// <param name="requestMessage"></param> /// <param name="OneTimeOnly"></param> /// <returns></returns> public async Task <Message> RequestLocation(String buttonText = "Send your location", String requestMessage = "Give me your location!", bool OneTimeOnly = true) { var rcl = new ReplyKeyboardMarkup(KeyboardButton.WithRequestLocation(buttonText)); rcl.OneTimeKeyboard = OneTimeOnly; return(await API(a => a.SendTextMessageAsync(this.DeviceId, requestMessage, replyMarkup: rcl))); }
public JObject BuildReplyMarkupKeyboard(KeyboardButton menu, KeyboardPage keyboard, bool isOneTime = false) { var buttons = new JArray(); foreach (var row in keyboard.Rows) { buttons.Add(new JArray()); foreach (var button in row.Buttons) { (buttons[buttons.Count - 1] as JArray).Add(button.Name); } } if (menu != null) { buttons.Add(new JArray { { menu.Name } }); } return(new JObject { { "one_time_keyboard", isOneTime }, { "resize_keyboard", true }, { "keyboard", buttons } }); }
public static async void RetryVote(Message message, TelegramBotClient bot, object arg) { try { Vote vote = VoteSystem.GetVote(Int32.Parse((arg as CallbackQuery).Data.Replace("retry", ""))); var keyb = new KeyboardButton[vote.Points.Count + 1][]; int i = 0; foreach (var point in vote.Points.Keys) { keyb[i++] = new KeyboardButton[] { new KeyboardButton(point) }; } keyb[i++] = new KeyboardButton[] { new KeyboardButton("[Назад в главное меню]") }; UserDatabase.Broadcast(u => !vote.UserIsVoted(u.User.Id), user => "*Опрос пользователей:*\n\n" + vote.Caption.Trim(), bot, (new ReplyMenu("", true, keyb)).Keyboard); await bot.SendTextMessageAsync(message.Chat.Id, "Опрос отправлен всем непроголосовавшим пользователям", ParseMode.Markdown); } catch { await bot.SendTextMessageAsync(message.Chat.Id, "*Опрос закрыт или не создан*"); } }
private static async void GetVote(Message message, TelegramBotClient bot) { try { var votes = VoteSystem.GetVotesNames(); if (!votes.Any()) { await bot.SendTextMessageAsync(message.Chat.Id, $"*Нет открытых голосований*", ParseMode.Markdown, false, false, 0, CommandsCenter.GetMenu("StartMenu").Keyboard); return; } KeyboardButton[][] keyboard = new KeyboardButton[votes.Count() + 1][]; int i = 0; keyboard[i++] = new KeyboardButton[] { new KeyboardButton("[Назад в меню]") }; foreach (var vote in votes) { keyboard[i++] = new KeyboardButton[] { CommandsCenter.GetReplyButton(vote).Button }; } await bot.SendTextMessageAsync(message.Chat.Id, $"*Список открытых голосований:*", ParseMode.Markdown, false, false, 0, new ReplyMenu("", true, keyboard).Keyboard); } catch { } }
public int AddRows(KeyboardButton button) { ReplyKeyBoards.Add(new List <KeyboardButton>() { button }); return(ReplyKeyBoards.Count); }
public void AddRequestLocation(string text) { KeyboardButton btn = KeyboardButton.WithRequestLocation(text); _buttons.Add(new List <KeyboardButton> { btn }); }
public ReplyKeyboardMarkupBuilder Set(KeyboardButton button) { _ = button ?? throw new ArgumentNullException(nameof(button)); _set = new[] { new[] { button } }; _buttons = null; return(this); }
public static ReplyKeyboardMarkup cancell() { ReplyKeyboardMarkup rpl2 = new ReplyKeyboardMarkup(); KeyboardButton[] r3 = new KeyboardButton[] { keys("⛔️انصراف⛔️") }; rpl2.Keyboard = new KeyboardButton[][] { r3 }; return(rpl2); }
public ReplyKeyboardMarkup(KeyboardButton[] keyboardRow, bool resizeKeyboard = false, bool oneTimeKeyboard = false) { Keyboard = new[] { keyboardRow }; ResizeKeyboard = resizeKeyboard; OneTimeKeyboard = oneTimeKeyboard; }
/// <summary> /// Returns the state of the given <see cref="KeyboardButton"/>. /// </summary> public bool this[KeyboardButton button] { get { bool result; BaseKeyStates.TryGetValue(button, out result); return result; } private set { BaseKeyStates[button] = value; } }
internal void KeyPressEvent(KeyboardButton button) { if(Parent != null) { //prepare event list Component[] eventList = Parent.FindAll(Parent.MousePosition, false, true); bool consumed = false; //perform event passing foreach(Component comp in eventList) { //call event comp.InvokeKeyPress(button); //add to components waiting on release KeyboardActiveComponents.Add(button, comp); //consume if opaque if(comp.InputOpaque.Value) { //if eligible for keyboard focus, give it if(comp.HasListeners(InputEventType.KPress) || comp.HasListeners(InputEventType.KRelease) || comp.HasListeners(InputEventType.CTyped)) { FocusedComponent = comp; consumed = true; } break; } } //if unconsumed, give to focused if(!consumed && FocusedComponent != null) { FocusedComponent.InvokeKeyPress(button); } } }
public KeyEventArgs(KeyboardButton button, bool pressed) { Button = button; Pressed = pressed; }
public KeyEventArgs(KeyEventArgs args) : base(args) { Button = args.Button; Pressed = args.Pressed; }
private void InitializeComponent() { this.button1 = new mvcmt.KeyboardButton(); this.button2 = new mvcmt.KeyboardButton(); this.button3 = new mvcmt.KeyboardButton(); this.button4 = new mvcmt.KeyboardButton(); this.button5 = new mvcmt.KeyboardButton(); this.button6 = new mvcmt.KeyboardButton(); this.button7 = new mvcmt.KeyboardButton(); this.button8 = new mvcmt.KeyboardButton(); this.SuspendLayout(); // // button1 // this.button1.BackColor = System.Drawing.Color.White; this.button1.FlatAppearance.BorderSize = 0; this.button1.FlatAppearance.MouseDownBackColor = System.Drawing.Color.GreenYellow; this.button1.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White; this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button1.Location = new System.Drawing.Point(8, 8); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(61, 279); this.button1.TabIndex = 1; this.button1.Text = "C"; //this.button1.Click += button_Click; this.button1.MouseDown += button_Click; this.button1.MouseUp += button_Up; this.button1.UseVisualStyleBackColor = false; // // button2 // this.button2.BackColor = System.Drawing.Color.White; this.button2.FlatAppearance.BorderSize = 0; this.button2.FlatAppearance.MouseDownBackColor = System.Drawing.Color.GreenYellow; this.button2.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White; this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button2.Location = new System.Drawing.Point(75, 8); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(61, 279); this.button2.TabIndex = 2; this.button2.Text = "D"; this.button2.UseVisualStyleBackColor = false; this.button2.Click += button_Click; // // button3 // this.button3.BackColor = System.Drawing.Color.White; this.button3.FlatAppearance.BorderSize = 0; this.button3.FlatAppearance.MouseDownBackColor = System.Drawing.Color.GreenYellow; this.button3.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White; this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button3.Location = new System.Drawing.Point(143, 8); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(61, 279); this.button3.TabIndex = 3; this.button3.Text = "E"; this.button3.UseVisualStyleBackColor = false; this.button3.Click += button_Click; // // button4 // this.button4.BackColor = System.Drawing.Color.White; this.button4.FlatAppearance.BorderSize = 0; this.button4.FlatAppearance.MouseDownBackColor = System.Drawing.Color.GreenYellow; this.button4.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White; this.button4.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button4.Location = new System.Drawing.Point(211, 8); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(61, 279); this.button4.TabIndex = 4; this.button4.Text = "F"; this.button4.UseVisualStyleBackColor = false; this.button4.Click += button_Click; // // button5 // this.button5.BackColor = System.Drawing.Color.White; this.button5.FlatAppearance.BorderSize = 0; this.button5.FlatAppearance.MouseDownBackColor = System.Drawing.Color.GreenYellow; this.button5.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White; this.button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button5.Location = new System.Drawing.Point(279, 8); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(61, 279); this.button5.TabIndex = 5; this.button5.Text = "G"; this.button5.UseVisualStyleBackColor = false; this.button5.Click += button_Click; // // button6 // this.button6.BackColor = System.Drawing.Color.White; this.button6.FlatAppearance.BorderSize = 0; this.button6.FlatAppearance.MouseDownBackColor = System.Drawing.Color.GreenYellow; this.button6.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White; this.button6.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button6.Location = new System.Drawing.Point(346, 8); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(61, 279); this.button6.TabIndex = 6; this.button6.Text = "A"; this.button6.UseVisualStyleBackColor = false; this.button6.Click += button_Click; // // button7 // this.button7.BackColor = System.Drawing.Color.White; this.button7.FlatAppearance.BorderSize = 0; this.button7.FlatAppearance.MouseDownBackColor = System.Drawing.Color.GreenYellow; this.button7.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White; this.button7.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button7.Location = new System.Drawing.Point(413, 8); this.button7.Name = "button7"; this.button7.Size = new System.Drawing.Size(61, 279); this.button7.TabIndex = 7; this.button7.Text = "H"; this.button7.UseVisualStyleBackColor = false; this.button7.Click += button_Click; // // button8 // this.button8.BackColor = System.Drawing.Color.White; this.button8.FlatAppearance.BorderSize = 0; this.button8.FlatAppearance.MouseDownBackColor = System.Drawing.Color.GreenYellow; this.button8.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White; this.button8.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button8.Location = new System.Drawing.Point(480, 8); this.button8.Name = "button8"; this.button8.Size = new System.Drawing.Size(61, 279); this.button8.TabIndex = 8; this.button8.Text = "C"; this.button8.UseVisualStyleBackColor = false; this.button8.MouseClick += button_Click; // // View // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.MediumOrchid; this.ClientSize = new System.Drawing.Size(548, 294); this.Controls.Add(this.button1); this.Controls.Add(this.button2); this.Controls.Add(this.button3); this.Controls.Add(this.button4); this.Controls.Add(this.button5); this.Controls.Add(this.button6); this.Controls.Add(this.button7); this.Controls.Add(this.button8); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.KeyPreview = true; this.MaximizeBox = false; this.Name = "View"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "8s8b8k"; this.KeyDown += View_KeyDown; this.KeyUp += View_KeyUp; this.ResumeLayout(false); }
internal void KeyReleaseEvent(KeyboardButton button) { if(Parent != null) { //store all components that are guaranteed a call ActiveComponents.Clear(); ActiveComponents.UnionWith(KeyboardActiveComponents.GetValues(button)); //prepare event list Component[] eventList = Parent.FindAll(Parent.MousePosition, false, true); bool consumed = false; //perform event passing foreach(Component comp in eventList) { //call event comp.InvokeKeyRelease(button); //remove from active components (we don't care if it doesn't contain the element, it'll just do nothing) ActiveComponents.Remove(comp); //consume if opaque if(comp.InputOpaque.Value) { //if eligible for keyboard focus, give it if(comp.HasListeners(InputEventType.KPress) || comp.HasListeners(InputEventType.KRelease) || comp.HasListeners(InputEventType.CTyped)) { FocusedComponent = comp; consumed = true; } break; } } //if unconsumed, give to focused if(!consumed && FocusedComponent != null) { FocusedComponent.InvokeKeyRelease(button); ActiveComponents.Remove(FocusedComponent); } //satisfy waiting components foreach(Component comp in ActiveComponents) { //call event comp.InvokeKeyRelease(button); } //remove all waiters KeyboardActiveComponents.Clear(button); } }