ui tweaks
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Michele Scandura 2021-09-03 17:16:43 +01:00
parent a8991b474f
commit 4149d744e8
7 changed files with 224 additions and 53 deletions

View file

@ -353,22 +353,13 @@ namespace Sledgemapper
Title = "Maps"
};
var content = new CampaignList();
var content = new MapList();
var campaigns = await _communicationManager.Api.GetMaps(_state.CampaignName);
foreach (var campaign in campaigns)
{
var item = new CampaignListItem();
item.TxtCampaignName.Text = campaign.SessionName;
item.Background = new NinePatchRegion(
Content.Load<Texture2D>("listBackground"), new Rectangle(0, 0, 418, 25),
new Myra.Graphics2D.Thickness
{
Left = 11,
Right = 11,
Top = 11,
Bottom = 11
});
item.TouchUp += OnCampaignSelected;
var item = new UI.ListItem();
item.ItemName.Text = campaign.SessionName;
item.TouchUp += OnMapSelected;
content.StackCampaignsList.AddChild(item);
}
//content.BtnNewCampaign.Text = "N";
@ -403,17 +394,9 @@ namespace Sledgemapper
var players = await _communicationManager.Api.GetPlayers(_state.CampaignName);
foreach (var player in players)
{
var item = new PlayerListItem();
item.TxtPlayerName.Text = player.UserName;
item.Background = new NinePatchRegion(
Content.Load<Texture2D>("listBackground"), new Rectangle(0, 0, 418, 25),
new Myra.Graphics2D.Thickness
{
Left = 11,
Right = 11,
Top = 11,
Bottom = 11
});
var item = new UI.ListItem();
item.ItemName.Text = player.UserName;
content.StackCampaignsList.AddChild(item);
}
@ -533,17 +516,9 @@ namespace Sledgemapper
var campaigns = await _communicationManager.Api.GetCampaigns();
foreach (var campaign in campaigns)
{
var item = new CampaignListItem();
item.TxtCampaignName.Text = campaign.Name;
//item.Background = new NinePatchRegion(
// Content.Load<Texture2D>("listBackground"), new Rectangle(0, 0, 418, 25),
// new Myra.Graphics2D.Thickness
// {
// Left = 11,
// Right = 11,
// Top = 11,
// Bottom = 11
// });
var item = new UI.ListItem();
item.ItemName.Text = campaign.Name;
item.TouchUp += OnCampaignSelected;
content.StackCampaignsList.AddChild(item);
}
@ -565,8 +540,30 @@ namespace Sledgemapper
private void OnCampaignSelected(object sender, EventArgs e)
{
var item = sender as CampaignListItem;
_state.CampaignName = item.TxtCampaignName.Text;
var item = sender as UI.ListItem;
var localContent = GetParentContentInWindow<Widget>(item);
_state.CampaignName = item.ItemName.Text;
var list = item.Parent as Myra.Graphics2D.UI.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);
}
private void OnMapSelected(object sender, EventArgs e)
{
var item = sender as UI.ListItem;
var localContent = GetParentContentInWindow<Widget>(item);
var list = item.Parent as Myra.Graphics2D.UI.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);
}
private void OneMenuFileSettingsSelected(object sender, EventArgs e)
@ -2374,39 +2371,38 @@ namespace Sledgemapper
}
}
private void OnButtonNoteOkClick(object sender, EventArgs e)
{
var button = ((TextButton)sender);
Container container = button.Parent;
private (Window Window ,C Content) GetParentContentInWindow<C>(Widget widget) where C:Widget
{
Container container = widget.Parent;
while (!(container is Window))
{
container = container.Parent;
}
var localWindow = (Window)container;
var localContent = localWindow.Content as NoteWindow;
var localContent = localWindow.Content as C;
return (localWindow,localContent);
}
private void OnButtonNoteOkClick(object sender, EventArgs e)
{
var button = ((TextButton)sender);
var localContent = GetParentContentInWindow<NoteWindow>(button) ;
var note = new Note
{
X = _state.SelectedNote.X,
Y = _state.SelectedNote.Y,
Text = localContent.NoteText.Text
Text = localContent.Content.NoteText.Text
};
_sessionData.NewNote(note);
localWindow.Close();
localContent.Window.Close();
}
private void OnButtonNoteCancelClick(object sender, EventArgs e)
{
var button = ((TextButton)sender);
Container container = button.Parent;
while (!(container is Window))
{
container = container.Parent;
}
var localWindow = (Window)container;
localWindow.Close();
var content = GetParentContentInWindow<Widget>(button);
content.Window.Close();
}
private async void OnButtonLoginClick(object sender, EventArgs e)
{