- Cleanup of unecessary init calls
- added form1/form2 option to start menu in test project - added example for different forms with and without event handlers - added form examples to Readme.md
This commit is contained in:
parent
19f3c9c195
commit
211bc55aff
82
README.md
82
README.md
@ -26,6 +26,12 @@ Test the Testproject: [@TGBaseBot](https://t.me/TGBaseBot)
|
||||
|
||||
* [Example #4 - Registration Formular](#registration-example-example-4---registration-form-test)
|
||||
|
||||
- [Special Forms](#forms)
|
||||
|
||||
* [AlertDialog](#alert-dialog)
|
||||
* [AutoCleanForm](#autocleanform)
|
||||
* [PromptDialog](#prompt-dialog)
|
||||
|
||||
|
||||
---
|
||||
|
||||
@ -578,6 +584,82 @@ There is also a second example, where every of these 3 inputs gets requested by
|
||||
Cause its to much Text, i didnt have added it here. You will find it under [TelegramBaseTest/Tests/Register/PerStep.cs](TelegramBaseTest/Tests/Register/PerStep.cs)
|
||||
Beginn there and navigate your way through these Steps in the subfolder.
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Forms
|
||||
|
||||
There are some default types of forms to make the interaction with users easier.
|
||||
For now we have the following:
|
||||
|
||||
* [AlertDialog](#alert-dialog)
|
||||
Just a simple dialog with one ok Button.
|
||||
|
||||
* [AutoCleanForm](#autocleanform)
|
||||
A form which needs to be derived from. It will be delete all in the context sent messages to the user after every new message or on leaving the formular and navigates somewhere else.
|
||||
Makes sense to create a "feeling" of a clean environment for the user. For instance if you have a multilevel menu. This will remove the previously shown menu, and renders the new sub/top level.
|
||||
|
||||
* [PromptDialog](#prompt-dialog)
|
||||
A simple dialog which is able to show multiple buttons and a Text message. The user could select one option and will get redirected to a different form, depending on the click.
|
||||
|
||||
### Alert Dialog
|
||||
|
||||
```
|
||||
|
||||
var fto = new TestForm2();
|
||||
|
||||
AlertDialog ad = new AlertDialog("This is a message", "Ok", fto);
|
||||
|
||||
await this.NavigateTo(ad);
|
||||
|
||||
```
|
||||
|
||||
|
||||
### AutoCleanForm
|
||||
|
||||
|
||||
|
||||
### Prompt Dialog
|
||||
|
||||
#### Without Eventhandler (pre-init of form necessary)
|
||||
|
||||
```
|
||||
|
||||
PromptDialog pd = new PromptDialog("Please confirm", new ButtonBase("Ok", "ok"), new ButtonBase("Cancel", "cancel"));
|
||||
|
||||
var tf = new TestForm2();
|
||||
|
||||
pd.ButtonForms.Add("ok", tf);
|
||||
pd.ButtonForms.Add("cancel", tf);
|
||||
|
||||
await this.NavigateTo(pd);
|
||||
|
||||
```
|
||||
|
||||
|
||||
#### With Eventhandler (no pre-init of form necessary)
|
||||
|
||||
```
|
||||
|
||||
PromptDialog pd = new PromptDialog("Please confirm", new ButtonBase("Ok", "ok"), new ButtonBase("Cancel", "cancel"));
|
||||
|
||||
//You could mix here for sure.
|
||||
pd.ButtonForms.Add("ok", null);
|
||||
pd.ButtonForms.Add("cancel", null);
|
||||
|
||||
pd.ButtonClicked += async (s, en) =>
|
||||
{
|
||||
var tf = new TestForm2();
|
||||
|
||||
//Remember only to navigate from the current running form. (here it is the prompt dialog, cause we have left the above already)
|
||||
await pd.NavigateTo(tf);
|
||||
};
|
||||
|
||||
await this.NavigateTo(pd);
|
||||
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
I will add more notes to it soon, so stay tuned.
|
||||
|
||||
@ -59,8 +59,6 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
var st = new Start();
|
||||
|
||||
await st.Init();
|
||||
|
||||
await this.NavigateTo(st);
|
||||
|
||||
break;
|
||||
|
||||
@ -75,8 +75,6 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
var sf = new Start();
|
||||
|
||||
await sf.Init();
|
||||
|
||||
await this.NavigateTo(sf);
|
||||
|
||||
return;
|
||||
|
||||
@ -50,8 +50,6 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
var st = new Start();
|
||||
|
||||
await st.Init();
|
||||
|
||||
await this.NavigateTo(st);
|
||||
|
||||
break;
|
||||
|
||||
@ -53,6 +53,22 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
await this.NavigateTo(reg);
|
||||
|
||||
break;
|
||||
|
||||
case "form1":
|
||||
|
||||
var form1 = new TestForm();
|
||||
|
||||
await this.NavigateTo(form1);
|
||||
|
||||
break;
|
||||
|
||||
case "form2":
|
||||
|
||||
var form2 = new TestForm2();
|
||||
|
||||
await this.NavigateTo(form2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -68,6 +84,10 @@ namespace TelegramBaseTest.Tests
|
||||
btn.AddButtonRow(new ButtonBase("#3 Progress Bar", new CallbackData("a", "progress").Serialize()));
|
||||
btn.AddButtonRow(new ButtonBase("#4 Registration Example", new CallbackData("a", "registration").Serialize()));
|
||||
|
||||
btn.AddButtonRow(new ButtonBase("#5 Form1 Command", new CallbackData("a", "form1").Serialize()));
|
||||
|
||||
btn.AddButtonRow(new ButtonBase("#6 Form2 Command", new CallbackData("a", "form2").Serialize()));
|
||||
|
||||
await this.Device.Send("Choose your test:", btn);
|
||||
}
|
||||
|
||||
|
||||
@ -51,8 +51,6 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
var tf = new TestForm2();
|
||||
|
||||
await tf.Init();
|
||||
|
||||
await this.NavigateTo(tf);
|
||||
|
||||
break;
|
||||
|
||||
@ -48,18 +48,14 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
var tf = new TestForm();
|
||||
|
||||
await tf.Init();
|
||||
|
||||
await this.NavigateTo(tf);
|
||||
}
|
||||
else if (call.Value == "alert")
|
||||
{
|
||||
var fto = new TestForm2();
|
||||
await fto.Init();
|
||||
|
||||
AlertDialog ad = new AlertDialog("This is a message", "Ok", fto);
|
||||
|
||||
|
||||
|
||||
await this.NavigateTo(ad);
|
||||
}
|
||||
else if (call.Value == "prompt")
|
||||
@ -68,10 +64,24 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
var tf = new TestForm2();
|
||||
|
||||
await tf.Init();
|
||||
|
||||
pd.ButtonForms.Add("ok", tf);
|
||||
pd.ButtonForms.Add("cancel", tf);
|
||||
|
||||
await this.NavigateTo(pd);
|
||||
}
|
||||
else if (call.Value == "promptevt")
|
||||
{
|
||||
PromptDialog pd = new PromptDialog("Please confirm", new ButtonBase("Ok", "ok"), new ButtonBase("Cancel", "cancel"));
|
||||
|
||||
pd.ButtonForms.Add("ok", null);
|
||||
pd.ButtonForms.Add("cancel", null);
|
||||
|
||||
pd.ButtonClicked += async (s, en) =>
|
||||
{
|
||||
var tf = new TestForm2();
|
||||
|
||||
await pd.NavigateTo(tf);
|
||||
};
|
||||
|
||||
await this.NavigateTo(pd);
|
||||
}
|
||||
@ -98,7 +108,11 @@ namespace TelegramBaseTest.Tests
|
||||
|
||||
//btn.AddButtonRow(new ButtonBase("Zum Testformular 1", CallbackData.Create("navigate", "testform1")), new ButtonBase("Zum Testformular 1", CallbackData.Create("navigate", "testform1")));
|
||||
|
||||
btn.AddButtonRow(new ButtonBase("Information Prompt", CallbackData.Create("navigate", "alert")), new ButtonBase("Confirmation Prompt", CallbackData.Create("navigate", "prompt")));
|
||||
btn.AddButtonRow(new ButtonBase("Information Prompt", CallbackData.Create("navigate", "alert")));
|
||||
|
||||
btn.AddButtonRow(new ButtonBase("Confirmation Prompt without event", CallbackData.Create("navigate", "prompt")));
|
||||
|
||||
btn.AddButtonRow(new ButtonBase("Confirmation Prompt with event", CallbackData.Create("navigate", "promptevt")));
|
||||
|
||||
|
||||
await this.Device.SendPhoto(bmp, "Test", btn);
|
||||
|
||||
@ -62,7 +62,7 @@ namespace TelegramBotBase.Base
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is this a system call ? Starts with a slash and command
|
||||
/// Is this a system call ? Starts with a slash '/' and a command
|
||||
/// </summary>
|
||||
public bool IsSystemCall
|
||||
{
|
||||
|
||||
@ -50,7 +50,6 @@ namespace TelegramBotBase.Form
|
||||
|
||||
await message.DeleteMessage();
|
||||
|
||||
|
||||
ButtonBase button = this.Buttons.FirstOrDefault(a => a.Value == call.Value);
|
||||
|
||||
if (button == null)
|
||||
@ -73,7 +72,6 @@ namespace TelegramBotBase.Form
|
||||
{
|
||||
ButtonForm btn = new ButtonForm();
|
||||
|
||||
|
||||
var buttons = this.Buttons.Select(a => new ButtonBase(a.Text, CallbackData.Create("action", a.Value))).ToList();
|
||||
btn.AddButtonRow(buttons);
|
||||
|
||||
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.3.1.2")]
|
||||
[assembly: AssemblyFileVersion("1.3.1.2")]
|
||||
[assembly: AssemblyVersion("1.3.1.3")]
|
||||
[assembly: AssemblyFileVersion("1.3.1.3")]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user