47 lines
No EOL
1.5 KiB
C#
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();
|
|
}
|
|
}
|
|
} |