diff --git a/TelegramBotBase/Controls/ButtonGrid.cs b/TelegramBotBase/Controls/ButtonGrid.cs index 0c75db4..8dff23c 100644 --- a/TelegramBotBase/Controls/ButtonGrid.cs +++ b/TelegramBotBase/Controls/ButtonGrid.cs @@ -86,6 +86,11 @@ namespace TelegramBotBase.Controls /// public List HeadLayoutButtonRow { get; set; } + /// + /// Layout of columns which should be displayed below the header + /// + public List SubHeadLayoutButtonRow { get; set; } + /// /// Defines which type of Button Keyboard should be rendered. /// @@ -159,7 +164,9 @@ namespace TelegramBotBase.Controls if (!result.IsFirstHandler) return; - var button = HeadLayoutButtonRow?.FirstOrDefault(a => a.Text.Trim() == result.MessageText) ?? ButtonsForm.ToList().FirstOrDefault(a => a.Text.Trim() == result.MessageText); + 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); if (button == null) { @@ -236,7 +243,9 @@ namespace TelegramBotBase.Controls { case eKeyboardType.InlineKeyBoard: - var button = HeadLayoutButtonRow?.FirstOrDefault(a => a.Value == result.RawData) ?? ButtonsForm.ToList().FirstOrDefault(a => a.Value == result.RawData); + var button = HeadLayoutButtonRow?.FirstOrDefault(a => a.Value == result.RawData) + ?? SubHeadLayoutButtonRow?.FirstOrDefault(a => a.Value == result.RawData) + ?? ButtonsForm.ToList().FirstOrDefault(a => a.Value == result.RawData); if (button == null) { @@ -326,7 +335,7 @@ namespace TelegramBotBase.Controls if (this.EnableSearch && this.SearchQuery != null && this.SearchQuery != "") { - form = form.FilterDuplicate(this.SearchQuery); + form = form.FilterDuplicate(this.SearchQuery, true); } else { @@ -343,6 +352,18 @@ namespace TelegramBotBase.Controls form.InsertButtonRow(0, this.HeadLayoutButtonRow); } + if (this.SubHeadLayoutButtonRow != null && SubHeadLayoutButtonRow.Count > 0) + { + if (this.IsNavigationBarVisible) + { + form.InsertButtonRow(2, this.SubHeadLayoutButtonRow); + } + else + { + form.InsertButtonRow(1, this.SubHeadLayoutButtonRow); + } + } + switch (this.KeyboardType) { //Reply Keyboard could only be updated with a new keyboard. @@ -416,7 +437,7 @@ namespace TelegramBotBase.Controls bf.AddButtonRow(new ButtonBase(NoItemsLabel, "$")); } - if (this.NavigationBarVisibility == eNavigationBarVisibility.always | (this.NavigationBarVisibility == eNavigationBarVisibility.auto && PagingNecessary)) + if (this.IsNavigationBarVisible) { //🔍 List lst = new List(); @@ -455,6 +476,19 @@ namespace TelegramBotBase.Controls } } + public bool IsNavigationBarVisible + { + get + { + if (this.NavigationBarVisibility == eNavigationBarVisibility.always | (this.NavigationBarVisibility == eNavigationBarVisibility.auto && PagingNecessary)) + { + return true; + } + + return false; + } + } + /// /// Returns the maximum number of rows /// @@ -503,6 +537,9 @@ namespace TelegramBotBase.Controls if (this.HeadLayoutButtonRow != null && this.HeadLayoutButtonRow.Count > 0) layoutRows++; + if (this.SubHeadLayoutButtonRow != null && this.SubHeadLayoutButtonRow.Count > 0) + layoutRows++; + return layoutRows; } }