Adding DynamicButton for Button with dynamic Text updates
For use, call the ButtonGrid.Updated() method
This commit is contained in:
parent
ecfacdadbb
commit
cf9e2285f1
@ -33,14 +33,14 @@ namespace TelegramBotBase.Base
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual async Task Action(MessageResult result, String value = null)
|
public virtual async Task Action(MessageResult result, String value = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -50,18 +50,18 @@ namespace TelegramBotBase.Base
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual async Task Hidden(bool FormClose)
|
public virtual async Task Hidden(bool FormClose)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual async Task Cleanup()
|
public virtual async Task Cleanup()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace TelegramBotBase.Form
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ButtonBase
|
public class ButtonBase
|
||||||
{
|
{
|
||||||
public String Text { get; set; }
|
public virtual String Text { get; set; }
|
||||||
|
|
||||||
public String Value { get; set; }
|
public String Value { get; set; }
|
||||||
|
|
||||||
|
|||||||
41
TelegramBotBase/Form/DynamicButton.cs
Normal file
41
TelegramBotBase/Form/DynamicButton.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace TelegramBotBase.Form
|
||||||
|
{
|
||||||
|
public class DynamicButton : ButtonBase
|
||||||
|
{
|
||||||
|
public override string Text
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetText?.Invoke() ?? m_text;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_text = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String m_text = "";
|
||||||
|
|
||||||
|
private Func<String> GetText;
|
||||||
|
|
||||||
|
public DynamicButton(String Text, String Value, String Url = null)
|
||||||
|
{
|
||||||
|
this.Text = Text;
|
||||||
|
this.Value = Value;
|
||||||
|
this.Url = Url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DynamicButton(Func<String> GetText, String Value, String Url = null)
|
||||||
|
{
|
||||||
|
this.GetText = GetText;
|
||||||
|
this.Value = Value;
|
||||||
|
this.Url = Url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user