diff --git a/TelegramBaseTest/Tests/TestForm2.cs b/TelegramBaseTest/Tests/TestForm2.cs index 22a3174..2110a85 100644 --- a/TelegramBaseTest/Tests/TestForm2.cs +++ b/TelegramBaseTest/Tests/TestForm2.cs @@ -52,23 +52,37 @@ namespace TelegramBaseTest.Tests } else if (call.Value == "alert") { - var fto = new TestForm2(); + AlertDialog ad = new AlertDialog("This is a message", "Ok"); + + ad.ButtonClicked += async (s, en) => + { + var fto = new TestForm2(); + await this.NavigateTo(fto); + }; - AlertDialog ad = new AlertDialog("This is a message", "Ok", fto); - await this.NavigateTo(ad); } else if (call.Value == "prompt") { PromptDialog pd = new PromptDialog("Please confirm"); + pd.ButtonClicked += async (s, en) => + { + if(en.Button.Value == "ok") + { + var tf = new TestForm2(); + await pd.NavigateTo(tf); + } + else if(en.Button.Value == "cancel") + { + var tf = new TestForm2(); + await pd.NavigateTo(tf); + } + + }; + pd.AddButton(new ButtonBase("Ok", "ok")); pd.AddButton(new ButtonBase("Cancel", "cancel")); - - var tf = new TestForm2(); - - pd.ButtonForms.Add("ok", tf); - pd.ButtonForms.Add("cancel", tf); await this.NavigateTo(pd); } diff --git a/TelegramBotBase/Form/AlertDialog.cs b/TelegramBotBase/Form/AlertDialog.cs index 5ad3e76..de24d54 100644 --- a/TelegramBotBase/Form/AlertDialog.cs +++ b/TelegramBotBase/Form/AlertDialog.cs @@ -22,15 +22,5 @@ namespace TelegramBotBase.Form } - [Obsolete] - public AlertDialog(String Message, String ButtonText, FormBase FormToOpen = null) : base(Message) - { - this.Buttons.Add(new ButtonBase(ButtonText, "ok")); - this.ButtonText = ButtonText; - - if (FormToOpen != null) - this.ButtonForms.Add("ok", FormToOpen); - } - } } diff --git a/TelegramBotBase/Form/PromptDialog.cs b/TelegramBotBase/Form/PromptDialog.cs index a5ee197..b5b2bd9 100644 --- a/TelegramBotBase/Form/PromptDialog.cs +++ b/TelegramBotBase/Form/PromptDialog.cs @@ -15,9 +15,6 @@ namespace TelegramBotBase.Form public List Buttons { get; set; } - [Obsolete] - public Dictionary ButtonForms { get; set; } = new Dictionary(); - private EventHandlerList __Events { get; set; } = new EventHandlerList(); private static object __evButtonClicked { get; } = new object(); @@ -68,13 +65,6 @@ namespace TelegramBotBase.Form } OnButtonClicked(new ButtonClickedEventArgs(button)); - - FormBase fb = ButtonForms.ContainsKey(call.Value) ? ButtonForms[call.Value] : null; - - if (fb != null) - { - await this.NavigateTo(fb); - } }