Avalonia Start

This commit is contained in:
2024-03-10 19:33:34 +01:00
parent 99257c3422
commit 4d1df14fe5
32 changed files with 1284 additions and 3316 deletions

View File

@@ -71,7 +71,7 @@ namespace LaDOSE.Api.Controllers
}); });
} }
//[AllowAnonymous] [AllowAnonymous]
[HttpPost("register")] [HttpPost("register")]
public IActionResult Register([FromBody]ApplicationUser userDto) public IActionResult Register([FromBody]ApplicationUser userDto)
{ {

View File

@@ -40,11 +40,6 @@ namespace LaDOSE.Api
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
//Fix Gentoo Issue. //Fix Gentoo Issue.
var MySqlServer = this.Configuration["MySql:Server"];
var MySqlDatabase = this.Configuration["MySql:Database"];
var MySqlUser = this.Configuration["MySql:User"];
var MySqlPassword = this.Configuration["MySql:Password"];
if (Convert.ToBoolean(this.Configuration["FixGentoo"])) if (Convert.ToBoolean(this.Configuration["FixGentoo"]))
{ {
try try

View File

@@ -0,0 +1,11 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="LaDOSE.DesktopApp.Avalonia.App"
xmlns:local="using:LaDOSE.DesktopApp.Avalonia"
RequestedThemeVariant="Dark">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
</Application.Styles>
</Application>

View File

@@ -0,0 +1,33 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using LaDOSE.DesktopApp.Avalonia.ViewModels;
using LaDOSE.DesktopApp.Avalonia.Views;
using ReactiveUI;
using Splat;
namespace LaDOSE.DesktopApp.Avalonia;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
Locator.CurrentMutable.Register(() => new GamesView(), typeof(IViewFor<GamesViewModel>));
Locator.CurrentMutable.Register(() => new InfoView(), typeof(IViewFor<InfoViewModel>));
Locator.CurrentMutable.Register(() => new TournamentResultView(), typeof(IViewFor<TournamentResultViewModel>));
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
}
base.OnFrameworkInitializationCompleted();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

View File

@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<Folder Include="Models\"/>
<AvaloniaResource Include="Assets\**"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.10"/>
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.10" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.10"/>
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10"/>
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.10"/>
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.10"/>
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.10"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LaDOSE.DTO\LaDOSE.DTO.csproj" />
<ProjectReference Include="..\LaDOSE.REST\LaDOSE.REST.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,53 @@
using Avalonia;
using Avalonia.ReactiveUI;
using System;
using System.ComponentModel;
using LaDOSE.REST;
using Splat;
// using Xilium.CefGlue;
// using Xilium.CefGlue.Common;
// using Avalonia.Visuals;
namespace LaDOSE.DesktopApp.Avalonia;
sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args)
{
RegisterDependencies(Locator.CurrentMutable, Locator.Current);
BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
}
private static void RegisterDependencies(IMutableDependencyResolver currentMutable, IReadonlyDependencyResolver current)
{
currentMutable.RegisterLazySingleton<RestService>(()=>
{
var restService = new RestService();
restService.Connect(new Uri("http://localhost:5000"),"dev","dev");
return restService;
});
}
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder
.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace()
.AfterSetup(_ =>
{
// CefRuntimeLoader.Initialize(new CefSettings()
// {
// WindowlessRenderingEnabled = true,
// NoSandbox = true,
// });
})
.UseReactiveUI();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@@ -0,0 +1,343 @@
body {
color: #efefef;
background-color: #141415;
}
:root {
--breakpoint-xs: 0;
--breakpoint-sm: 576px;
--breakpoint-md: 768px;
--breakpoint-lg: 992px;
--breakpoint-xl: 1200px;
}
.table {
width: 100%;
margin-bottom: 1rem;
background-color: transparent;
}
.table th,
.table td {
padding: 0.75rem;
vertical-align: top;
border-top: 1px solid #dee2e6;
}
.table thead th {
vertical-align: bottom;
border-bottom: 2px solid #dee2e6;
}
.table tbody + tbody {
border-top: 2px solid #dee2e6;
}
.table .table {
background-color: #fff;
}
.table-sm th,
.table-sm td {
padding: 0.3rem;
}
.table-bordered {
border: 1px solid #dee2e6;
}
.table-bordered th,
.table-bordered td {
border: 1px solid #dee2e6;
}
.table-bordered thead th,
.table-bordered thead td {
border-bottom-width: 2px;
}
.table-borderless th,
.table-borderless td,
.table-borderless thead th,
.table-borderless tbody + tbody {
border: 0;
}
.table-striped tbody tr:nth-of-type(odd) {
background-color: rgba(0, 0, 0, 0.05);
}
.table-hover tbody tr:hover {
background-color: rgba(0, 0, 0, 0.075);
}
.table-primary,
.table-primary > th,
.table-primary > td {
background-color: #b8daff;
}
.table-hover .table-primary:hover {
background-color: #9fcdff;
}
.table-hover .table-primary:hover > td,
.table-hover .table-primary:hover > th {
background-color: #9fcdff;
}
.table-secondary,
.table-secondary > th,
.table-secondary > td {
background-color: #d6d8db;
}
.table-hover .table-secondary:hover {
background-color: #c8cbcf;
}
.table-hover .table-secondary:hover > td,
.table-hover .table-secondary:hover > th {
background-color: #c8cbcf;
}
.table-success,
.table-success > th,
.table-success > td {
background-color: #c3e6cb;
}
.table-hover .table-success:hover {
background-color: #b1dfbb;
}
.table-hover .table-success:hover > td,
.table-hover .table-success:hover > th {
background-color: #b1dfbb;
}
.table-info,
.table-info > th,
.table-info > td {
background-color: #bee5eb;
}
.table-hover .table-info:hover {
background-color: #abdde5;
}
.table-hover .table-info:hover > td,
.table-hover .table-info:hover > th {
background-color: #abdde5;
}
.table-warning,
.table-warning > th,
.table-warning > td {
background-color: #ffeeba;
}
.table-hover .table-warning:hover {
background-color: #ffe8a1;
}
.table-hover .table-warning:hover > td,
.table-hover .table-warning:hover > th {
background-color: #ffe8a1;
}
.table-danger,
.table-danger > th,
.table-danger > td {
background-color: #f5c6cb;
}
.table-hover .table-danger:hover {
background-color: #f1b0b7;
}
.table-hover .table-danger:hover > td,
.table-hover .table-danger:hover > th {
background-color: #f1b0b7;
}
.table-light,
.table-light > th,
.table-light > td {
background-color: #fdfdfe;
}
.table-hover .table-light:hover {
background-color: #ececf6;
}
.table-hover .table-light:hover > td,
.table-hover .table-light:hover > th {
background-color: #ececf6;
}
.table-dark,
.table-dark > th,
.table-dark > td {
background-color: #c6c8ca;
}
.table-hover .table-dark:hover {
background-color: #b9bbbe;
}
.table-hover .table-dark:hover > td,
.table-hover .table-dark:hover > th {
background-color: #b9bbbe;
}
.table-active,
.table-active > th,
.table-active > td {
background-color: rgba(0, 0, 0, 0.075);
}
.table-hover .table-active:hover {
background-color: rgba(0, 0, 0, 0.075);
}
.table-hover .table-active:hover > td,
.table-hover .table-active:hover > th {
background-color: rgba(0, 0, 0, 0.075);
}
.table .thead-dark th {
color: #fff;
background-color: #212529;
border-color: #32383e;
}
.table .thead-light th {
color: #495057;
background-color: #e9ecef;
border-color: #dee2e6;
}
.table-dark {
color: #fff;
background-color: #212529;
}
.table-dark th,
.table-dark td,
.table-dark thead th {
border-color: #32383e;
}
.table-dark.table-bordered {
border: 0;
}
.table-dark.table-striped tbody tr:nth-of-type(odd) {
background-color: rgba(255, 255, 255, 0.05);
}
.table-dark.table-hover tbody tr:hover {
background-color: rgba(255, 255, 255, 0.075);
}
@media (max-width: 575.98px) {
.table-responsive-sm {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
.table-responsive-sm > .table-bordered {
border: 0;
}
}
@media (max-width: 767.98px) {
.table-responsive-md {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
.table-responsive-md > .table-bordered {
border: 0;
}
}
@media (max-width: 991.98px) {
.table-responsive-lg {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
.table-responsive-lg > .table-bordered {
border: 0;
}
}
@media (max-width: 1199.98px) {
.table-responsive-xl {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
.table-responsive-xl > .table-bordered {
border: 0;
}
}
.table-responsive {
display: block;
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
.table-responsive > .table-bordered {
border: 0;
}
.table {
border-collapse: collapse !important;
}
.table td,
.table th {
/*background-color: #fff !important;*/
}
.table-bordered th,
.table-bordered td {
border: 1px solid #dee2e6 !important;
}
.table-dark {
color: #fff;
background-color: #212529
}
.table-dark th,
.table-dark td,
.table-dark thead th,
.table-dark tbody + tbody {
border-color: #dee2e6;
}
.table .thead-dark th {
color: inherit;
border-color: #dee2e6;
}

View File

@@ -0,0 +1,24 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using ReactiveUI;
namespace LaDOSE.DesktopApp.Avalonia.Utils;
public abstract class BaseViewModel : ReactiveObject, IRoutableViewModel,INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
protected void RaisePropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected BaseViewModel(IScreen hostScreen, string? urlPathSegment)
{
UrlPathSegment = urlPathSegment;
HostScreen = hostScreen;
}
public string? UrlPathSegment { get; }
public IScreen HostScreen { get; }
}

View File

@@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace LaDOSE.DesktopApp.Utils namespace LaDOSE.DesktopApp.Avalonia.Utils
{ {
public static class CustomListExtension public static class CustomListExtension
{ {

View File

@@ -0,0 +1,86 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using LaDOSE.DesktopApp.Avalonia.Utils;
using LaDOSE.DesktopApp.Avalonia.ViewModels;
using LaDOSE.DTO;
using LaDOSE.REST;
using ReactiveUI;
using Splat;
namespace LaDOSE.DesktopApp.Avalonia.ViewModels
{
public class GamesViewModel : BaseViewModel
{
public string DisplayName => "Games";
private GameDTO _currentGame;
private List<GameDTO> _games;
private RestService RestService { get; set; }
public GamesViewModel(IScreen screen): base(screen,"Games")
{
this.RestService = Locator.Current.GetService<RestService>();
this.Games=new List<GameDTO>();
OnInitialize();
}
void OnInitialize()
{
LoadGames();
this.CurrentGame = Games.First();
}
public void LoadGames()
{
var gameDtos = this.RestService.GetGames().OrderBy(e=>e.Order).ToList();
this.Games = gameDtos;
RaisePropertyChanged(nameof(this.Games));
}
public List<GameDTO> Games
{
get => _games;
set
{
_games = value;
RaisePropertyChanged(nameof(this.Games));
}
}
public GameDTO CurrentGame
{
get => _currentGame;
set
{
_currentGame = value;
RaisePropertyChanged(nameof(this.CurrentGame));
}
}
public void Update()
{
this.RestService.UpdateGame(this.CurrentGame);
LoadGames();
}
public void AddGame()
{
var item = new GameDTO();
this.RestService.UpdateGame(item);
LoadGames();
}
public void DeleteGame()
{
this.RestService.DeleteGame(this.CurrentGame.Id);
LoadGames();
}
public bool CanDeleteGame => CurrentGame != null;
}
}

View File

@@ -0,0 +1,16 @@
using System.ComponentModel;
using ReactiveUI;
namespace LaDOSE.DesktopApp.Avalonia.ViewModels;
public class InfoViewModel: ReactiveObject, IRoutableViewModel,INotifyPropertyChanged
{
public InfoViewModel(IScreen screen)
{
HostScreen = screen;
}
public string? UrlPathSegment => "Info";
public IScreen HostScreen { get; }
}

View File

@@ -0,0 +1,16 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
namespace LaDOSE.DesktopApp.Avalonia.ViewModels;
public class MainWindowViewModel : Window
{
public RoutedViewHostViewModel RoutedViewViewHost { get; } = new();
public void CloseApp()
{
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime)
((IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime).Shutdown();
}
}

View File

@@ -0,0 +1,61 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using LaDOSE.DesktopApp.Avalonia.Utils;
using ReactiveUI;
namespace LaDOSE.DesktopApp.Avalonia.ViewModels;
public class RoutedViewHostViewModel : ReactiveObject, IScreen, INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
protected void RaisePropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private string _current;
public RoutedViewHostViewModel()
{
Games = new GamesViewModel(this);
Info = new InfoViewModel(this);
Tournament = new TournamentResultViewModel(this);
Router.Navigate.Execute(Tournament);
Current = "Tournament";
}
public string Current
{
get => _current;
set
{
_current = value;
RaisePropertyChanged(nameof(Current));
}
}
public RoutingState Router { get; } = new();
public GamesViewModel Games { get; }
public InfoViewModel Info { get; }
public TournamentResultViewModel Tournament { get; }
public void ShowGames()
{
Router.Navigate.Execute(Games);
Current = "Games";
}
public void ShowInfo()
{
Router.Navigate.Execute(Info);
Current = "Info";
}
public void ShowTournament()
{
Router.Navigate.Execute(Tournament);
Current = "Tournament";
}
}

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Data; using System.Data;
@@ -8,19 +7,19 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Controls; using Avalonia.Collections;
using System.Windows.Forms; using Avalonia.Controls;
using LaDOSE.DesktopApp.Utils; using LaDOSE.DesktopApp.Avalonia.Utils;
using LaDOSE.DTO; using LaDOSE.DTO;
using LaDOSE.REST; using LaDOSE.REST;
using SaveFileDialog = Microsoft.Win32.SaveFileDialog; using ReactiveUI;
using Screen = Caliburn.Micro.Screen; using Splat;
namespace LaDOSE.DesktopApp.ViewModels namespace LaDOSE.DesktopApp.Avalonia.ViewModels
{ {
public class TournamentResultViewModel : Screen public class TournamentResultViewModel : BaseViewModel
{ {
public override string DisplayName => "Tournament Result"; public string DisplayName => "Tournament Result";
private RestService RestService { get; set; } private RestService RestService { get; set; }
//Dictionary<string, Dictionary<int, int>> _computedResult; //Dictionary<string, Dictionary<int, int>> _computedResult;
@@ -29,12 +28,6 @@ namespace LaDOSE.DesktopApp.ViewModels
private string css = string.Empty; private string css = string.Empty;
//"strong { font-weight: 700;} ". +
// "a { color: #ff9024;}"+
// "body { color: #efefef;background-color: #141415; }" +
// ""+
// "a:hover, .entry-meta span a:hover, .comments-link a:hover, body.coldisplay2 #front-columns a:active {color: #cb5920;}"+
// "tr td { border: 1px dashed #3D3D3D;} ";
private String _selectRegex; private String _selectRegex;
public String SelectRegex public String SelectRegex
@@ -43,7 +36,7 @@ namespace LaDOSE.DesktopApp.ViewModels
set set
{ {
_selectRegex = value; _selectRegex = value;
NotifyOfPropertyChange(() => SelectRegex); RaisePropertyChanged(nameof(SelectRegex));
} }
} }
@@ -55,7 +48,7 @@ namespace LaDOSE.DesktopApp.ViewModels
set set
{ {
_selectEventRegex = value; _selectEventRegex = value;
NotifyOfPropertyChange(() => SelectEventRegex); RaisePropertyChanged(nameof(SelectEventRegex));
} }
} }
private string _slug; private string _slug;
@@ -65,7 +58,7 @@ namespace LaDOSE.DesktopApp.ViewModels
set set
{ {
_slug = value; _slug = value;
NotifyOfPropertyChange(() => Slug); RaisePropertyChanged(nameof(Slug));
} }
} }
@@ -87,34 +80,34 @@ namespace LaDOSE.DesktopApp.ViewModels
set set
{ {
_htmlContent = value; _htmlContent = value;
NotifyOfPropertyChange(() => HtmlContent); RaisePropertyChanged(nameof(HtmlContent));
NotifyOfPropertyChange(() => Html); RaisePropertyChanged(nameof(Html));
} }
} }
private DateTime _from; private DateTimeOffset _from;
public DateTime From public DateTimeOffset From
{ {
get { return _from; } get { return _from; }
set set
{ {
_from = value; _from = value;
NotifyOfPropertyChange(() => From); RaisePropertyChanged(nameof(From));
} }
} }
private DateTime _to; private DateTimeOffset _to;
public DateTime To public DateTimeOffset To
{ {
get { return _to; } get { return _to; }
set set
{ {
_to = value; _to = value;
NotifyOfPropertyChange(() => To); RaisePropertyChanged(nameof(To));
} }
} }
@@ -130,7 +123,7 @@ namespace LaDOSE.DesktopApp.ViewModels
set set
{ {
_results = value; _results = value;
NotifyOfPropertyChange(() => Results); RaisePropertyChanged(nameof(Results));
} }
} }
@@ -142,7 +135,7 @@ namespace LaDOSE.DesktopApp.ViewModels
set set
{ {
_selectedEvents = value; _selectedEvents = value;
NotifyOfPropertyChange(() => SelectedEvents); RaisePropertyChanged(nameof(SelectedEvents));
} }
} }
@@ -154,7 +147,7 @@ namespace LaDOSE.DesktopApp.ViewModels
set set
{ {
_selectedTournaments = value; _selectedTournaments = value;
NotifyOfPropertyChange(() => SelectedTournaments); RaisePropertyChanged(nameof(SelectedTournaments));
} }
} }
@@ -175,7 +168,7 @@ namespace LaDOSE.DesktopApp.ViewModels
SelectedGameResult = new ObservableCollection<ResultDTO>(resultForGame); SelectedGameResult = new ObservableCollection<ResultDTO>(resultForGame);
} }
NotifyOfPropertyChange(() => SelectedGame); RaisePropertyChanged(nameof(SelectedGame));
} }
} }
@@ -187,12 +180,13 @@ namespace LaDOSE.DesktopApp.ViewModels
set set
{ {
_selectedGameResult = value; _selectedGameResult = value;
NotifyOfPropertyChange(() => SelectedGameResult); RaisePropertyChanged(nameof(SelectedGameResult));
} }
} }
private String _first; private String _first;
private DataTable _gridDataTable; private DataTable _gridDataTable;
private string _error;
public String First public String First
{ {
@@ -200,65 +194,62 @@ namespace LaDOSE.DesktopApp.ViewModels
set set
{ {
_first = value; _first = value;
NotifyOfPropertyChange(() => First); RaisePropertyChanged(nameof(First));
} }
} }
#endregion #endregion
public TournamentResultViewModel(RestService restService) public TournamentResultViewModel(IScreen hostScreen):base(hostScreen,"Tournament")
{ {
this.RestService = restService; this.RestService = Locator.Current.GetService<RestService>();;
_selectedTournaments = new ObservableCollection<TournamentDTO>(); _selectedTournaments = new ObservableCollection<TournamentDTO>();
_selectedEvents = new ObservableCollection<EventDTO>(); _selectedEvents = new ObservableCollection<EventDTO>();
Tournaments = new List<TournamentDTO>(); Tournaments = new List<TournamentDTO>();
Events = new List<EventDTO>(); Events = new List<EventDTO>();
OnInitialize();
} }
protected override void OnInitialize() protected void OnInitialize()
{ {
var manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LaDOSE.DesktopApp.Resources.css.css"); // var manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LaDOSE.DesktopApp.Resources.css.css");
using (var sr = new StreamReader(manifestResourceStream)) // using (var sr = new StreamReader(manifestResourceStream))
{ // {
this.css = sr.ReadToEnd(); // this.css = sr.ReadToEnd();
} // }
this.To = DateTime.Now; this.To = new DateTimeOffset(DateTime.Now);
this.From = DateTime.Now.AddMonths(-1); this.From = new DateTimeOffset(DateTime.Now.AddMonths(-1));
this.SelectRegex = "Ranking"; this.SelectRegex = "Ranking";
this.SelectEventRegex = @"Ranking #10\d{2}"; this.SelectEventRegex = @"Ranking #10\d{2}";
this.Slug = "ranking-1001"; this.Slug = "ranking-1001";
LoadTournaments(); LoadTournaments();
LoadEvents(); LoadEvents();
base.OnInitialize();
} }
public void LoadTournaments() public void LoadTournaments()
{ {
WpfUtil.Await(() =>
{
var tournamentDtos = this.RestService
.GetTournaments(new TimeRangeDTO() {From = this.From, To = this.To}).ToList();
this.Tournaments = tournamentDtos;
NotifyOfPropertyChange("Tournaments"); // var tournamentDtos = this.RestService
}); // .GetTournaments(new TimeRangeDTO() {From = this.From, To = this.To}).ToList();
// this.Tournaments = tournamentDtos;
RaisePropertyChanged(nameof(Tournaments));
} }
public void LoadEvents() public void LoadEvents()
{ {
WpfUtil.Await(() =>
{
var eventsDtos = this.RestService var eventsDtos = this.RestService
.GetAllEvents().ToList(); .GetAllEvents().ToList();
this.Events = eventsDtos; this.Events = eventsDtos;
NotifyOfPropertyChange("Events"); RaisePropertyChanged(nameof(Events));
});
} }
public DataTable GridDataTable public DataTable GridDataTable
@@ -267,44 +258,61 @@ namespace LaDOSE.DesktopApp.ViewModels
set set
{ {
_gridDataTable = value; _gridDataTable = value;
NotifyOfPropertyChange(() => GridDataTable); RaisePropertyChanged(nameof(GridDataTable));
RaisePropertyChanged(nameof(GridDataTableView));
}
}
public DataView GridDataTableView
{
get
{
DataView gridDataTableView = _gridDataTable?.AsDataView();
return gridDataTableView;
} }
} }
public void Select() public void Select()
{ {
WpfUtil.Await(() =>
{
var tournamentsIds = SelectedEvents.Select(e => e.Id).ToList(); var tournamentsIds = SelectedEvents.Select(e => e.Id).ToList();
var resultsDto = this.RestService.GetResults(tournamentsIds); var resultsDto = this.RestService.GetResults(tournamentsIds);
this.Results = resultsDto; this.Results = resultsDto;
ComputeDataGrid(); ComputeDataGrid();
ComputeHtml(); ComputeHtml();
});
} }
public void GetSmash() public void GetSmash()
{ {
WpfUtil.Await(() =>
{
var resultsDto = this.RestService.ParseSmash(Slug); var resultsDto = this.RestService.ParseSmash(Slug);
if (!resultsDto) if (!resultsDto)
{ {
MessageBox.Show("Fail"); Error = "Error getting Smash";
} }
});
} }
public string Error
{
get => _error;
set
{
if (value == _error) return;
_error = value;
RaisePropertyChanged();
}
}
public void GetChallonge() public void GetChallonge()
{ {
WpfUtil.Await(() =>
{
var ids = SelectedTournaments.Select(e => e.ChallongeId).ToList(); var ids = SelectedTournaments.Select(e => e.ChallongeId).ToList();
var resultsDto = this.RestService.ParseChallonge(ids); var resultsDto = this.RestService.ParseChallonge(ids);
if (!resultsDto) if (!resultsDto)
{ {
MessageBox.Show("Fail"); Error = "Fail";
} }
});
} }
public void UpdateEvent() public void UpdateEvent()
@@ -329,14 +337,14 @@ namespace LaDOSE.DesktopApp.ViewModels
var selectedTournaments = this.Tournaments.Where(e => Regex.IsMatch(e.Name, this.SelectRegex)).ToList(); var selectedTournaments = this.Tournaments.Where(e => Regex.IsMatch(e.Name, this.SelectRegex)).ToList();
this.SelectedTournaments.Clear(); this.SelectedTournaments.Clear();
if (selectedTournaments.Count > 0) if (selectedTournaments.Count > 0)
selectedTournaments.ForEach(e => this.SelectedTournaments.AddUI(e)); selectedTournaments.ForEach(e => this.SelectedTournaments.Add(e));
} }
public void SelectEvent() public void SelectEvent()
{ {
var selectedEvents = this.Events.Where(e => Regex.IsMatch(e.Name, this.SelectEventRegex)).ToList(); var selectedEvents = this.Events.Where(e => Regex.IsMatch(e.Name, this.SelectEventRegex)).ToList();
this.SelectedEvents.Clear(); this.SelectedEvents.Clear();
if (selectedEvents.Count > 0) if (selectedEvents.Count > 0)
selectedEvents.ForEach(e => this.SelectedEvents.AddUI(e)); selectedEvents.ForEach(e => this.SelectedEvents.Add(e));
} }
//This could be simplified the Dictionary was for a previous usage, but i m too lazy to rewrite it. //This could be simplified the Dictionary was for a previous usage, but i m too lazy to rewrite it.
private void ComputeDataGrid() private void ComputeDataGrid()
@@ -367,7 +375,7 @@ namespace LaDOSE.DesktopApp.ViewModels
{ {
var resultsGame = Results.Games[j]; var resultsGame = Results.Games[j];
var points = GetPlayerPoint(resultsParticipent, resultsGame.Id); var points = GetPlayerPoint(resultsParticipent, resultsGame.Id);
dataRow[resultsGame.Name.Replace('.', ' ')] = points!=0?(object) points:DBNull.Value; dataRow[resultsGame.Name.Replace('.', ' ')] = points!=0?points:0;
total += points; total += points;
} }
dataRow["Total"] = total; dataRow["Total"] = total;
@@ -389,33 +397,33 @@ namespace LaDOSE.DesktopApp.ViewModels
private void ExportToCSV() private void ExportToCSV()
{ {
if (this.GridDataTable != null) // if (this.GridDataTable != null)
{ // {
var dataTable = this.GridDataTable.DefaultView.ToTable(); // var dataTable = this.GridDataTable.DefaultView.ToTable();
SaveFileDialog sfDialog = new SaveFileDialog() // SaveFileDialog sfDialog = new SaveFileDialog()
{ // {
Filter = "Csv Files (*.csv)|*.csv|All Files (*.*)|*.*", // Filter = "Csv Files (*.csv)|*.csv|All Files (*.*)|*.*",
AddExtension = true // AddExtension = true
}; // };
if (sfDialog.ShowDialog() == true) // if (sfDialog.ShowDialog() == true)
{ // {
StringBuilder sb = new StringBuilder(); // StringBuilder sb = new StringBuilder();
//
IEnumerable<string> columnNames = dataTable.Columns.Cast<DataColumn>() // IEnumerable<string> columnNames = dataTable.Columns.Cast<DataColumn>()
.Select(column => column.ColumnName); // .Select(column => column.ColumnName);
sb.AppendLine(string.Join(";", columnNames)); // sb.AppendLine(string.Join(";", columnNames));
//
foreach (DataRow row in dataTable.Rows) // foreach (DataRow row in dataTable.Rows)
{ // {
//EXCEL IS A BITCH // //EXCEL IS A BITCH
IEnumerable<string> fields = row.ItemArray.Select(field => // IEnumerable<string> fields = row.ItemArray.Select(field =>
string.Concat("\"", field.ToString().Replace("\"", "\"\""), "\"")); // string.Concat("\"", field.ToString().Replace("\"", "\"\""), "\""));
sb.AppendLine(string.Join(";", fields)); // sb.AppendLine(string.Join(";", fields));
} // }
//
File.WriteAllText(sfDialog.FileName, sb.ToString()); // File.WriteAllText(sfDialog.FileName, sb.ToString());
} // }
} // }
} }
private void ComputeHtml() private void ComputeHtml()
@@ -483,7 +491,7 @@ namespace LaDOSE.DesktopApp.ViewModels
} }
public void CopyHtml() public void CopyHtml()
{ {
System.Windows.Clipboard.SetText(this.HtmlContent); // System.Windows.Clipboard.SetText(this.HtmlContent);
} }
private int GetPlayerPoint(string name, int gameid) private int GetPlayerPoint(string name, int gameid)

View File

@@ -0,0 +1,82 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="LaDOSE.DesktopApp.Avalonia.Views.GamesView"
xmlns:vm="using:LaDOSE.DesktopApp.Avalonia.ViewModels"
x:DataType="vm:GamesViewModel"
>
<Grid Row="4" Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Button Grid.Row="0" x:Name="LoadGames" Command="{Binding LoadGames}" >Load Games</Button>
<ListBox Grid.Row="1" ItemsSource="{Binding Games}" x:Name="GamesListView" SelectedItem="{Binding CurrentGame}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Order}"></Label>
<Label> - </Label>
<Label Content="{Binding Name}"></Label>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Button Grid.Row="0" Grid.Column="0" x:Name="AddGame" Command="{Binding AddGame}">Add Game</Button>
<Button Grid.Row="0" Grid.Column="1" x:Name="DeleteGame" Command="{Binding DeleteGame}">Delete Game</Button>
<Label Grid.Row="1" Grid.Column="0">Id</Label>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=CurrentGame.Id,Mode=TwoWay}" IsReadOnly="True"></TextBox>
<Label Grid.Row="2" Grid.Column="0">Name</Label>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Path=CurrentGame.Name,Mode=TwoWay}" ></TextBox>
<Label Grid.Row="3" Grid.Column="0">Order</Label>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Path=CurrentGame.Order,Mode=TwoWay}">
<!-- <i:Interaction.Behaviors> -->
<!-- <behaviors:TextBoxInputRegExBehaviour RegularExpression="^\d+$" MaxLength="9" EmptyValue="0"> -->
<!-- -->
<!-- </behaviors:TextBoxInputRegExBehaviour> -->
<!-- </i:Interaction.Behaviors> -->
</TextBox>
<Label Grid.Row="4" Grid.Column="0">LongName</Label>
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding Path=CurrentGame.LongName,Mode=TwoWay}" ></TextBox>
<Label Grid.Row="5" Grid.Column="0">WpTag</Label>
<TextBox Grid.Row="5" Grid.Column="1" Text="{Binding Path=CurrentGame.WordPressTag,Mode=TwoWay}" ></TextBox>
<Label Grid.Row="6" Grid.Column="0">WpTagOs</Label>
<TextBox Grid.Row="6" Grid.Column="1" Text="{Binding Path=CurrentGame.WordPressTagOs,Mode=TwoWay}" ></TextBox>
<Label Grid.Row="7" Grid.Column="0">SmashId</Label>
<TextBox Grid.Row="7" Grid.Column="1" Text="{Binding Path=CurrentGame.SmashId,Mode=TwoWay}">
</TextBox>
<Button Grid.Row="9" Grid.ColumnSpan="2" x:Name="Update" Command="{Binding Update}">Update</Button>
</Grid>
</Grid>
</UserControl>

View File

@@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using LaDOSE.DesktopApp.Avalonia.ViewModels;
using ReactiveUI;
namespace LaDOSE.DesktopApp.Avalonia.Views;
public partial class GamesView : UserControl,IViewFor<GamesViewModel>
{
public GamesView()
{
InitializeComponent();
}
object? IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (GamesViewModel?)value;
}
public GamesViewModel? ViewModel { get; set; }
}

View File

@@ -0,0 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="LaDOSE.DesktopApp.Avalonia.Views.InfoView">
<Decorator x:Name="browserWrapper"/>
</UserControl>

View File

@@ -0,0 +1,24 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using LaDOSE.DesktopApp.Avalonia.ViewModels;
using ReactiveUI;
namespace LaDOSE.DesktopApp.Avalonia.Views;
public partial class InfoView : UserControl, IViewFor<InfoViewModel>
{
// private AvaloniaCefBrowser browser;
public InfoView()
{
InitializeComponent();
}
object? IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (InfoViewModel?)value;
}
public InfoViewModel? ViewModel { get; set; }
}

View File

@@ -0,0 +1,52 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:LaDOSE.DesktopApp.Avalonia.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactiveUi="http://reactiveui.net"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="LaDOSE.DesktopApp.Avalonia.Views.MainWindow"
x:DataType="vm:MainWindowViewModel"
Icon="/Assets/avalonia-logo.ico"
Title="LaDOSE.DesktopApp.Avalonia">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainWindowViewModel/>
</Design.DataContext>
<Grid Row="4" Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Menu Grid.Row="0" DockPanel.Dock="Top">
<MenuItem Header="_File">
<MenuItem Header="_Events" Command="{Binding RoutedViewViewHost.ShowTournament}">
</MenuItem>
<MenuItem Header="_Games" Command="{Binding RoutedViewViewHost.ShowGames}" >
</MenuItem>
<MenuItem Header="_Tournaments">
</MenuItem>
<MenuItem Header="_EventPlayers">
</MenuItem>
<MenuItem Header="_Info" Command="{Binding RoutedViewViewHost.ShowInfo}" />
<MenuItem Header="_Close" Command="{Binding CloseApp}" />
</MenuItem>
</Menu>
<TabControl Grid.Row="1" TabStripPlacement="Left">
<TabItem Header="{Binding Path=RoutedViewViewHost.Current}">
<DockPanel DataContext="{Binding RoutedViewViewHost}">
<reactiveUi:RoutedViewHost Router="{Binding Router}"/>
</DockPanel>
</TabItem>
</TabControl>
<StackPanel Grid.Row="2" Orientation="Horizontal">
<TextBlock> User : </TextBlock>
<TextBlock Margin="5,0,0,0"></TextBlock>
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,12 @@
using Avalonia.Controls;
namespace LaDOSE.DesktopApp.Avalonia.Views;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}

View File

@@ -0,0 +1,212 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="LaDOSE.DesktopApp.Avalonia.Views.TournamentResultView"
xmlns:vm="using:LaDOSE.DesktopApp.Avalonia.ViewModels"
x:DataType="vm:TournamentResultViewModel"
>
<Grid Row="2" Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="2*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Row="0" Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Row="0" Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,5">
<Label>Date :</Label>
<StackPanel Orientation="Horizontal" Width="210">
<DatePicker SelectedDate="{Binding From}" Width="100" BorderBrush="{x:Null}">
</DatePicker>
<DatePicker SelectedDate="{Binding To}" Width="100" Margin="5,0,5,0" BorderBrush="{x:Null}">
</DatePicker>
</StackPanel>
<Label>Usefull :</Label>
<Button Padding="5,0,5,0" x:Name="SelectMonth" Command="{Binding SelectMonth}">Month</Button>
<Button Padding="5,0,5,0" Margin="5,0,5,0" x:Name="SelectYear" Command="{Binding SelectYear}">Year</Button>
</StackPanel>
<Button Grid.Row="1" x:Name="LoadTournaments" Command="{Binding LoadTournaments}">Update</Button>
<ListBox Grid.Row="2" ItemsSource="{Binding Tournaments}" x:Name="TournamentList" Margin="0,0,0,5"
IsTextSearchEnabled="True" TextSearch.Text="Name"
SelectedItems="{Binding SelectedTournaments}"
SelectionMode="Multiple">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<DockPanel Grid.Row="3" Dock="Left">
<Label>Select :</Label>
<TextBox Width="200" Text="{Binding SelectRegex}"></TextBox>
<Button Padding="5,0,5,0" Margin="5,0,5,0" x:Name="SelectRegexp" Command="{Binding SelectRegexp}">Select</Button>
<Button Padding="5,0,5,0" Margin="5,0,5,0" x:Name="GetChallonge" Command="{Binding GetChallonge}">Import</Button>
</DockPanel>
</Grid>
<Grid Row="0" Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" Margin="0,0,0,6">
<Label> Smash Slug :</Label>
<TextBox Width="200" Text="{Binding Slug}"></TextBox>
<Button Margin="5,0,5,0" x:Name="GetSmash" Command="{Binding GetSmash}" >Import Smash Event</Button>
</StackPanel>
<Button Grid.Row="1" x:Name="UpdateEvent" Command="{Binding UpdateEvent}">Update Event</Button>
<ListBox Grid.Row="2" ItemsSource="{Binding Events}" Margin="0,0,0,5"
IsTextSearchEnabled="True" TextSearch.Text="Name" SelectionMode="Multiple"
SelectedItems="{Binding SelectedEvents}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Id}" />
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<DockPanel Grid.Row="3" Dock="Left">
<Label>Select :</Label>
<TextBox Width="200" Text="{Binding SelectEventRegex}"></TextBox>
<Button Padding="5,0,5,0" Margin="5,0,5,0" x:Name="SelectEvent" Command="{Binding SelectEvent}">Select</Button>
</DockPanel>
</Grid>
</Grid>
<Grid Row="3">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<!--<DockPanel Grid.Row="0" Grid.ColumnSpan="3" Dock="Left">
<Label>Select :</Label>
<TextBox Width="200" Text="{Binding SelectRegex}"></TextBox>
<Button Padding="5,0,5,0" Margin="5,0,5,0" x:Name="SelectRegexp">Select</Button>
<Button x:Name="Select" >Get Tournaments Result</Button>
</DockPanel>-->
<Button x:Name="Select" Grid.ColumnSpan="3" Command="{Binding Select}">Get Tournaments Result</Button>
<StackPanel Grid.Row="1" Grid.ColumnSpan="3" Orientation="Horizontal">
<TextBlock> Game :</TextBlock>
<TextBlock Margin="5,0,0,0" Text="{Binding Results.Games.Count}" />
</StackPanel>
<ListBox Grid.Row="2" ItemsSource="{Binding Results.Games}" Margin="5,5,5,5"
IsTextSearchEnabled="True" TextSearch.Text="Name"
SelectedItem="{Binding SelectedGame}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Id}" />
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Orientation="Horizontal">
<TextBlock> Participents :</TextBlock>
<TextBlock Margin="5,0,0,0" Text="{Binding Results.Participents.Count}" />
</StackPanel>
<ListBox Grid.Row="2" Grid.Column="1" ItemsSource="{Binding Results.Participents}" Margin="5,5,5,5"
IsTextSearchEnabled="True" TextSearch.Text="Name">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5,0,0,0" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TabControl Grid.Row="2" Grid.Column="2">
<TabItem Header="Result">
<DataGrid x:Name="DataGrid" PropertyChanged="DataGrid_OnPropertyChanged" ItemsSource="{Binding GridDataTableView}" CanUserSortColumns="True" BorderThickness="1" BorderBrush="Gray"/>
</TabItem>
<TabItem Header="By Game">
<DockPanel>
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
<TextBlock> Total :</TextBlock>
<TextBlock Text="{Binding SelectedGameResult.Count}" />
</StackPanel>
<ListBox ItemsSource="{Binding SelectedGameResult}" Margin="5,5,5,5"
IsTextSearchEnabled="True" TextSearch.Text="Name" DockPanel.Dock="Top">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5,0,0,0" Text="{Binding Player}" />
<TextBlock Margin="5,0,0,0" Text="{Binding Point}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
</TabItem>
<TabItem Header="HTML">
<DockPanel>
<Button x:Name="CopyHtml" DockPanel.Dock="Top" Command="{Binding CopyHtml}">Copy HTML to clipboard</Button>
<TextBox Text="{Binding Html}" />
</DockPanel>
</TabItem>
</TabControl>
<Button Grid.Row="4" Grid.ColumnSpan="3" x:Name="Export" Command="{Binding Export}">Export</Button>
</Grid>
</Grid>
</UserControl>

View File

@@ -0,0 +1,56 @@

using System.Data;
using System.Diagnostics;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
using LaDOSE.DesktopApp.Avalonia.ViewModels;
using ReactiveUI;
namespace LaDOSE.DesktopApp.Avalonia.Views
{
/// <summary>
/// Interaction logic for ShellView.xaml
/// </summary>
public partial class TournamentResultView : UserControl, IViewFor<TournamentResultViewModel>
{
public TournamentResultView()
{
InitializeComponent();
}
object? IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (TournamentResultViewModel)value;
}
public TournamentResultViewModel? ViewModel { get; set; }
private void DataGrid_OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
{
if (e.Property.Name == "ItemsSource")
{
Trace.WriteLine("Changed Binding");
var grid = (sender as DataGrid);
grid.Columns.Clear();
var data = ViewModel.GridDataTable;
foreach (DataColumn? view in data.Columns)
{
grid.Columns.Add(new DataGridTextColumn()
{
Header = view.ColumnName,
CanUserSort = true,
Binding = new Binding($"Row.ItemArray[{view.Ordinal}]")
});
}
}
return;
}
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="LaDOSE.DesktopApp.Avalonia.Desktop"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>

View File

@@ -11,7 +11,7 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>LaDOSE.DesktopApp</RootNamespace> <RootNamespace>LaDOSE.DesktopApp</RootNamespace>
<AssemblyName>LaDOSE.DesktopApp</AssemblyName> <AssemblyName>LaDOSE.DesktopApp</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
@@ -71,27 +71,6 @@
<OutputPath>bin\x64\Release\</OutputPath> <OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Caliburn.Micro, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.Core.3.2.0\lib\net45\Caliburn.Micro.dll</HintPath>
</Reference>
<Reference Include="Caliburn.Micro.Platform, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.dll</HintPath>
</Reference>
<Reference Include="Caliburn.Micro.Platform.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
</Reference>
<Reference Include="CefSharp, Version=103.0.120.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
<HintPath>..\packages\CefSharp.Common.103.0.120\lib\net452\CefSharp.dll</HintPath>
</Reference>
<Reference Include="CefSharp.Core, Version=103.0.120.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
<HintPath>..\packages\CefSharp.Common.103.0.120\lib\net452\CefSharp.Core.dll</HintPath>
</Reference>
<Reference Include="CefSharp.Wpf, Version=103.0.120.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=MSIL">
<HintPath>..\packages\CefSharp.Wpf.103.0.120\lib\net452\CefSharp.Wpf.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.11.4.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.11.4\lib\net452\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
@@ -101,9 +80,6 @@
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" /> <Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@@ -126,8 +102,6 @@
<Compile Include="Behaviors\TextBoxInputRegExBehaviour.cs" /> <Compile Include="Behaviors\TextBoxInputRegExBehaviour.cs" />
<Compile Include="Behaviors\MultiSelectorBehaviours.cs" /> <Compile Include="Behaviors\MultiSelectorBehaviours.cs" />
<Compile Include="Bootstrapper.cs" /> <Compile Include="Bootstrapper.cs" />
<Compile Include="Themes\LeftMarginMultiplierConverter.cs" />
<Compile Include="Themes\TreeViewItemExtensions.cs" />
<Compile Include="Utils\CustomEqualityCompare.cs" /> <Compile Include="Utils\CustomEqualityCompare.cs" />
<Compile Include="Utils\PhpSerialize.cs" /> <Compile Include="Utils\PhpSerialize.cs" />
<Compile Include="UserControls\BookingUserControl.xaml.cs"> <Compile Include="UserControls\BookingUserControl.xaml.cs">
@@ -163,10 +137,6 @@
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Page Include="Themes\Styles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UserControls\BookingUserControl.xaml"> <Page Include="UserControls\BookingUserControl.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -214,7 +184,6 @@
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>

View File

@@ -1,31 +0,0 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace DarkBlendTheme
{
public class LeftMarginMultiplierConverter : IValueConverter
{
public double Length { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var item = value as TreeViewItem;
if (item == null)
return new Thickness(0);
return new Thickness(Length * item.GetDepth(), 0, 0, 0);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new System.NotImplementedException();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,38 +0,0 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
namespace DarkBlendTheme
{
public static class TreeViewItemExtensions
{
public static int GetDepth(this TreeViewItem item)
{
TreeViewItem parent;
while ((parent = GetParent(item)) != null)
{
return GetDepth(parent) + 1;
}
return 0;
}
private static TreeViewItem GetParent(TreeViewItem item)
{
var parent = VisualTreeHelper.GetParent(item);
while (!(parent is TreeViewItem || parent is TreeView))
{
if (parent == null) return null;
parent = VisualTreeHelper.GetParent(parent);
}
return parent as TreeViewItem;
}
}
}

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Caliburn.Micro" version="3.2.0" targetFramework="net461" />
<package id="Caliburn.Micro.Core" version="3.2.0" targetFramework="net461" />
<package id="cef.redist.x64" version="103.0.12" targetFramework="net461" />
<package id="cef.redist.x86" version="103.0.12" targetFramework="net461" />
<package id="CefSharp.Common" version="103.0.120" targetFramework="net461" />
<package id="CefSharp.Wpf" version="103.0.120" targetFramework="net461" />
<package id="RestSharp" version="106.11.4" targetFramework="net461" />
<package id="WPFThemes.DarkBlend" version="1.0.8" targetFramework="net461" />
</packages>

View File

@@ -24,7 +24,10 @@ namespace LaDOSE.REST
public event EventHandler<UpdatedJwtEventHandler> UpdatedJwtEvent; public event EventHandler<UpdatedJwtEventHandler> UpdatedJwtEvent;
public RestService() { } public RestService()
{
}
public void Connect(Uri url, string user, string password) public void Connect(Uri url, string user, string password)
@@ -36,7 +39,7 @@ namespace LaDOSE.REST
#if DEBUG #if DEBUG
options.MaxTimeout = Int32.MaxValue; options.MaxTimeout = Int32.MaxValue;
#endif #endif
options.Authenticator = new JwtAuthenticator("token"); options.Authenticator = new JwtAuthenticator(token);
}); });
this.username = user; this.username = user;

View File

@@ -23,6 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaDOSE.REST", "LaDOSE.REST\
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinuxTest", "LinuxTest\LinuxTest.csproj", "{0EFA533F-9657-40CE-A3A5-F4E3C6E649B1}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinuxTest", "LinuxTest\LinuxTest.csproj", "{0EFA533F-9657-40CE-A3A5-F4E3C6E649B1}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaDOSE.DesktopApp.Avalonia", "LaDOSE.DesktopApp.Avalonia\LaDOSE.DesktopApp.Avalonia.csproj", "{1A3C654A-2730-42DA-B714-187169965A31}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -57,6 +59,10 @@ Global
{0EFA533F-9657-40CE-A3A5-F4E3C6E649B1}.Debug|Any CPU.Build.0 = Debug|Any CPU {0EFA533F-9657-40CE-A3A5-F4E3C6E649B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EFA533F-9657-40CE-A3A5-F4E3C6E649B1}.Release|Any CPU.ActiveCfg = Release|Any CPU {0EFA533F-9657-40CE-A3A5-F4E3C6E649B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EFA533F-9657-40CE-A3A5-F4E3C6E649B1}.Release|Any CPU.Build.0 = Release|Any CPU {0EFA533F-9657-40CE-A3A5-F4E3C6E649B1}.Release|Any CPU.Build.0 = Release|Any CPU
{1A3C654A-2730-42DA-B714-187169965A31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A3C654A-2730-42DA-B714-187169965A31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A3C654A-2730-42DA-B714-187169965A31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A3C654A-2730-42DA-B714-187169965A31}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE