Match management view
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
<Button Content="Events" Command="{Binding NavigateToEventsCommand}" Padding="16,8" FontSize="14" Foreground="White" Background="Transparent" BorderThickness="0"/>
|
||||
<Button Content="Games" Command="{Binding NavigateToGamesCommand}" Padding="16,8" FontSize="14" Foreground="White" Background="Transparent" BorderThickness="0"/>
|
||||
<Button Content="Tournaments" Command="{Binding NavigateToTournamentsCommand}" Padding="16,8" FontSize="14" Foreground="White" Background="Transparent" BorderThickness="0"/>
|
||||
<Button Content="Matches" Command="{Binding NavigateToMatchesCommand}" Padding="16,8" FontSize="14" Foreground="White" Background="Transparent" BorderThickness="0"/>
|
||||
<Button Content="Teams" Command="{Binding NavigateToTeamsCommand}" Padding="16,8" FontSize="14" Foreground="White" Background="Transparent" BorderThickness="0"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
<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"
|
||||
xmlns:vm="using:TournamentOrganizer.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="600"
|
||||
x:Class="TournamentOrganizer.Views.MatchesView"
|
||||
x:DataType="vm:MatchesViewModel">
|
||||
<Design.DataContext>
|
||||
<vm:MatchesViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
<UserControl.Styles>
|
||||
<Style Selector="ListBoxItem.dropdown-item">
|
||||
<Setter Property="Padding" Value="8,4"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
</Style>
|
||||
<Style Selector="ListBoxItem.dropdown-item:selected">
|
||||
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundListLowBrush}"/>
|
||||
</Style>
|
||||
<Style Selector="ListBoxItem.dropdown-item:pointerover">
|
||||
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundListLowBrush}"/>
|
||||
</Style>
|
||||
<Style Selector="Button.dropdown-action">
|
||||
<Setter Property="Padding" Value="8,4"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left"/>
|
||||
</Style>
|
||||
<Style Selector="Button.dropdown-action:pointerover">
|
||||
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundListLowBrush}"/>
|
||||
</Style>
|
||||
</UserControl.Styles>
|
||||
|
||||
<Grid RowDefinitions="Auto,*,Auto" ColumnDefinitions="*,*">
|
||||
<TextBlock Grid.ColumnSpan="2" Grid.Row="0" Text="Match Management" FontSize="20" FontWeight="Bold" Margin="16,16,16,8"/>
|
||||
|
||||
<!-- Left Panel: Filters and Matches -->
|
||||
<Border Grid.Column="0" Grid.Row="1" BorderBrush="Gray" BorderThickness="1" Margin="8" CornerRadius="4" Padding="8">
|
||||
<DockPanel>
|
||||
<TextBlock DockPanel.Dock="Top" Text="Matches" FontSize="16" FontWeight="SemiBold" Margin="0,0,0,8"/>
|
||||
|
||||
<!-- Filters -->
|
||||
<StackPanel DockPanel.Dock="Top" Spacing="6" Margin="0,0,0,8">
|
||||
<TextBlock Text="Filters" FontWeight="SemiBold" FontSize="12"/>
|
||||
|
||||
<!-- Event Filter Dropdown -->
|
||||
<Panel Name="EventFilterPanel">
|
||||
<ToggleButton Name="EventFilterToggle" HorizontalContentAlignment="Left" HorizontalAlignment="Stretch" Padding="8,6"
|
||||
IsChecked="{Binding IsEventDropdownOpen}">
|
||||
<ToggleButton.Template>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border Background="{TemplateBinding Background}" BorderBrush="Gray" BorderThickness="1" CornerRadius="4">
|
||||
<ContentPresenter Content="{TemplateBinding Content}" Margin="{TemplateBinding Padding}" HorizontalAlignment="Left"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</ToggleButton.Template>
|
||||
<ToggleButton.Content>
|
||||
<Panel>
|
||||
<TextBlock Text="{Binding SelectedEvent.DisplayName, Mode=OneWay}" IsVisible="{Binding SelectedEvent, Converter={x:Static ObjectConverters.IsNotNull}}"/>
|
||||
<TextBlock Text="Select an event..." Foreground="Gray" IsVisible="{Binding SelectedEvent, Converter={x:Static ObjectConverters.IsNull}}"/>
|
||||
</Panel>
|
||||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
<Popup IsOpen="{Binding IsEventDropdownOpen}" PlacementTarget="{Binding #EventFilterToggle}" Width="{Binding Bounds.Width, ElementName=EventFilterToggle}">
|
||||
<Border Background="{DynamicResource SystemControlBackgroundChromeMediumBrush}" BorderBrush="Gray" BorderThickness="1" CornerRadius="4">
|
||||
<DockPanel MaxHeight="200">
|
||||
<TextBox DockPanel.Dock="Top" Text="{Binding EventFilterSearch}" Watermark="Search events..." Margin="4" Padding="6,4"/>
|
||||
<Button DockPanel.Dock="Bottom" Content="All" Classes="dropdown-action" Foreground="Gray" Margin="4,0,4,4"
|
||||
Click="OnClearEventFilter"/>
|
||||
<ListBox ItemsSource="{Binding FilteredEvents}" MaxHeight="160" SelectionMode="Single" Classes="dropdown-item"
|
||||
SelectionChanged="OnEventSelectionChanged">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:EventOption">
|
||||
<TextBlock Text="{Binding DisplayName}"/>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
</Popup>
|
||||
</Panel>
|
||||
|
||||
<!-- Tournament Filter Dropdown -->
|
||||
<Panel Name="TournamentFilterPanel">
|
||||
<ToggleButton Name="TournamentFilterToggle" HorizontalContentAlignment="Left" HorizontalAlignment="Stretch" Padding="8,6"
|
||||
IsChecked="{Binding IsTournamentDropdownOpen}" IsEnabled="{Binding IsTournamentFilterEnabled}">
|
||||
<ToggleButton.Template>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border Background="{TemplateBinding Background}" BorderBrush="Gray" BorderThickness="1" CornerRadius="4">
|
||||
<ContentPresenter Content="{TemplateBinding Content}" Margin="{TemplateBinding Padding}" HorizontalAlignment="Left"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</ToggleButton.Template>
|
||||
<ToggleButton.Content>
|
||||
<Panel>
|
||||
<TextBlock Text="{Binding SelectedTournament.DisplayName, Mode=OneWay}" IsVisible="{Binding SelectedTournament, Converter={x:Static ObjectConverters.IsNotNull}}"/>
|
||||
<TextBlock Text="Select an event first..." Foreground="Gray" IsVisible="{Binding SelectedTournament, Converter={x:Static ObjectConverters.IsNull}}"/>
|
||||
</Panel>
|
||||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
<Popup IsOpen="{Binding IsTournamentDropdownOpen}" PlacementTarget="{Binding #TournamentFilterToggle}" Width="{Binding Bounds.Width, ElementName=TournamentFilterToggle}">
|
||||
<Border Background="{DynamicResource SystemControlBackgroundChromeMediumBrush}" BorderBrush="Gray" BorderThickness="1" CornerRadius="4">
|
||||
<DockPanel MaxHeight="200">
|
||||
<TextBox DockPanel.Dock="Top" Text="{Binding TournamentFilterSearch}" Watermark="Search tournaments..." Margin="4" Padding="6,4"/>
|
||||
<Button DockPanel.Dock="Bottom" Content="All" Classes="dropdown-action" Foreground="Gray" Margin="4,0,4,4"
|
||||
Click="OnClearTournamentFilter"/>
|
||||
<ListBox ItemsSource="{Binding FilteredTournaments}" MaxHeight="160" SelectionMode="Single" Classes="dropdown-item"
|
||||
SelectionChanged="OnTournamentSelectionChanged">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:TournamentOption">
|
||||
<TextBlock Text="{Binding DisplayName}"/>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
</Popup>
|
||||
</Panel>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Matches List -->
|
||||
<ListBox ItemsSource="{Binding Matches}"
|
||||
SelectedItem="{Binding SelectedMatch}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:MatchDisplay">
|
||||
<StackPanel Spacing="2">
|
||||
<TextBlock Text="{Binding TeamsText}" FontWeight="SemiBold"/>
|
||||
<TextBlock Text="{Binding State}" FontSize="11" Foreground="Gray"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Right Panel: Match Details -->
|
||||
<Border Grid.Column="1" Grid.Row="1" BorderBrush="Gray" BorderThickness="1" Margin="8" CornerRadius="4" Padding="8"
|
||||
IsVisible="{Binding SelectedMatch, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<DockPanel>
|
||||
<TextBlock DockPanel.Dock="Top" Text="Match Details" FontSize="16" FontWeight="SemiBold" Margin="0,0,0,8"/>
|
||||
|
||||
<ScrollViewer>
|
||||
<StackPanel Spacing="12">
|
||||
<!-- Teams and Scores -->
|
||||
<StackPanel Spacing="4">
|
||||
<TextBlock Text="Teams" FontWeight="SemiBold"/>
|
||||
<ItemsControl ItemsSource="{Binding MatchTeams}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:TeamParticipantDisplay">
|
||||
<Grid ColumnDefinitions="*,Auto,Auto" Margin="0,4,0,0">
|
||||
<TextBlock Grid.Column="0" Text="{Binding TeamName}" FontWeight="SemiBold"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Score, StringFormat='Score: {0}'}" Margin="8,0"/>
|
||||
<TextBlock Grid.Column="2" Text="{Binding Seed, StringFormat='#{0}'}" Foreground="Gray"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Rounds -->
|
||||
<StackPanel Spacing="4">
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<TextBlock Grid.Column="0" Text="Rounds" FontWeight="SemiBold"/>
|
||||
<Button Grid.Column="1" Content="Create Round" Command="{Binding CreateRoundCommand}"
|
||||
IsEnabled="{Binding CanCreateRound}"/>
|
||||
</Grid>
|
||||
|
||||
<ListBox ItemsSource="{Binding Rounds}"
|
||||
SelectedItem="{Binding SelectedRound}"
|
||||
MinHeight="60">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:RoundDisplay">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<TextBlock Text="{Binding Id, StringFormat='Round #{0}'}" FontWeight="SemiBold"/>
|
||||
<TextBlock Text="{Binding State}" Foreground="Gray"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Round Actions -->
|
||||
<StackPanel Spacing="4" IsVisible="{Binding SelectedRound, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<TextBlock Text="Round Actions" FontWeight="SemiBold"/>
|
||||
|
||||
<Button Content="Start Round" Command="{Binding StartRoundCommand}"
|
||||
IsEnabled="{Binding CanStartRound}" HorizontalAlignment="Stretch"/>
|
||||
|
||||
<TextBlock Text="Award Victory:" FontSize="12" Foreground="Gray"/>
|
||||
<Grid ColumnDefinitions="*,*" ColumnSpacing="4">
|
||||
<Button Grid.Column="0" Content="{Binding MatchTeams[0].TeamName, StringFormat='Victory: {0}'}"
|
||||
Command="{Binding AwardVictoryCommand}"
|
||||
CommandParameter="0"
|
||||
IsEnabled="{Binding CanAwardVictory}"/>
|
||||
<Button Grid.Column="1" Content="{Binding MatchTeams[1].TeamName, StringFormat='Victory: {0}'}"
|
||||
Command="{Binding AwardVictoryCommand}"
|
||||
CommandParameter="1"
|
||||
IsEnabled="{Binding CanAwardVictory}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Status Bar -->
|
||||
<TextBlock Grid.ColumnSpan="2" Grid.Row="2" Text="{Binding StatusMessage}" Margin="8" Foreground="Gray" FontSize="12"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,53 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using TournamentOrganizer.ViewModels;
|
||||
|
||||
namespace TournamentOrganizer.Views;
|
||||
|
||||
public partial class MatchesView : UserControl
|
||||
{
|
||||
public MatchesView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnEventSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (sender is ListBox { SelectedItem: EventOption option } && DataContext is MatchesViewModel vm)
|
||||
{
|
||||
vm.SelectEventFilter(option);
|
||||
if (EventFilterToggle != null)
|
||||
EventFilterToggle.IsChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTournamentSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (sender is ListBox { SelectedItem: TournamentOption option } && DataContext is MatchesViewModel vm)
|
||||
{
|
||||
vm.SelectTournamentFilter(option);
|
||||
if (TournamentFilterToggle != null)
|
||||
TournamentFilterToggle.IsChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClearEventFilter(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is MatchesViewModel vm)
|
||||
{
|
||||
vm.ClearEventFilter();
|
||||
if (EventFilterToggle != null)
|
||||
EventFilterToggle.IsChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClearTournamentFilter(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is MatchesViewModel vm)
|
||||
{
|
||||
vm.ClearTournamentFilter();
|
||||
if (TournamentFilterToggle != null)
|
||||
TournamentFilterToggle.IsChecked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user