Adding more details on ConfirmDialog

- adding a Tag property for optional use in ArrayPromptDialog and ConfirmDialog
- adding it to the ButtonClickedEventArgs
This commit is contained in:
FlorianDahn 2021-03-29 23:50:42 +02:00
parent 8142b626b2
commit 92f12735c8
3 changed files with 20 additions and 2 deletions

View File

@ -16,6 +16,8 @@ namespace TelegramBotBase.Args
public int Index { get; set; } public int Index { get; set; }
public object Tag { get; set; }
public ButtonClickedEventArgs() public ButtonClickedEventArgs()
{ {

View File

@ -16,8 +16,16 @@ namespace TelegramBotBase.Form
[IgnoreState] [IgnoreState]
public class ArrayPromptDialog : FormBase public class ArrayPromptDialog : FormBase
{ {
/// <summary>
/// The message the users sees.
/// </summary>
public String Message { get; set; } public String Message { get; set; }
/// <summary>
/// An additional optional value.
/// </summary>
public object Tag { get; set; }
public ButtonBase[][] Buttons { get; set; } public ButtonBase[][] Buttons { get; set; }
[Obsolete] [Obsolete]
@ -70,7 +78,7 @@ namespace TelegramBotBase.Form
return; return;
} }
OnButtonClicked(new ButtonClickedEventArgs(button)); OnButtonClicked(new ButtonClickedEventArgs(button) { Tag = this.Tag });
FormBase fb = ButtonForms.ContainsKey(call.Value) ? ButtonForms[call.Value] : null; FormBase fb = ButtonForms.ContainsKey(call.Value) ? ButtonForms[call.Value] : null;

View File

@ -13,8 +13,16 @@ namespace TelegramBotBase.Form
[IgnoreState] [IgnoreState]
public class ConfirmDialog : ModalDialog public class ConfirmDialog : ModalDialog
{ {
/// <summary>
/// The message the users sees.
/// </summary>
public String Message { get; set; } public String Message { get; set; }
/// <summary>
/// An additional optional value.
/// </summary>
public object Tag { get; set; }
/// <summary> /// <summary>
/// Automatically close form on button click /// Automatically close form on button click
/// </summary> /// </summary>
@ -77,7 +85,7 @@ namespace TelegramBotBase.Form
return; return;
} }
OnButtonClicked(new ButtonClickedEventArgs(button)); OnButtonClicked(new ButtonClickedEventArgs(button) { Tag = this.Tag });
if (AutoCloseOnClick) if (AutoCloseOnClick)
await CloseForm(); await CloseForm();