81 lines
No EOL
3.2 KiB
C#
81 lines
No EOL
3.2 KiB
C#
using Myra.Graphics2D.UI;
|
|
using Sentry;
|
|
using System;
|
|
using TinyMessenger;
|
|
|
|
namespace Sledgemapper.UI
|
|
{
|
|
public partial class CampaignWindow
|
|
{
|
|
private readonly CommunicationManager CommunicationManager;
|
|
private readonly Window Window;
|
|
private readonly TinyMessengerHub Messenger;
|
|
|
|
public CampaignWindow(CommunicationManager communicationManager, Window window, TinyMessengerHub messenger)
|
|
{
|
|
BuildUI();
|
|
CommunicationManager = communicationManager;
|
|
Window = window;
|
|
Messenger = messenger;
|
|
BtnNewCampaign.Click += OnButtonNewCampaignClicked;
|
|
|
|
}
|
|
|
|
private async void OnButtonNewCampaignClicked(object sender, EventArgs e)
|
|
{
|
|
//var localContent = ((TextButton)sender).GetParentContentInWindow<CampaignWindow>();// localWindow.Content as PlayerWindow;
|
|
|
|
var isValid = TxtCampaign.ValidateTextbox();
|
|
if (!isValid)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//if (CommunicationManager.Connection.State != HubConnectionState.Connected)
|
|
//{
|
|
// lblConnectionStatus.Text = "Connecting";
|
|
// await CommunicationManager.Connection.StartAsync();
|
|
// UpdateConnectionState(CommunicationManager.Connection);
|
|
//}
|
|
|
|
var successful = false;
|
|
try
|
|
{
|
|
await CommunicationManager.Api.NewCampaign(TxtCampaign.Text);
|
|
|
|
//if (result)
|
|
//{
|
|
// CommunicationManager.SessionData.SessionName = localContent.TxtSession.Text;
|
|
// CommunicationManager.SessionData.MapEntityAdded -= OnMapEntityAdded;
|
|
// CommunicationManager.SessionData.MapEntityDeleted -= OnMapEntityDeleted;
|
|
// CommunicationManager.SessionData.MapEntityAdded += OnMapEntityAdded;
|
|
// CommunicationManager.SessionData.MapEntityDeleted += OnMapEntityDeleted;
|
|
//}
|
|
//successful = result;
|
|
//var result2 = await CommunicationManager.Connection?.InvokeAsync<Session>("JoinSession", localContent.TxtSession.Text);
|
|
//CommunicationManager.SessionData.SessionId = result2.SessionId;
|
|
//CommunicationManager.SessionData.SessionName = localContent.TxtSession.Text;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SentrySdk.CaptureException(ex);
|
|
//ExceptionlessClient.Default.SubmitException(ex);
|
|
}
|
|
|
|
//if (successful)
|
|
//{
|
|
// //CommunicationManager.SessionData.SessionName = localContent.TxtSession.Text;
|
|
// //CommunicationManager.SessionData.Map = CommunicationManager.SessionData.Map;
|
|
// //CommunicationManager.SessionData.Overlays = CommunicationManager.SessionData.Overlays;
|
|
// //CommunicationManager.SessionData.Walls = CommunicationManager.SessionData.Walls;
|
|
// //lblSessionName.Text = CommunicationManager.SessionData.SessionName;
|
|
// //MenuConnectSync.Enabled = true;
|
|
// //MenuConnectUpload.Enabled = true;
|
|
// localWindow.Close();
|
|
//}
|
|
|
|
Window.Close();
|
|
|
|
}
|
|
}
|
|
} |