cleanup, refactoring, usual stuff
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b671c661a7
commit
f15f1c8857
26 changed files with 183 additions and 209 deletions
|
@ -1,5 +1,6 @@
|
|||
using Myra.Graphics2D.Brushes;
|
||||
using Myra.Graphics2D.UI;
|
||||
using Sledgemapper.Messages;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TinyMessenger;
|
||||
|
@ -11,17 +12,15 @@ namespace Sledgemapper.UI
|
|||
private readonly CommunicationManager CommunicationManager;
|
||||
private readonly Window Window;
|
||||
private readonly TinyMessengerHub Messenger;
|
||||
private readonly Desktop Desktop;
|
||||
private Settings _settings;
|
||||
private bool campaignSelected;
|
||||
|
||||
public CampaignList(CommunicationManager communicationManager, Window window, TinyMessengerHub messenger, Settings settings, Desktop desktop)
|
||||
public CampaignList(CommunicationManager communicationManager, Window window, TinyMessengerHub messenger)
|
||||
{
|
||||
BuildUI();
|
||||
CommunicationManager = communicationManager;
|
||||
Window = window;
|
||||
Messenger = messenger;
|
||||
Desktop = desktop;
|
||||
_settings = settings;
|
||||
|
||||
BtnNewCampaign.Click += (s, e) =>
|
||||
{
|
||||
window.Close();
|
||||
|
@ -33,6 +32,7 @@ namespace Sledgemapper.UI
|
|||
if (campaignSelected)
|
||||
{
|
||||
campaignSelected = false;
|
||||
Messenger.Publish(new CampaignSelectedMessage(this));
|
||||
window.Close();
|
||||
}
|
||||
};
|
||||
|
@ -57,96 +57,31 @@ namespace Sledgemapper.UI
|
|||
};
|
||||
|
||||
var content = new CampaignWindow(CommunicationManager, window, Messenger);
|
||||
//content.BtnNewCampaign.Text = "N";
|
||||
//content.BtnNewCampaign.Click += OnButtonNewCampaignClicked;
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(Desktop);
|
||||
//content.TxtCampaign.SetKeyboardFocus();
|
||||
window.ShowModal(Window.Desktop);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private bool campaignSelected;
|
||||
|
||||
|
||||
private void OnCampaignSelected(object sender, EventArgs e)
|
||||
{
|
||||
var item = sender as UI.ListItem;
|
||||
var localContent = item.GetParentContentInWindow<Widget>();
|
||||
var item = sender as ListItem;
|
||||
|
||||
State.Instance.CampaignName = item.ItemName.Text;
|
||||
var list = item.Parent as Myra.Graphics2D.UI.Grid;
|
||||
var list = item.Parent as Grid;
|
||||
for (var i = 0; i < list.ChildrenCount; i++)
|
||||
{
|
||||
var currentItem = list.GetChild(i) as HorizontalStackPanel;// UI.ListItem;
|
||||
currentItem.Background = new SolidBrush("#D9D9D9FF");
|
||||
}
|
||||
item.Background = new SolidBrush(_settings.OverlayTintColor);
|
||||
item.Background = new SolidBrush(Settings.Instance.OverlayTintColor);
|
||||
campaignSelected = true;
|
||||
}
|
||||
|
||||
//private async void OnButtonNewCampaignClicked(object sender, EventArgs e)
|
||||
//{
|
||||
// var localContent = ((TextButton)sender).GetParentContentInWindow<CampaignWindow>();// localWindow.Content as PlayerWindow;
|
||||
|
||||
// var isValid = localContent.Content.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(localContent.Content.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)
|
||||
// {
|
||||
// //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();
|
||||
// //}
|
||||
|
||||
// localContent.Window.Close();
|
||||
|
||||
//}
|
||||
|
||||
public async Task LoadCampaigns()
|
||||
{
|
||||
var campaigns = await CommunicationManager.Api.GetCampaigns();
|
||||
foreach (var campaign in campaigns)
|
||||
{
|
||||
var item = new UI.ListItem();
|
||||
var item = new ListItem();
|
||||
item.ItemName.Text = campaign.Name;
|
||||
|
||||
item.TouchUp += OnCampaignSelected;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue