Update README.md

This commit is contained in:
Florian Dahn 2019-03-20 17:48:18 +07:00 committed by GitHub
parent 16baef0c45
commit a97305fa35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

124
README.md
View File

@ -157,16 +157,16 @@ Below we have 4 options.
```
BotBase<Start> bb = new BotBase<Start>("{YOUR API KEY}");
BotBase<Start> bb = new BotBase<Start>("{YOUR API KEY}");
bb.SystemCalls.Add("/start");
bb.SystemCalls.Add("/form1");
bb.SystemCalls.Add("/form2");
bb.SystemCalls.Add("/start");
bb.SystemCalls.Add("/form1");
bb.SystemCalls.Add("/form2");
bb.SystemCalls.Add("/params");
bb.SystemCalls.Add("/params");
bb.SystemCall += async (s, en) =>
{
bb.SystemCall += async (s, en) =>
{
switch (en.Command)
{
case "/form1":
@ -194,9 +194,9 @@ Below we have 4 options.
break;
}
};
};
bb.Start();
bb.Start();
```
@ -247,8 +247,6 @@ public class SimpleForm : FormBase
break;
}
}
}
```
@ -351,21 +349,21 @@ Maybe, if i got more ideas, i will add other "controls" in the future.
```
public class ProgressTest : AutoCleanForm
{
public class ProgressTest : AutoCleanForm
{
public ProgressTest()
{
public ProgressTest()
{
this.DeleteMode = eDeleteMode.OnLeavingForm;
}
}
public override async Task Opened()
{
public override async Task Opened()
{
await this.Device.Send("Welcome to ProgressTest");
}
}
public override async Task Action(MessageResult message)
{
public override async Task Action(MessageResult message)
{
var call = message.GetData<CallbackData>();
await message.ConfirmAction();
@ -444,11 +442,11 @@ Maybe, if i got more ideas, i will add other "controls" in the future.
}
}
}
public override async Task Render(MessageResult message)
{
public override async Task Render(MessageResult message)
{
ButtonForm btn = new ButtonForm();
btn.AddButtonRow(new ButtonBase("Standard", new CallbackData("a", "standard").Serialize()), new ButtonBase("Squares", new CallbackData("a", "squares").Serialize()));
@ -459,21 +457,21 @@ Maybe, if i got more ideas, i will add other "controls" in the future.
btn.AddButtonRow(new ButtonBase("Back to start", new CallbackData("a", "start").Serialize()));
await this.Device.Send("Choose your progress bar:", btn);
}
}
public override async Task Closed()
{
public override async Task Closed()
{
foreach (var b in this.Controls)
{
await b.Cleanup();
}
await this.Device.Send("Ciao from ProgressTest");
}
}
}
}
```
@ -485,16 +483,16 @@ To give you an example about the possiblities, i added into the Test project an
```
public class PerForm : AutoCleanForm
{
public String EMail { get; set; }
public class PerForm : AutoCleanForm
{
public String EMail { get; set; }
public String Firstname { get; set; }
public String Firstname { get; set; }
public String Lastname { get; set; }
public String Lastname { get; set; }
public async override Task Load(MessageResult message)
{
public async override Task Load(MessageResult message)
{
if (message.MessageText.Trim() == "")
return;
@ -516,10 +514,10 @@ To give you an example about the possiblities, i added into the Test project an
return;
}
}
}
public async override Task Action(MessageResult message)
{
public async override Task Action(MessageResult message)
{
var call = message.GetData<CallbackData>();
await message.ConfirmAction();
@ -540,10 +538,10 @@ To give you an example about the possiblities, i added into the Test project an
}
}
}
public async override Task Render(MessageResult message)
{
public async override Task Render(MessageResult message)
{
if (this.Firstname == null)
{
await this.Device.Send("Please sent your firstname:");
@ -573,10 +571,10 @@ To give you an example about the possiblities, i added into the Test project an
bf.AddButtonRow(new ButtonBase("Back", new CallbackData("a", "back").Serialize()));
await this.Device.Send("Your details:\r\n" + s, bf);
}
}
}
}
```
@ -593,25 +591,25 @@ Beginn there and navigate your way through these Steps in the subfolder.
There are some default types of forms to make the interaction with users easier.
For now we have the following:
- [AlertDialog](#alert-dialog)
- [AlertDialog](#alert-dialog)
Just a simple dialog with one ok Button.
- [AutoCleanForm](#autocleanform)
- [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)
- [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();
var fto = new TestForm2();
AlertDialog ad = new AlertDialog("This is a message", "Ok", fto);
AlertDialog ad = new AlertDialog("This is a message", "Ok", fto);
await this.NavigateTo(ad);
await this.NavigateTo(ad);
```
@ -626,14 +624,14 @@ For now we have the following:
```
PromptDialog pd = new PromptDialog("Please confirm", new ButtonBase("Ok", "ok"), new ButtonBase("Cancel", "cancel"));
PromptDialog pd = new PromptDialog("Please confirm", new ButtonBase("Ok", "ok"), new ButtonBase("Cancel", "cancel"));
var tf = new TestForm2();
var tf = new TestForm2();
pd.ButtonForms.Add("ok", tf);
pd.ButtonForms.Add("cancel", tf);
pd.ButtonForms.Add("ok", tf);
pd.ButtonForms.Add("cancel", tf);
await this.NavigateTo(pd);
await this.NavigateTo(pd);
```
@ -642,21 +640,21 @@ For now we have the following:
```
PromptDialog pd = new PromptDialog("Please confirm", new ButtonBase("Ok", "ok"), new ButtonBase("Cancel", "cancel"));
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);
//You could mix here for sure.
pd.ButtonForms.Add("ok", null);
pd.ButtonForms.Add("cancel", null);
pd.ButtonClicked += async (s, en) =>
{
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);
await this.NavigateTo(pd);
```