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

@@ -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

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
namespace LaDOSE.DesktopApp.Avalonia.Utils
{
public static class CustomListExtension
{
public sealed class EqualityComparer<T> : IEqualityComparer<T> where T : class
{
private readonly Func<T, T, bool> _compare;
public EqualityComparer(Func<T, T, bool> c)
{
_compare = c;
}
public bool Equals(T x, T y)
{
return _compare(x, y);
}
public int GetHashCode(T obj)
{
return 0;
}
}
}
}

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

@@ -0,0 +1,561 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using Avalonia.Collections;
using Avalonia.Controls;
using LaDOSE.DesktopApp.Avalonia.Utils;
using LaDOSE.DTO;
using LaDOSE.REST;
using ReactiveUI;
using Splat;
namespace LaDOSE.DesktopApp.Avalonia.ViewModels
{
public class TournamentResultViewModel : BaseViewModel
{
public string DisplayName => "Tournament Result";
private RestService RestService { get; set; }
//Dictionary<string, Dictionary<int, int>> _computedResult;
#region Properties
private string css = string.Empty;
private String _selectRegex;
public String SelectRegex
{
get { return _selectRegex; }
set
{
_selectRegex = value;
RaisePropertyChanged(nameof(SelectRegex));
}
}
private String _selectEventRegex;
public String SelectEventRegex
{
get { return _selectEventRegex; }
set
{
_selectEventRegex = value;
RaisePropertyChanged(nameof(SelectEventRegex));
}
}
private string _slug;
public String Slug
{
get { return _slug; }
set
{
_slug = value;
RaisePropertyChanged(nameof(Slug));
}
}
private String _html;
public String Html
{
get { return $"<html><head><style>{this.css}</style></head><body>{HtmlContent}</body></html>"; }
set
{
_html = value;
}
}
private String _htmlContent;
public String HtmlContent
{
get { return _htmlContent; }
set
{
_htmlContent = value;
RaisePropertyChanged(nameof(HtmlContent));
RaisePropertyChanged(nameof(Html));
}
}
private DateTimeOffset _from;
public DateTimeOffset From
{
get { return _from; }
set
{
_from = value;
RaisePropertyChanged(nameof(From));
}
}
private DateTimeOffset _to;
public DateTimeOffset To
{
get { return _to; }
set
{
_to = value;
RaisePropertyChanged(nameof(To));
}
}
private TournamentsResultDTO _results;
public List<TournamentDTO> Tournaments { get; set; }
public List<EventDTO> Events { get; set; }
public TournamentsResultDTO Results
{
get => _results;
set
{
_results = value;
RaisePropertyChanged(nameof(Results));
}
}
private ObservableCollection<EventDTO> _selectedEvents;
public ObservableCollection<EventDTO> SelectedEvents
{
get { return _selectedEvents; }
set
{
_selectedEvents = value;
RaisePropertyChanged(nameof(SelectedEvents));
}
}
private ObservableCollection<TournamentDTO> _selectedTournaments;
public ObservableCollection<TournamentDTO> SelectedTournaments
{
get { return _selectedTournaments; }
set
{
_selectedTournaments = value;
RaisePropertyChanged(nameof(SelectedTournaments));
}
}
private GameDTO _selectedGame;
public GameDTO SelectedGame
{
get { return _selectedGame; }
set
{
_selectedGame = value;
//TODO: QUICK AND DIRTY
List<ResultDTO> resultForGame = this.Results.Results.Where(e => e.GameId == SelectedGame?.Id).ToList();
if (resultForGame.Any())
{
First = resultForGame.OrderByDescending(e => e.Point).First().Player;
SelectedGameResult = new ObservableCollection<ResultDTO>(resultForGame);
}
RaisePropertyChanged(nameof(SelectedGame));
}
}
private ObservableCollection<ResultDTO> _selectedGameResult;
public ObservableCollection<ResultDTO> SelectedGameResult
{
get { return _selectedGameResult; }
set
{
_selectedGameResult = value;
RaisePropertyChanged(nameof(SelectedGameResult));
}
}
private String _first;
private DataTable _gridDataTable;
private string _error;
public String First
{
get { return _first; }
set
{
_first = value;
RaisePropertyChanged(nameof(First));
}
}
#endregion
public TournamentResultViewModel(IScreen hostScreen):base(hostScreen,"Tournament")
{
this.RestService = Locator.Current.GetService<RestService>();;
_selectedTournaments = new ObservableCollection<TournamentDTO>();
_selectedEvents = new ObservableCollection<EventDTO>();
Tournaments = new List<TournamentDTO>();
Events = new List<EventDTO>();
OnInitialize();
}
protected void OnInitialize()
{
// var manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LaDOSE.DesktopApp.Resources.css.css");
// using (var sr = new StreamReader(manifestResourceStream))
// {
// this.css = sr.ReadToEnd();
// }
this.To = new DateTimeOffset(DateTime.Now);
this.From = new DateTimeOffset(DateTime.Now.AddMonths(-1));
this.SelectRegex = "Ranking";
this.SelectEventRegex = @"Ranking #10\d{2}";
this.Slug = "ranking-1001";
LoadTournaments();
LoadEvents();
}
public void LoadTournaments()
{
// var tournamentDtos = this.RestService
// .GetTournaments(new TimeRangeDTO() {From = this.From, To = this.To}).ToList();
// this.Tournaments = tournamentDtos;
RaisePropertyChanged(nameof(Tournaments));
}
public void LoadEvents()
{
var eventsDtos = this.RestService
.GetAllEvents().ToList();
this.Events = eventsDtos;
RaisePropertyChanged(nameof(Events));
}
public DataTable GridDataTable
{
get => _gridDataTable;
set
{
_gridDataTable = value;
RaisePropertyChanged(nameof(GridDataTable));
RaisePropertyChanged(nameof(GridDataTableView));
}
}
public DataView GridDataTableView
{
get
{
DataView gridDataTableView = _gridDataTable?.AsDataView();
return gridDataTableView;
}
}
public void Select()
{
var tournamentsIds = SelectedEvents.Select(e => e.Id).ToList();
var resultsDto = this.RestService.GetResults(tournamentsIds);
this.Results = resultsDto;
ComputeDataGrid();
ComputeHtml();
}
public void GetSmash()
{
var resultsDto = this.RestService.ParseSmash(Slug);
if (!resultsDto)
{
Error = "Error getting Smash";
}
}
public string Error
{
get => _error;
set
{
if (value == _error) return;
_error = value;
RaisePropertyChanged();
}
}
public void GetChallonge()
{
var ids = SelectedTournaments.Select(e => e.ChallongeId).ToList();
var resultsDto = this.RestService.ParseChallonge(ids);
if (!resultsDto)
{
Error = "Fail";
}
}
public void UpdateEvent()
{
LoadEvents();
}
public void SelectYear()
{
this.To = DateTime.Now;
this.From = new DateTime(DateTime.Now.Year, 1, 1);
}
public void SelectMonth()
{
this.To = DateTime.Now;
this.From = DateTime.Now.AddMonths(-1);
}
public void SelectRegexp()
{
var selectedTournaments = this.Tournaments.Where(e => Regex.IsMatch(e.Name, this.SelectRegex)).ToList();
this.SelectedTournaments.Clear();
if (selectedTournaments.Count > 0)
selectedTournaments.ForEach(e => this.SelectedTournaments.Add(e));
}
public void SelectEvent()
{
var selectedEvents = this.Events.Where(e => Regex.IsMatch(e.Name, this.SelectEventRegex)).ToList();
this.SelectedEvents.Clear();
if (selectedEvents.Count > 0)
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.
private void ComputeDataGrid()
{
var resultsParticipents = this.Results.Participents.Select(e=>e.Name).Distinct(new CustomListExtension.EqualityComparer<String>((a, b) => a.ToUpperInvariant()== b.ToUpperInvariant())).OrderBy(e=>e).ToList();
//At start the dictionnary was for some fancy dataviz things, but since the point are inside
//i m to lazy to rewrite this functions (this is so ugly...)
//_computedResult = ResultsToDataDictionary(resultsParticipents);
StringBuilder sb = new StringBuilder();
DataTable grid = new DataTable();
var games = Results.Games.Distinct().OrderBy(e => e.Order).ToList();
grid.Columns.Add("Players");
games.ForEach(e => grid.Columns.Add(e.Name.Replace('.', ' '),typeof(Int32)));
grid.Columns.Add("Total").DataType = typeof(Int32);
for (int i = 0; i < resultsParticipents.Count; i++)
{
var dataRow = grid.Rows.Add();
var resultsParticipent = resultsParticipents[i];
int total = 0;
dataRow["Players"] = resultsParticipent;
for (int j = 0; j < games.Count; j++)
{
var resultsGame = Results.Games[j];
var points = GetPlayerPoint(resultsParticipent, resultsGame.Id);
dataRow[resultsGame.Name.Replace('.', ' ')] = points!=0?points:0;
total += points;
}
dataRow["Total"] = total;
}
grid.DefaultView.Sort = "Total DESC";
this.GridDataTable = grid;
}
public void Export()
{
if (this.Results == null)
return;
ExportToCSV();
}
private void ExportToCSV()
{
// if (this.GridDataTable != null)
// {
// var dataTable = this.GridDataTable.DefaultView.ToTable();
// SaveFileDialog sfDialog = new SaveFileDialog()
// {
// Filter = "Csv Files (*.csv)|*.csv|All Files (*.*)|*.*",
// AddExtension = true
// };
// if (sfDialog.ShowDialog() == true)
// {
// StringBuilder sb = new StringBuilder();
//
// IEnumerable<string> columnNames = dataTable.Columns.Cast<DataColumn>()
// .Select(column => column.ColumnName);
// sb.AppendLine(string.Join(";", columnNames));
//
// foreach (DataRow row in dataTable.Rows)
// {
// //EXCEL IS A BITCH
// IEnumerable<string> fields = row.ItemArray.Select(field =>
// string.Concat("\"", field.ToString().Replace("\"", "\"\""), "\""));
// sb.AppendLine(string.Join(";", fields));
// }
//
// File.WriteAllText(sfDialog.FileName, sb.ToString());
// }
// }
}
private void ComputeHtml()
{
StringBuilder sb = new StringBuilder();
sb.Append("<table class=\"table table-responsive-md table-dark table-striped mt-lg-4 mt-3\">");
int columns = 0;
var distinct = Results.Results.Select(e => e.GameId).Distinct();
var gamePlayed = Results.Games.Where(e=> distinct.Contains(e.Id)).OrderBy(e=>e.Order);
foreach (var game in gamePlayed)
{
List<ResultDTO> enumerable = Results.Results.Where(r => r.GameId == game.Id).ToList();
List<string> top3 = enumerable.OrderBy(e => e.Rank).Take(3).Select(e => e.Player).ToList();
if (top3.Count == 0)
{
continue;
}
if (columns % 2 == 0)
{
sb.Append("<tr>");
}
columns++;
var span = 1;
if (columns == gamePlayed.Count())
{
if (columns % 2 != 0)
{
span = 2;
}
}
sb.Append($"<td colspan=\"{span}\" width=\"50%\">" +
"<span style=\"color: #ff0000;\">" +
$"<strong>{game.LongName} ({Results.Results.Count(e => e.GameId == game.Id)} participants) :</strong>" +
"</span>");
if (top3.Count >= 3)
{
sb.AppendLine($"<br> 1/ {top3[0]}<br> 2/ {top3[1]}<br> 3/ {top3[2]} <br>");
//<a href=\"https://challonge.com/fr/{enumerable.First().TournamentUrl}\" target=\"_blank\">https://challonge.com/fr/{enumerable.First().TournamentUrl}</a>
var url = enumerable.FirstOrDefault().TournamentUrl;
url = url.Replace(" ", "-");
url = url.Replace(".", "-");
sb.AppendLine($"<a href=\"https://smash.gg/tournament/ranking-1002/event/{url}\" target=\"_blank\">Voir le Bracket</p></td>");
}
if (columns % 2 == 0)
{
sb.Append("</tr>");
}
}
sb.Append("</table>");
this.HtmlContent = sb.ToString();
}
public void CopyHtml()
{
// System.Windows.Clipboard.SetText(this.HtmlContent);
}
private int GetPlayerPoint(string name, int gameid)
{
return Results.Results.Where(e => e.GameId == gameid && e.Player.ToUpperInvariant() == name.ToUpperInvariant()).Sum(e=>e.Point);
}
// private Dictionary<string, Dictionary<int, int>> ResultsToDataDictionary(
// List<ParticipentDTO> resultsParticipents)
// {
// var computed = new Dictionary<string, Dictionary<int, int>>();
// foreach (var participent in resultsParticipents)
// {
// computed.Add(participent.Name, new Dictionary<int, int>());
// }
// foreach (var game in Results.Games)
// {
// var results = Results.Results.Where(e => e.GameId == game.Id).ToList();
// foreach (var result in results)
// {
// var dictionary = computed[result.Player];
// if (dictionary.ContainsKey(result.GameId))
// dictionary[game.Id] += result.Point;
// else
// {
// dictionary.Add(game.Id, result.Point);
// }
// }
// }
// MergeDuplicates(resultsParticipents, computed);
// return computed;
// }
// private static void MergeDuplicates(List<ParticipentDTO> resultsParticipents, Dictionary<string, Dictionary<int, int>> computed)
// {
// var duplicates = computed.Keys.ToList().GroupBy(x => x.ToUpperInvariant()).Where(x => x.Count() > 1)
// .Select(x => x.Key)
// .ToList();
// if (duplicates.Count > 0)
// {
// foreach (var duplicate in duplicates)
// {
// var lines = computed.Where(e => e.Key.ToUpperInvariant() == duplicate).ToList();
// for (int i = lines.Count(); i > 1; --i)
// {
// var result = lines[--i];
// foreach (var games in result.Value.Keys)
// {
// if (lines[0].Value.ContainsKey(games))
// lines[0].Value[games] += result.Value[games];
// else
// lines[0].Value.Add(games, result.Value[games]);
// }
// computed.Remove(result.Key);
// resultsParticipents.Remove(resultsParticipents.First(e => e.Name == result.Key));
// }
// }
// }
// }
}
}

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>