- added IsDisposed to form
- removed FormSwitched from FormBase and added to DeviceSession (more logical message loop) - added PreviousForm to DeviceSession, contains last opened form (at initial form is null) -BotBase message loop update - now navigation is possible from every form, not just the latest ones as before
This commit is contained in:
parent
022eee4b57
commit
fe1aafc9a5
@ -20,9 +20,9 @@ namespace TelegramBotBase.Form
|
||||
public bool CustomEventManagement { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// contains if the form has been switched (navigated)
|
||||
/// has this formular already been disposed ?
|
||||
/// </summary>
|
||||
public bool FormSwitched { get; set; } = false;
|
||||
public bool IsDisposed { get; set; } = false;
|
||||
|
||||
public List<ControlBase> Controls { get; set; }
|
||||
|
||||
@ -117,12 +117,14 @@ namespace TelegramBotBase.Form
|
||||
if (ds == null)
|
||||
return;
|
||||
|
||||
this.FormSwitched = true;
|
||||
ds.FormSwitched = true;
|
||||
|
||||
ds.ActiveForm = newForm;
|
||||
newForm.Client = this.Client;
|
||||
newForm.Device = ds;
|
||||
|
||||
ds.PreviousForm = this;
|
||||
|
||||
await newForm.Init(args);
|
||||
|
||||
await this.Closed();
|
||||
@ -137,7 +139,7 @@ namespace TelegramBotBase.Form
|
||||
{
|
||||
this.Client = null;
|
||||
this.Device = null;
|
||||
this.FormSwitched = false;
|
||||
this.IsDisposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,6 +258,9 @@ namespace TelegramBotBase
|
||||
do
|
||||
{
|
||||
i++;
|
||||
|
||||
//Reset navigation
|
||||
ds.FormSwitched = false;
|
||||
|
||||
activeForm = ds.ActiveForm;
|
||||
|
||||
@ -279,10 +282,10 @@ namespace TelegramBotBase
|
||||
}
|
||||
|
||||
//Render Event
|
||||
if (!activeForm.FormSwitched)
|
||||
if (!ds.FormSwitched)
|
||||
await activeForm.Render(e);
|
||||
|
||||
} while (activeForm.FormSwitched && i < NavigationMaximum);
|
||||
} while (ds.FormSwitched && i < NavigationMaximum);
|
||||
|
||||
}
|
||||
|
||||
@ -329,6 +332,9 @@ namespace TelegramBotBase
|
||||
{
|
||||
i++;
|
||||
|
||||
//Reset navigation
|
||||
ds.FormSwitched = false;
|
||||
|
||||
activeForm = ds.ActiveForm;
|
||||
|
||||
//If the form manages the events by itselfs, skip here
|
||||
@ -342,7 +348,7 @@ namespace TelegramBotBase
|
||||
await activeForm.Load(e);
|
||||
|
||||
//Action Event
|
||||
if (!activeForm.FormSwitched)
|
||||
if (!ds.FormSwitched)
|
||||
{
|
||||
await activeForm.Action(e);
|
||||
|
||||
@ -353,7 +359,7 @@ namespace TelegramBotBase
|
||||
|
||||
if (uhc.Handled)
|
||||
{
|
||||
if (activeForm.FormSwitched)
|
||||
if (ds.FormSwitched)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -367,10 +373,10 @@ namespace TelegramBotBase
|
||||
}
|
||||
|
||||
//Render Event
|
||||
if (!activeForm.FormSwitched)
|
||||
if (!ds.FormSwitched)
|
||||
await activeForm.Render(e);
|
||||
|
||||
} while (activeForm.FormSwitched && i < NavigationMaximum);
|
||||
} while (ds.FormSwitched && i < NavigationMaximum);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -37,6 +37,16 @@ namespace TelegramBotBase.Sessions
|
||||
/// </summary>
|
||||
public FormBase ActiveForm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the previous shown form
|
||||
/// </summary>
|
||||
public FormBase PreviousForm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// contains if the form has been switched (navigated)
|
||||
/// </summary>
|
||||
public bool FormSwitched { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the ID of the last received message.
|
||||
/// </summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user