sledgemapper/Sledgemapper/UI/PlayerWindow.Custom.cs
Michele 3e1acd26f2
All checks were successful
continuous-integration/drone/push Build is passing
invite player fixes
2021-09-23 22:15:15 +01:00

47 lines
No EOL
1.5 KiB
C#

/* Generated by MyraPad at 28/08/2021 22:04:11 */
using Myra.Graphics2D.UI;
using Sentry;
using Sledgemapper.Messages;
using System;
using TinyMessenger;
namespace Sledgemapper.UI
{
public partial class PlayerWindow
{
protected CommunicationManager CommunicationManager { get; }
protected TinyMessengerHub Messenger { get; }
public PlayerWindow(CommunicationManager communicationManager, TinyMessenger.TinyMessengerHub messenger)
{
CommunicationManager = communicationManager;
Messenger = messenger;
BuildUI();
BtnNewCampaign.Click += OnButtonInvitePlayerClicked;
}
private async void OnButtonInvitePlayerClicked(object sender, EventArgs e)
{
var localContent = ((TextButton)sender).GetParentContentInWindow<PlayerWindow>();// localWindow.Content as PlayerWindow;
var isValid = localContent.Content.TxtCampaign.ValidateTextbox();
if (!isValid)
{
return;
}
var successful = false;
try
{
await CommunicationManager.Api.InvitePlayer(State.Instance.CampaignId, localContent.Content.TxtCampaign.Text);
}
catch (Exception ex)
{
Messenger.Publish(new ErrorMessage(this, "Error inviting player"));
SentrySdk.CaptureException(ex);
}
this.GetContainingWindow().Close();
}
}
}