public async override Task Action(MessageResult result, string value = null) { //Find clicked button depending on Text or Value (depending on markup type) if (this.KeyboardType != eKeyboardType.InlineKeyBoard) { return; } if (result.Handled) { return; } if (!result.IsFirstHandler) { return; } await result.ConfirmAction(this.ConfirmationText ?? ""); var button = HeadLayoutButtonRow?.FirstOrDefault(a => a.Value == result.RawData) ?? SubHeadLayoutButtonRow?.FirstOrDefault(a => a.Value == result.RawData) ?? ButtonsForm.ToList().FirstOrDefault(a => a.Value == result.RawData); var index = HeadLayoutButtonRow?.IndexOf(button) ?? SubHeadLayoutButtonRow?.IndexOf(button) ?? ButtonsForm.ToList().IndexOf(button); if (button != null) { await OnButtonClicked(new ButtonClickedEventArgs(button, index)); result.Handled = true; return; } switch (result.RawData) { case "$previous$": if (this.CurrentPageIndex > 0) { this.CurrentPageIndex--; } this.Updated(); break; case "$next$": if (this.CurrentPageIndex < this.PageCount - 1) { this.CurrentPageIndex++; } this.Updated(); break; case "$filter$": this.SelectedViewIndex = 1; this.Updated(); break; case "$back$": this.SelectedViewIndex = 0; this.Updated(); break; } }
public async override Task Load(MessageResult result) { if (this.KeyboardType != eKeyboardType.ReplyKeyboard) { return; } if (!result.IsFirstHandler) { return; } if (result.MessageText == null) { return; } var button = HeadLayoutButtonRow?.FirstOrDefault(a => a.Text.Trim() == result.MessageText) ?? SubHeadLayoutButtonRow?.FirstOrDefault(a => a.Text.Trim() == result.MessageText) ?? ButtonsForm.ToList().FirstOrDefault(a => a.Text.Trim() == result.MessageText); var index = HeadLayoutButtonRow?.IndexOf(button) ?? SubHeadLayoutButtonRow?.IndexOf(button) ?? ButtonsForm.ToList().IndexOf(button); switch (this.SelectedViewIndex) { case 0: if (button != null) { await OnButtonClicked(new ButtonClickedEventArgs(button, index)); //Remove button click message if (this.DeletePreviousMessage) { await Device.DeleteMessage(result.MessageId); } result.Handled = true; return; } if (result.MessageText == PreviousPageLabel) { if (this.CurrentPageIndex > 0) { this.CurrentPageIndex--; } this.Updated(); result.Handled = true; } else if (result.MessageText == NextPageLabel) { if (this.CurrentPageIndex < this.PageCount - 1) { this.CurrentPageIndex++; } this.Updated(); result.Handled = true; } else if (this.EnableSearch) { if (result.MessageText.StartsWith("🔍")) { //Sent note about searching if (this.SearchQuery == null) { await this.Device.Send(this.SearchLabel); } this.SearchQuery = null; this.Updated(); result.Handled = true; return; } this.SearchQuery = result.MessageText; if (this.SearchQuery != null && this.SearchQuery != "") { this.CurrentPageIndex = 0; this.Updated(); result.Handled = true; return; } } else if (this.Tags != null) { if (result.MessageText == "📁") { //Remove button click message if (this.DeletePreviousMessage) { await Device.DeleteMessage(result.MessageId); } this.SelectedViewIndex = 1; this.Updated(); result.Handled = true; return; } } break; case 1: if (result.MessageText == this.BackLabel) { //Remove button click message if (this.DeletePreviousMessage) { await Device.DeleteMessage(result.MessageId); } this.SelectedViewIndex = 0; this.Updated(); result.Handled = true; return; } var i = result.MessageText.LastIndexOf(" "); if (i == -1) { i = result.MessageText.Length; } var t = result.MessageText.Substring(0, i); if (this.SelectedTags.Contains(t)) { this.SelectedTags.Remove(t); } else { this.SelectedTags.Add(t); } this.Updated(); result.Handled = true; break; } }