diff --git a/TelegramBotBase/Base/ControlBase.cs b/TelegramBotBase/Base/ControlBase.cs index c33bb3a..6452ba9 100644 --- a/TelegramBotBase/Base/ControlBase.cs +++ b/TelegramBotBase/Base/ControlBase.cs @@ -33,14 +33,14 @@ namespace TelegramBotBase.Base { - + } 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 Cleanup() { - + } } diff --git a/TelegramBotBase/Form/ButtonBase.cs b/TelegramBotBase/Form/ButtonBase.cs index 0bb9496..b7a55e7 100644 --- a/TelegramBotBase/Form/ButtonBase.cs +++ b/TelegramBotBase/Form/ButtonBase.cs @@ -12,7 +12,7 @@ namespace TelegramBotBase.Form /// public class ButtonBase { - public String Text { get; set; } + public virtual String Text { get; set; } public String Value { get; set; } diff --git a/TelegramBotBase/Form/DynamicButton.cs b/TelegramBotBase/Form/DynamicButton.cs new file mode 100644 index 0000000..4935514 --- /dev/null +++ b/TelegramBotBase/Form/DynamicButton.cs @@ -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 GetText; + + public DynamicButton(String Text, String Value, String Url = null) + { + this.Text = Text; + this.Value = Value; + this.Url = Url; + } + + public DynamicButton(Func GetText, String Value, String Url = null) + { + this.GetText = GetText; + this.Value = Value; + this.Url = Url; + } + + + } +}