- adding a lot of english translations
- switching german to english - some bug fixes in device sessions and improvements - adding xml documentation
This commit is contained in:
@@ -1,91 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Base
|
||||
{
|
||||
//public class ActionResult : ResultBase
|
||||
//{
|
||||
// public Telegram.Bot.Args.CallbackQueryEventArgs RawCallbackData { get; set; }
|
||||
|
||||
// public override long DeviceId
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return this.RawCallbackData?.CallbackQuery.Message?.Chat.Id ?? 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
// public String Command
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return this.RawCallbackData.CallbackQuery.Message.Text ?? "";
|
||||
// }
|
||||
// }
|
||||
|
||||
// public String RawData
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return this.RawCallbackData.CallbackQuery.Data;
|
||||
// }
|
||||
// }
|
||||
|
||||
// public T GetData<T>()
|
||||
// where T : class
|
||||
// {
|
||||
// T cd = null;
|
||||
// try
|
||||
// {
|
||||
// cd = Newtonsoft.Json.JsonConvert.DeserializeObject<T>(this.RawData);
|
||||
|
||||
// return cd;
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Bestätigt den Erhalt der Aktion.
|
||||
// /// </summary>
|
||||
// /// <param name="message"></param>
|
||||
// /// <returns></returns>
|
||||
// public async Task ConfirmAction(String message = "")
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// await this.Client.TelegramClient.AnswerCallbackQueryAsync(this.RawCallbackData.CallbackQuery.Id, message);
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// public override async Task DeleteMessage()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// await this.Client.TelegramClient.DeleteMessageAsync(this.DeviceId, this.RawCallbackData.CallbackQuery.Message.MessageId);
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// public ActionResult(Telegram.Bot.Args.CallbackQueryEventArgs callback)
|
||||
// {
|
||||
// this.RawCallbackData = callback;
|
||||
// this.Message = callback.CallbackQuery.Message;
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
@@ -7,6 +7,9 @@ using TelegramBotBase.Form;
|
||||
|
||||
namespace TelegramBotBase.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// Button get clicked event
|
||||
/// </summary>
|
||||
public class ButtonClickedEventArgs : EventArgs
|
||||
{
|
||||
public ButtonBase Button { get; set; }
|
||||
|
||||
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for controls
|
||||
/// </summary>
|
||||
public class ControlBase
|
||||
{
|
||||
public Sessions.DeviceSession Device { get; set; }
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TelegramBotBase.Base;
|
||||
using TelegramBotBase.Sessions;
|
||||
|
||||
namespace TelegramBotBase.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for forms
|
||||
/// </summary>
|
||||
public class FormBase : IDisposable
|
||||
{
|
||||
public DeviceSession Device { get; set; }
|
||||
|
||||
public MessageClient Client { get; set; }
|
||||
|
||||
public bool CustomEventManagement { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// contains if the form has been switched (navigated)
|
||||
/// </summary>
|
||||
public bool FormSwitched { get; set; } = false;
|
||||
|
||||
public List<ControlBase> Controls { get; set; }
|
||||
|
||||
public FormBase()
|
||||
{
|
||||
this.Controls = new List<Base.ControlBase>();
|
||||
}
|
||||
|
||||
public FormBase(MessageClient Client): this()
|
||||
{
|
||||
this.Client = Client;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will get called at the initialization (once per context)
|
||||
/// </summary>
|
||||
public virtual async Task Init(params object[] args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual async Task Opened()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual async Task Closed()
|
||||
{
|
||||
foreach (var b in this.Controls)
|
||||
{
|
||||
await b.Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task PreLoad(MessageResult message)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual async Task Load(MessageResult message)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual async Task Action(MessageResult message)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public virtual async Task Render(MessageResult message)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Navigates to a new form
|
||||
/// </summary>
|
||||
/// <param name="newForm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task NavigateTo(FormBase newForm, params object[] args)
|
||||
{
|
||||
DeviceSession ds = this.Device;
|
||||
if (ds == null)
|
||||
return;
|
||||
|
||||
this.FormSwitched = true;
|
||||
|
||||
ds.ActiveForm = newForm;
|
||||
newForm.Client = this.Client;
|
||||
newForm.Device = ds;
|
||||
|
||||
await newForm.Init(args);
|
||||
|
||||
await this.Closed();
|
||||
|
||||
await newForm.Opened();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleanup
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
this.Client = null;
|
||||
this.Device = null;
|
||||
this.FormSwitched = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TelegramBotBase.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for message handling
|
||||
/// </summary>
|
||||
public class MessageClient
|
||||
{
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ namespace TelegramBotBase.Base
|
||||
|
||||
public Telegram.Bot.Args.CallbackQueryEventArgs RawCallbackData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Device/ChatId
|
||||
/// </summary>
|
||||
public override long DeviceId
|
||||
{
|
||||
get
|
||||
@@ -21,7 +24,7 @@ namespace TelegramBotBase.Base
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Die Id der Nachricht
|
||||
/// The message id
|
||||
/// </summary>
|
||||
public new int MessageId
|
||||
{
|
||||
@@ -48,7 +51,7 @@ namespace TelegramBotBase.Base
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ist diese eine Aktion? (z.B.: Button Klick)
|
||||
/// Is this an action ? (i.e. button click)
|
||||
/// </summary>
|
||||
public bool IsAction
|
||||
{
|
||||
@@ -87,7 +90,7 @@ namespace TelegramBotBase.Base
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bestätigt den Erhalt der Aktion.
|
||||
/// Confirm incomming action (i.e. Button click)
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace TelegramBotBase.Base
|
||||
public Telegram.Bot.Types.Message Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Löscht die aktuelle Nachricht, oder die übergebene
|
||||
/// Deletes the current message
|
||||
/// </summary>
|
||||
/// <param name="messageId"></param>
|
||||
/// <returns></returns>
|
||||
@@ -33,7 +33,7 @@ namespace TelegramBotBase.Base
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Löscht die aktuelle Nachricht, oder die übergebene
|
||||
///Deletes the current message or the given one.
|
||||
/// </summary>
|
||||
/// <param name="messageId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
@@ -7,6 +7,9 @@ using TelegramBotBase.Sessions;
|
||||
|
||||
namespace TelegramBotBase.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for given system call results
|
||||
/// </summary>
|
||||
public class SystemCallEventArgs : EventArgs
|
||||
{
|
||||
public String Command { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user