Update ButtonForm.cs

- Modifying FilterDuplicate to allow full row filter or not
This will keep only the matches, or the full row where it matches.
This commit is contained in:
FlorianDahn 2020-10-05 14:22:47 +02:00
parent 8ef8733a2b
commit a364562fd3

View File

@ -210,7 +210,7 @@ namespace TelegramBotBase.Form
/// Creates a copy of this form and filters by the parameter.
/// </summary>
/// <returns></returns>
public ButtonForm FilterDuplicate(String filter)
public ButtonForm FilterDuplicate(String filter, bool ByRow = false)
{
var bf = new ButtonForm()
{
@ -226,8 +226,17 @@ namespace TelegramBotBase.Form
if (b2.Text.IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) == -1)
continue;
//Copy full row, when at least one match has found.
if (ByRow)
{
lst.AddRange(b);
break;
}
else
{
lst.Add(b2);
}
}
if (lst.Count > 0)
bf.Buttons.Add(lst);