Adding paging/search example
This commit is contained in:
parent
ad6cf9539c
commit
183e89c36f
@ -804,6 +804,8 @@ await this.NavigateTo(cd);
|
|||||||
### Button Grid
|
### Button Grid
|
||||||
<img src="images/buttongrid.gif?raw=true" />
|
<img src="images/buttongrid.gif?raw=true" />
|
||||||
|
|
||||||
|
#### Paging & Searching
|
||||||
|
<img src="images/buttongrid_pagingfilter.gif?raw=true" />
|
||||||
|
|
||||||
## Groups
|
## Groups
|
||||||
|
|
||||||
|
|||||||
@ -188,6 +188,7 @@ namespace TelegramBotBase.Controls
|
|||||||
|
|
||||||
if (this.SearchQuery != null && this.SearchQuery != "")
|
if (this.SearchQuery != null && this.SearchQuery != "")
|
||||||
{
|
{
|
||||||
|
this.CurrentPageIndex = 0;
|
||||||
this.Updated();
|
this.Updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,7 +481,14 @@ namespace TelegramBotBase.Controls
|
|||||||
if (this.ButtonsForm.Count == 0)
|
if (this.ButtonsForm.Count == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return (int)Math.Ceiling((decimal)(this.ButtonsForm.Rows / (decimal)(MaximumRow - 3)));
|
var bf = this.ButtonsForm;
|
||||||
|
|
||||||
|
if (this.EnableSearch && this.SearchQuery != null && this.SearchQuery != "")
|
||||||
|
{
|
||||||
|
bf = bf.FilterDuplicate(this.SearchQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int)Math.Ceiling((decimal)(bf.Rows / (decimal)(MaximumRow - 3)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ namespace TelegramBotBaseTest.Tests.Controls
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Bg_ButtonClicked(object sender, ButtonClickedEventArgs e)
|
private async Task Bg_ButtonClicked(object sender, ButtonClickedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Button == null)
|
if (e.Button == null)
|
||||||
return;
|
return;
|
||||||
|
|||||||
73
TelegramBotBaseTest/Tests/Controls/ButtonGridPagingForm.cs
Normal file
73
TelegramBotBaseTest/Tests/Controls/ButtonGridPagingForm.cs
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TelegramBotBase.Args;
|
||||||
|
using TelegramBotBase.Controls;
|
||||||
|
using TelegramBotBase.Form;
|
||||||
|
|
||||||
|
namespace TelegramBotBaseTest.Tests.Controls
|
||||||
|
{
|
||||||
|
public class ButtonGridPagingForm : AutoCleanForm
|
||||||
|
{
|
||||||
|
|
||||||
|
ButtonGrid m_Buttons = null;
|
||||||
|
|
||||||
|
public ButtonGridPagingForm()
|
||||||
|
{
|
||||||
|
this.DeleteMode = TelegramBotBase.Enums.eDeleteMode.OnLeavingForm;
|
||||||
|
|
||||||
|
this.Init += ButtonGridForm_Init;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ButtonGridForm_Init(object sender, InitEventArgs e)
|
||||||
|
{
|
||||||
|
m_Buttons = new ButtonGrid();
|
||||||
|
|
||||||
|
m_Buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard;
|
||||||
|
|
||||||
|
m_Buttons.EnablePaging = true;
|
||||||
|
m_Buttons.EnableSearch = true;
|
||||||
|
|
||||||
|
m_Buttons.HeadLayoutButtonRow = new List<ButtonBase>() { new ButtonBase("Back", "back") };
|
||||||
|
|
||||||
|
var countries = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
|
||||||
|
|
||||||
|
ButtonForm bf = new ButtonForm();
|
||||||
|
|
||||||
|
foreach (var c in countries)
|
||||||
|
{
|
||||||
|
bf.AddButtonRow(new ButtonBase(c.EnglishName, c.EnglishName));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Buttons.ButtonsForm = bf;
|
||||||
|
|
||||||
|
m_Buttons.ButtonClicked += Bg_ButtonClicked;
|
||||||
|
|
||||||
|
this.AddControl(m_Buttons);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Bg_ButtonClicked(object sender, ButtonClickedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Button == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (e.Button.Value == "back")
|
||||||
|
{
|
||||||
|
var start = new Menu();
|
||||||
|
await this.NavigateTo(start);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
await this.Device.Send($"Button clicked with Text: {e.Button.Text} and Value {e.Button.Value}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -146,6 +146,16 @@ namespace TelegramBotBaseTest.Tests
|
|||||||
|
|
||||||
await this.NavigateTo(bg);
|
await this.NavigateTo(bg);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "buttongridfilter":
|
||||||
|
|
||||||
|
message.Handled = true;
|
||||||
|
|
||||||
|
var bg2 = new Controls.ButtonGridPagingForm();
|
||||||
|
|
||||||
|
await this.NavigateTo(bg2);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +185,8 @@ namespace TelegramBotBaseTest.Tests
|
|||||||
|
|
||||||
btn.AddButtonRow(new ButtonBase("#12 ButtonGrid", new CallbackData("a", "buttongrid").Serialize()));
|
btn.AddButtonRow(new ButtonBase("#12 ButtonGrid", new CallbackData("a", "buttongrid").Serialize()));
|
||||||
|
|
||||||
|
btn.AddButtonRow(new ButtonBase("#13 ButtonGrid Paging & Filter", new CallbackData("a", "buttongridfilter").Serialize()));
|
||||||
|
|
||||||
await this.Device.Send("Choose your test:", btn);
|
await this.Device.Send("Choose your test:", btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
images/buttongrid_pagingfilter.gif
Normal file
BIN
images/buttongrid_pagingfilter.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
Loading…
x
Reference in New Issue
Block a user