- 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:
FlorianDahn
2019-02-22 16:35:35 +01:00
parent 7439b009be
commit aa53dc9386
22 changed files with 203 additions and 214 deletions
-91
View File
@@ -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; }
+3
View File
@@ -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; }
+115
View File
@@ -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;
}
}
}
+3
View File
@@ -7,6 +7,9 @@ using System.Threading.Tasks;
namespace TelegramBotBase.Base
{
/// <summary>
/// Base class for message handling
/// </summary>
public class MessageClient
{
+6 -3
View File
@@ -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>
+2 -2
View File
@@ -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; }