diff --git a/EstusShots.Gtk/Controls/BindableListControl.cs b/EstusShots.Gtk/Controls/BindableListControl.cs
index 3d3b364..d5f2a97 100644
--- a/EstusShots.Gtk/Controls/BindableListControl.cs
+++ b/EstusShots.Gtk/Controls/BindableListControl.cs
@@ -83,7 +83,7 @@ namespace EstusShots.Gtk.Controls
throw new TypeLoadException(
$"Property '{column.PropertyName}' does not exist on Type '{item.GetType()}'");
var val = prop.GetValue(item);
- if (column.Format != null) val = column.Format(val);
+ if (column.DisplayConverter != null) val = column.DisplayConverter(val);
row.Add(val);
}
@@ -129,34 +129,11 @@ namespace EstusShots.Gtk.Controls
{
// Offset by one, because the first column in the data store is fixed to the key value of the row
var valueIndex = Columns.IndexOf(dataColumn) + 1;
- var cell = GetRenderer(dataColumn);
- var attr = GetAttribute(dataColumn);
- dataColumn.PackStart(cell, true);
- dataColumn.AddAttribute(cell, attr, valueIndex);
+ dataColumn.AddAttribute(dataColumn.Cell, dataColumn.ValueAttribute, valueIndex);
TreeView.AppendColumn(dataColumn);
}
}
-
- private CellRenderer GetRenderer(DataColumn column)
- {
- var property = typeof(T).GetProperty(column.PropertyName);
- return property?.PropertyType.Name switch
- {
- nameof(Boolean) => new CellRendererToggle(),
- _ => new CellRendererText()
- };
- }
-
- private string GetAttribute(DataColumn column)
- {
- var property = typeof(T).GetProperty(column.PropertyName);
- return property?.PropertyType.Name switch
- {
- nameof(Boolean) => "active",
- _ => "text"
- };
- }
-
+
private void InitListStore()
{
var types = Columns
diff --git a/EstusShots.Gtk/Controls/DataColumn.cs b/EstusShots.Gtk/Controls/DataColumn.cs
index b03900c..8f24bec 100644
--- a/EstusShots.Gtk/Controls/DataColumn.cs
+++ b/EstusShots.Gtk/Controls/DataColumn.cs
@@ -3,19 +3,18 @@ using Gtk;
namespace EstusShots.Gtk.Controls
{
- public class DataColumn : TreeViewColumn
+ public abstract class DataColumn : TreeViewColumn
{
- public DataColumn()
+ protected DataColumn(string propertyName)
{
+ PropertyName = propertyName;
+ Title = propertyName;
+
Resizable = true;
Reorderable = true;
}
- public DataColumn(string propertyName) : this()
- {
- PropertyName = propertyName;
- Title = propertyName;
- }
+ public abstract string ValueAttribute { get; }
///
/// The name of the property in the data source, that should be show nin the view
@@ -26,6 +25,64 @@ namespace EstusShots.Gtk.Controls
/// Applies the given transformation on each item in the column.
/// This changes only the display of the value.
///
- public Func Format { get; set; }
+ public abstract Func DisplayConverter { get; set; }
+
+ ///
+ /// Cell renderer for rows in the column
+ ///
+ public abstract CellRenderer Cell { get; set; }
+ }
+
+ public class DataColumnText : DataColumn
+ {
+ public DataColumnText(string propertyName) : base(propertyName)
+ {
+ ValueAttribute = "text";
+ Cell = new CellRendererText();
+ PackStart(Cell, true);
+ }
+
+
+ public override string ValueAttribute { get; }
+
+ public override Func DisplayConverter { get; set; }
+
+ ///
+ /// Cell renderer for rows in the column
+ ///
+ public sealed override CellRenderer Cell { get; set; }
+ }
+
+ public class DataColumnBool : DataColumn
+ {
+ public DataColumnBool(string propertyName) : base(propertyName)
+ {
+ ValueAttribute = "active";
+ Cell = new CellRendererToggle();
+ PackStart(Cell, true);
+ }
+
+ public override string ValueAttribute { get; }
+ public override Func DisplayConverter { get; set; }
+ public sealed override CellRenderer Cell { get; set; }
+ }
+
+ public class DataColumnDouble : DataColumn
+ {
+ public DataColumnDouble(string propertyName) : base(propertyName)
+ {
+ ValueAttribute = "text";
+ Cell = new CellRendererSpin();
+ PackStart(Cell, true);
+ }
+
+ public int Digits
+ {
+ set => SetAttributes(Cell, "digits", value);
+ }
+
+ public override string ValueAttribute { get; }
+ public override Func DisplayConverter { get; set; }
+ public sealed override CellRenderer Cell { get; set; }
}
}
\ No newline at end of file
diff --git a/EstusShots.Gtk/Dialogs/Dialogs.glade b/EstusShots.Gtk/Dialogs/Dialogs.glade
index ce0584e..162c9b2 100644
--- a/EstusShots.Gtk/Dialogs/Dialogs.glade
+++ b/EstusShots.Gtk/Dialogs/Dialogs.glade
@@ -2,14 +2,144 @@
-
+
+ 100
+ 0.10000000000000001
+ 10
+
+
False
+ Drink
+ False
+ True
+ center-on-parent
+ True
+ dialog
+ center
+
+
+
+
+
+ False
+ vertical
+ 2
+
+
+ False
+ end
+
+
+ gtk-save
+ True
+ True
+ True
+ True
+
+
+
+ True
+ True
+ 0
+
+
+
+
+ gtk-cancel
+ True
+ True
+ True
+ True
+
+
+ True
+ True
+ 1
+
+
+
+
+ False
+ False
+ 0
+
+
+
+
+ True
+ False
+ 10
+ 10
+ 5
+ 7
+
+
+ True
+ False
+ end
+ Name
+
+
+ 0
+ 0
+
+
+
+
+ True
+ False
+ end
+ Vol. Alcohol
+
+
+ 0
+ 1
+
+
+
+
+ True
+ True
+
+
+ 1
+ 0
+
+
+
+
+ True
+ True
+ %
+ number
+ DrinkVolAdjustment
+ 0.10000000000000001
+ 1
+ True
+
+
+ 1
+ 1
+
+
+
+
+ False
+ True
+ 1
+
+
+
+
+
+
+ False
+ Player
False
True
center-on-parent
True
dialog
- False
center
@@ -76,7 +206,7 @@
True
False
end
- Name:
+ Name
0
@@ -88,7 +218,7 @@
True
False
end
- Alias:
+ Alias
0
@@ -133,7 +263,7 @@
True
False
end
- Hex ID:
+ Hex ID
0
diff --git a/EstusShots.Gtk/Dialogs/DrinkEditor.cs b/EstusShots.Gtk/Dialogs/DrinkEditor.cs
new file mode 100644
index 0000000..272eaad
--- /dev/null
+++ b/EstusShots.Gtk/Dialogs/DrinkEditor.cs
@@ -0,0 +1,63 @@
+using System;
+using EstusShots.Shared.Dto;
+using Gtk;
+using UI = Gtk.Builder.ObjectAttribute;
+
+namespace EstusShots.Gtk.Dialogs
+{
+ public class DrinkEditor
+ {
+ [UI] private readonly Dialog DrinkEditorDialog = null;
+ [UI] private readonly Entry DrinkNameEntry = null;
+ [UI] private readonly Adjustment DrinkVolAdjustment = null;
+ [UI] private readonly Button SaveDrinkButton = null;
+ [UI] private readonly Button CancelDrinkEditorButton = null;
+
+ private readonly Drink _drink;
+
+ public event DialogClosedEventHandler OnDialogClosed;
+
+ public DrinkEditor(Window parent, Drink drink)
+ {
+ _drink = drink;
+
+ var builder = new Builder("Dialogs.glade");
+ builder.Autoconnect(this);
+
+ SaveDrinkButton.Clicked += SaveDrinkButtonOnClicked;
+ CancelDrinkEditorButton.Clicked += (sender, args) =>
+ {
+ OnDialogClosed?.Invoke(this, new DialogClosedEventArgs(false, null));
+ DrinkEditorDialog.Dispose();
+ };
+
+ ReadFromModel();
+
+ DrinkEditorDialog.TransientFor = parent;
+ DrinkEditorDialog.Show();
+ }
+
+ // Events
+
+ private void SaveDrinkButtonOnClicked(object sender, EventArgs e)
+ {
+ ReadToModel();
+ OnDialogClosed?.Invoke(this, new DialogClosedEventArgs(true, _drink));
+ DrinkEditorDialog.Dispose();
+ }
+
+ // Private Methods
+
+ private void ReadToModel()
+ {
+ _drink.Name = DrinkNameEntry.Text;
+ _drink.Vol = DrinkVolAdjustment.Value;
+ }
+
+ private void ReadFromModel()
+ {
+ DrinkNameEntry.Text = _drink.Name;
+ DrinkVolAdjustment.Value = _drink.Vol;
+ }
+ }
+}
\ No newline at end of file
diff --git a/EstusShots.Gtk/Dialogs/PlayerEditor.cs b/EstusShots.Gtk/Dialogs/PlayerEditor.cs
index de69939..1e6e92a 100644
--- a/EstusShots.Gtk/Dialogs/PlayerEditor.cs
+++ b/EstusShots.Gtk/Dialogs/PlayerEditor.cs
@@ -20,11 +20,9 @@ namespace EstusShots.Gtk.Dialogs
public class PlayerEditor
{
- private Builder _builder;
- private Player _player;
+ private readonly Player _player;
[UI] private readonly Dialog PlayerEditorDialog = null;
- [UI] private readonly Overlay PlayerEditorOverlay = null;
[UI] private readonly Entry PlayerNameEntry = null;
[UI] private readonly Entry PlayerAliasEntry = null;
[UI] private readonly Entry PlayerHexIdEntry = null;
@@ -38,8 +36,8 @@ namespace EstusShots.Gtk.Dialogs
{
_player = player;
- _builder = new Builder("Dialogs.glade");
- _builder.Autoconnect(this);
+ var builder = new Builder("Dialogs.glade");
+ builder.Autoconnect(this);
SavePlayerButton.Clicked += SavePlayerButtonOnClicked;
CancelPlayerEditorButton.Clicked += (sender, args) =>
diff --git a/EstusShots.Gtk/MainWindow.cs b/EstusShots.Gtk/MainWindow.cs
index 32f73f3..1990d5d 100644
--- a/EstusShots.Gtk/MainWindow.cs
+++ b/EstusShots.Gtk/MainWindow.cs
@@ -1,10 +1,6 @@
using System;
-using System.Threading.Tasks;
using EstusShots.Client;
-using EstusShots.Gtk.Controls;
using EstusShots.Gtk.Dialogs;
-using EstusShots.Shared.Dto;
-using EstusShots.Shared.Models;
using Gdk;
using GLib;
using Gtk;
@@ -25,10 +21,7 @@ namespace EstusShots.Gtk
[UI] public readonly Box LoadingSpinner = null;
[UI] public readonly Notebook Navigation = null;
-
-
private EstusShotsClient Client { get; }
- private BindableListControl EpisodesControl { get; set; }
public MainWindow() : this(new Builder("MainWindow.glade"))
{
@@ -48,17 +41,23 @@ namespace EstusShots.Gtk
// Call initialization code of each page
InitSeasonsPage();
InitEpisodesPage();
- InitPlayersPage();
-
- CreateEpisodesControl();
+ InitBaseDataPage();
// The episodes page is not shown, as long as no season is selected
EpisodesPage.Hide();
+
+ Navigation.SwitchPage += NavigationOnSwitchPage;
Info("Application Started");
UpdateTitle();
}
+ private void NavigationOnSwitchPage(object o, SwitchPageArgs args)
+ {
+ if (!(args.Page is Box appPage)) return;
+
+ }
+
private void ExceptionManagerOnUnhandledException(UnhandledExceptionArgs args)
{
Console.WriteLine(args.ExceptionObject);
diff --git a/EstusShots.Gtk/MainWindow.glade b/EstusShots.Gtk/MainWindow.glade
index 0cd542b..e7ceb7b 100644
--- a/EstusShots.Gtk/MainWindow.glade
+++ b/EstusShots.Gtk/MainWindow.glade
@@ -136,6 +136,9 @@
+
+ True
+
@@ -217,6 +220,7 @@
1
+ True
@@ -231,7 +235,7 @@
-
+
True
False
vertical
@@ -256,6 +260,7 @@
2
+ True
@@ -270,30 +275,105 @@
-
+
True
False
+ 5
+ 5
+ 5
+ 5
+ 5
-
+
True
False
+ vertical
+ 5
-
+
True
- True
- in
+ False
-
+
True
- True
-
-
+ False
+ Players:
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ 5
+ start
+
+
+ New Player
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+
+
+
+
+ False
+ True
+ end
+ 1
+
- -1
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+
+
+ True
+ True
+ in
+
+
+ True
+ True
+ horizontal
+
+
+
+
+
+
+
+ -1
+
+
+
+
+ True
+ True
+ 1
@@ -303,18 +383,71 @@
0
+
+
+ True
+ False
+
+
+ False
+ True
+ 1
+
+
True
False
vertical
+ 5
-
+
True
False
- 5
- 5
- Edit Player
+
+
+ True
+ False
+ Drinks:
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ start
+
+
+ New Drink
+ True
+ True
+ True
+
+
+ True
+ True
+ 0
+
+
+
+
+
+
+
+
+
+
+ False
+ True
+ end
+ 1
+
+
False
@@ -323,12 +456,28 @@
-
+
True
False
- vertical
-
+
+ True
+ True
+ in
+
+
+ True
+ True
+ horizontal
+
+
+
+
+
+
+
+ -1
+
@@ -337,55 +486,24 @@
1
-
-
- True
- False
- 5
- start
-
-
- New Player
- True
- True
- True
-
-
- True
- True
- 0
-
-
-
-
-
-
-
-
-
-
- False
- True
- 2
-
-
- False
+ True
True
- 1
+ 2
3
+ True
True
False
- Players
+ Drinks & Players
3
diff --git a/EstusShots.Gtk/Pages/BaseDataPage.cs b/EstusShots.Gtk/Pages/BaseDataPage.cs
new file mode 100644
index 0000000..82cc046
--- /dev/null
+++ b/EstusShots.Gtk/Pages/BaseDataPage.cs
@@ -0,0 +1,141 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using EstusShots.Gtk.Controls;
+using EstusShots.Gtk.Dialogs;
+using EstusShots.Shared.Dto;
+using EstusShots.Shared.Models.Parameters;
+using Gtk;
+using UI = Gtk.Builder.ObjectAttribute;
+
+namespace EstusShots.Gtk
+{
+ internal partial class MainWindow
+ {
+ [UI] public readonly Box BaseDataPage = null;
+ [UI] public readonly TreeView PlayersTreeView = null;
+ [UI] public readonly Button NewPlayerButton = null;
+ [UI] public readonly Button NewDrinkButton = null;
+
+ [UI] public readonly TreeView DrinksTreeView = null;
+
+ private BindableListControl _playersControl;
+ private BindableListControl _drinksControl;
+
+ private void InitBaseDataPage()
+ {
+ NewPlayerButton.Clicked += NewPlayerButtonOnClicked;
+ NewDrinkButton.Clicked += NewDrinkButtonOnClicked;
+
+ var playerColumns = new List
+ {
+ new DataColumnText(nameof(Player.Name)),
+ new DataColumnText(nameof(Player.Alias)),
+ new DataColumnBool(nameof(Player.Anonymous)) {Title = "Is Anonymous?", FixedWidth = 120},
+ new DataColumnText(nameof(Player.HexId)) {Title = "Hex ID"},
+ };
+ _playersControl = new BindableListControl(playerColumns, nameof(Player.PlayerId), PlayersTreeView);
+ _playersControl.OnSelectionChanged += PlayersControlOnOnSelectionChanged;
+
+
+ var drinkColumns = new List
+ {
+ new DataColumnText(nameof(Drink.Name)),
+ new DataColumnDouble(nameof(Drink.Vol)) {Title = "%"}
+ };
+ _drinksControl = new BindableListControl(drinkColumns, nameof(Drink.DrinkId), DrinksTreeView);
+
+ // TODO Only Load when navigated to
+ Task _;
+ _ = ReloadPlayers();
+ _ = ReloadDrinks();
+ }
+
+ // Events
+
+ private void PlayersControlOnOnSelectionChanged(object o, SelectionChangedEventArgs args)
+ {
+ if (!(args.Selection is Player player)) return;
+ var dialog = new PlayerEditor(this, player);
+ dialog.OnDialogClosed += PlayerEditorClosed;
+ }
+
+ private void NewPlayerButtonOnClicked(object sender, EventArgs e)
+ {
+ var dialog = new PlayerEditor(this, new Player());
+ dialog.OnDialogClosed += PlayerEditorClosed;
+ }
+
+ private void NewDrinkButtonOnClicked(object sender, EventArgs e)
+ {
+ var dialog = new DrinkEditor(this, new Drink());
+ dialog.OnDialogClosed += DialogOnOnDialogClosed;
+ }
+
+ private async void DialogOnOnDialogClosed(object o, DialogClosedEventArgs args)
+ {
+ if (!args.Ok || !(args.Model is Drink drink)) return;
+
+ var res = await Task.Factory.StartNew(()
+ => Client.Drinks.SaveDrink(new SaveDrinkParameter(drink)).Result);
+
+ if (!res.OperationResult.Success)
+ {
+ Info($"Unable to save: {res.OperationResult.ShortMessage}");
+ ErrorDialog.Show(res.OperationResult);
+ return;
+ }
+
+ await ReloadDrinks();
+ }
+
+ private async void PlayerEditorClosed(object o, DialogClosedEventArgs args)
+ {
+ if (!args.Ok || !(args.Model is Player player)) return;
+ var res = await Task.Factory.StartNew(()
+ => Client.Players.SavePlayer(new SavePlayerParameter(player)).Result);
+ if (!res.OperationResult.Success)
+ {
+ Info($"Unable to save: {res.OperationResult.ShortMessage}");
+ ErrorDialog.Show(res.OperationResult);
+ return;
+ }
+
+ await ReloadPlayers();
+ }
+
+ // Private Methods
+
+ private async Task ReloadPlayers()
+ {
+ var res = await Task.Factory.StartNew(()
+ => Client.Players.GetPlayers(new GetPlayersParameter()).Result);
+ if (!res.OperationResult.Success)
+ {
+ InfoLabel.Text = $"Refresh failed: {res.OperationResult.ShortMessage}";
+ ErrorDialog.Show(res.OperationResult);
+ return;
+ }
+
+ _playersControl.Items = res.Data.Players;
+ _playersControl.DataBind();
+ Info("Player list refreshed");
+ }
+
+ private async Task ReloadDrinks()
+ {
+ var res = await Task.Factory.StartNew(()
+ => Client.Drinks.GetDrinks(new GetDrinksParameter()).Result);
+ if (!res.OperationResult.Success)
+ {
+ InfoLabel.Text = $"Refresh failed: {res.OperationResult.ShortMessage}";
+ ErrorDialog.Show(res.OperationResult);
+ return;
+ }
+
+ _drinksControl.Items = res.Data.Drinks;
+ _drinksControl.DataBind();
+ Info("Drink list refreshed");
+ }
+ }
+}
\ No newline at end of file
diff --git a/EstusShots.Gtk/Pages/EpisodesPage.cs b/EstusShots.Gtk/Pages/EpisodesPage.cs
index 8d60f5b..379008a 100644
--- a/EstusShots.Gtk/Pages/EpisodesPage.cs
+++ b/EstusShots.Gtk/Pages/EpisodesPage.cs
@@ -14,16 +14,20 @@ namespace EstusShots.Gtk
{
[UI] public readonly Box EpisodesPage = null;
[UI] public readonly Button AddEpisodeButton = null;
- [UI] public readonly Overlay EpisodesOverlay = null;
[UI] public readonly TreeView EpisodesTreeView = null;
-
+
+ private BindableListControl EpisodesControl { get; set; }
+
+
private void InitEpisodesPage()
{
AddEpisodeButton.Clicked += AddEpisodeButtonOnClicked;
+
+ CreateEpisodesControl();
}
-
- // Eevents
-
+
+ // Events
+
private async void AddEpisodeButtonOnClicked(object sender, EventArgs e)
{
if (SeasonsControl.SelectedItem == null) return;
@@ -64,9 +68,9 @@ namespace EstusShots.Gtk
await ReloadEpisodes();
}
-
+
// Private Methods
-
+
private async Task ReloadEpisodes()
{
var seasonId = SeasonsControl.SelectedItem.SeasonId;
@@ -82,27 +86,27 @@ namespace EstusShots.Gtk
EpisodesControl.DataBind();
Info("Episodes Refreshed");
}
-
+
private void CreateEpisodesControl()
{
var columns = new List
{
- new DataColumn(nameof(Episode.DisplayName)) {Title = "Name"},
- new DataColumn(nameof(Episode.Title)) {Title = "Title"},
- new DataColumn(nameof(Episode.Date))
+ new DataColumnText(nameof(Episode.DisplayName)) {Title = "Name"},
+ new DataColumnText(nameof(Episode.Title)) {Title = "Title"},
+ new DataColumnText(nameof(Episode.Date))
{
Title = "Date",
- Format = d => (d as DateTime?)?.ToString("dd.MM.yyyy")
+ DisplayConverter = d => (d as DateTime?)?.ToString("dd.MM.yyyy")
},
- new DataColumn(nameof(Episode.Start))
+ new DataColumnText(nameof(Episode.Start))
{
Title = "Start",
- Format = d => (d as DateTime?)?.ToString("HH:mm")
+ DisplayConverter = d => (d as DateTime?)?.ToString("HH:mm")
},
- new DataColumn(nameof(Episode.End))
+ new DataColumnText(nameof(Episode.End))
{
Title = "End",
- Format = d => (d as DateTime?)?.ToString("HH:mm") ?? "Ongoing"
+ DisplayConverter = d => (d as DateTime?)?.ToString("HH:mm") ?? "Ongoing"
}
};
EpisodesControl = new BindableListControl(columns, nameof(Episode.EpisodeId), EpisodesTreeView);
diff --git a/EstusShots.Gtk/Pages/PlayersPage.cs b/EstusShots.Gtk/Pages/PlayersPage.cs
deleted file mode 100644
index 50d9dbb..0000000
--- a/EstusShots.Gtk/Pages/PlayersPage.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using EstusShots.Gtk.Controls;
-using EstusShots.Gtk.Dialogs;
-using EstusShots.Shared.Dto;
-using EstusShots.Shared.Models.Parameters;
-using Gtk;
-using UI = Gtk.Builder.ObjectAttribute;
-
-namespace EstusShots.Gtk
-{
- internal partial class MainWindow
- {
- [UI] public readonly Box PlayersPage = null;
- [UI] public readonly Overlay PlayersOverlay = null;
- [UI] public readonly TreeView PlayersTreeView = null;
- [UI] public readonly Button NewPlayerButton = null;
- [UI] public readonly Box PlayerEditorContainer = null;
-
- private BindableListControl PlayersControl;
-
- private void InitPlayersPage()
- {
- NewPlayerButton.Clicked += NewPlayerButtonOnClicked;
-
- var columns = new List
- {
- new DataColumn(nameof(Player.Name)),
- new DataColumn(nameof(Player.Alias)),
- new DataColumn(nameof(Player.Anonymous)) {Title = "Is Anonymous?", FixedWidth = 120},
- new DataColumn(nameof(Player.HexId)) {Title = "Hex ID"},
- };
- PlayersControl = new BindableListControl(columns, nameof(Player.PlayerId), PlayersTreeView);
- PlayersControl.OnSelectionChanged += PlayersControlOnOnSelectionChanged;
-
- Task.Factory.StartNew(ReloadPlayers);
- }
-
- // Events
-
- private void PlayersControlOnOnSelectionChanged(object o, SelectionChangedEventArgs args)
- {
- if (!(args.Selection is Player player)) return;
- var dialog = new PlayerEditor(this, player);
- dialog.OnDialogClosed += PlayerEditorClosed;
- }
-
- private void NewPlayerButtonOnClicked(object sender, EventArgs e)
- {
- var dialog = new PlayerEditor(this, new Player());
- dialog.OnDialogClosed += PlayerEditorClosed;
- }
-
- private async void PlayerEditorClosed(object o, DialogClosedEventArgs args)
- {
- if (!args.Ok || !(args.Model is Player player)) return;
- var res = await Task.Factory.StartNew(()
- => Client.Players.SavePlayer(new SavePlayerParameter(player)).Result);
- if (!res.OperationResult.Success)
- {
- Info($"Unable to save: {res.OperationResult.ShortMessage}");
- ErrorDialog.Show(res.OperationResult);
- return;
- }
-
- await ReloadPlayers();
- }
-
- // Private Methods
-
- private async Task ReloadPlayers()
- {
- var res = await Task.Factory.StartNew(()
- => Client.Players.GetPlayers(new GetPlayersParameter()).Result);
- if (!res.OperationResult.Success)
- {
- InfoLabel.Text = $"Refresh failed: {res.OperationResult.ShortMessage}";
- ErrorDialog.Show(res.OperationResult);
- return;
- }
-
- PlayersControl.Items = res.Data.Players;
- PlayersControl.DataBind();
- Info("Player list refreshed");
- }
- }
-}
\ No newline at end of file
diff --git a/EstusShots.Gtk/Pages/SeasonsPage.cs b/EstusShots.Gtk/Pages/SeasonsPage.cs
index 82d5e4d..989ea13 100644
--- a/EstusShots.Gtk/Pages/SeasonsPage.cs
+++ b/EstusShots.Gtk/Pages/SeasonsPage.cs
@@ -32,7 +32,7 @@ namespace EstusShots.Gtk
}
// Events
-
+
private async void LoadButtonClicked(object sender, EventArgs a)
{
using var _ = new LoadingMode(this);
@@ -63,7 +63,7 @@ namespace EstusShots.Gtk
await ReloadSeasons();
Info("Created new Season");
}
-
+
private async void SeasonsControlOnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!(e.Selection is Season season)) return;
@@ -82,7 +82,7 @@ namespace EstusShots.Gtk
}
// Private Methods
-
+
private async Task ReloadSeasons()
{
var res = await Task.Factory.StartNew(
@@ -103,22 +103,19 @@ namespace EstusShots.Gtk
{
var columns = new List
{
- new DataColumn(nameof(Season.DisplayName)) {Title = "Name"},
- new DataColumn(nameof(Season.Description)) {Title = "Description"},
- new DataColumn(nameof(Season.Start))
+ new DataColumnText(nameof(Season.DisplayName)) {Title = "Name"},
+ new DataColumnText(nameof(Season.Description)),
+ new DataColumnText(nameof(Season.Start))
{
- Title = "Start",
- Format = date => (date as DateTime?)?.ToString("dd.MM.yyyy")
+ DisplayConverter = date => (date as DateTime?)?.ToString("dd.MM.yyyy")
},
- new DataColumn(nameof(Season.End))
+ new DataColumnText(nameof(Season.End))
{
- Title = "End",
- Format = date => (date as DateTime?)?.ToString("dd.MM.yyyy") ?? "Ongoing"
+ DisplayConverter = date => (date as DateTime?)?.ToString("dd.MM.yyyy") ?? "Ongoing"
}
};
SeasonsControl = new BindableListControl(columns, nameof(Season.SeasonId), SeasonsView);
SeasonsControl.OnSelectionChanged += SeasonsControlOnSelectionChanged;
}
-
}
}
\ No newline at end of file
diff --git a/EstusShots.Server/Program.cs b/EstusShots.Server/Program.cs
index e187dd0..478cef8 100644
--- a/EstusShots.Server/Program.cs
+++ b/EstusShots.Server/Program.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
diff --git a/EstusShots.Server/Services/PlayersService.cs b/EstusShots.Server/Services/PlayersService.cs
index 9740e23..7dda1cb 100644
--- a/EstusShots.Server/Services/PlayersService.cs
+++ b/EstusShots.Server/Services/PlayersService.cs
@@ -65,7 +65,7 @@ namespace EstusShots.Server.Services
}
}
- public async Task> DeletePlayers(DeletePlayerParameter parameter)
+ public Task> DeletePlayers(DeletePlayerParameter parameter)
{
throw new System.NotImplementedException();
}