Update ButtonForm.cs
adding method to create a ButtonForm duplicate and filter the single buttons, used for ButtonGrid
This commit is contained in:
parent
cf9e2285f1
commit
46576eb819
@ -188,10 +188,10 @@ namespace TelegramBotBase.Form
|
||||
DependencyControl = this.DependencyControl
|
||||
};
|
||||
|
||||
foreach(var b in Buttons)
|
||||
foreach (var b in Buttons)
|
||||
{
|
||||
var lst = new List<ButtonBase>();
|
||||
foreach(var b2 in b)
|
||||
foreach (var b2 in b)
|
||||
{
|
||||
lst.Add(b2);
|
||||
}
|
||||
@ -200,5 +200,35 @@ namespace TelegramBotBase.Form
|
||||
|
||||
return bf;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a copy of this form and filters by the parameter.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ButtonForm FilterDuplicate(String filter)
|
||||
{
|
||||
var bf = new ButtonForm()
|
||||
{
|
||||
Markup = this.Markup,
|
||||
DependencyControl = this.DependencyControl
|
||||
};
|
||||
|
||||
foreach (var b in Buttons)
|
||||
{
|
||||
var lst = new List<ButtonBase>();
|
||||
foreach (var b2 in b)
|
||||
{
|
||||
if (b2.Text.IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) == -1)
|
||||
continue;
|
||||
|
||||
lst.Add(b2);
|
||||
}
|
||||
|
||||
if (lst.Count > 0)
|
||||
bf.Buttons.Add(lst);
|
||||
}
|
||||
|
||||
return bf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user