Files
BCSH1-TournamentApp/TournamentOrganizer/Views/EventsView.axaml
T
2026-05-06 10:21:10 +02:00

144 lines
7.1 KiB
XML

<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.EventsView"
x:DataType="vm:EventsViewModel">
<Design.DataContext>
<vm:EventsViewModel />
</Design.DataContext>
<UserControl.Styles>
<Style Selector="Button.dropdown-item">
<Setter Property="Padding" Value="8,4"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
</Style>
<Style Selector="Button.dropdown-item:pointerover">
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundListLowBrush}"/>
</Style>
</UserControl.Styles>
<Grid RowDefinitions="Auto,*,Auto" ColumnDefinitions="*,*">
<TextBlock Grid.ColumnSpan="2" Grid.Row="0" Text="Events Management" FontSize="20" FontWeight="Bold" Margin="16,16,16,8"/>
<!-- Left Panel: Event List and Filter -->
<Border Grid.Column="0" Grid.Row="1" BorderBrush="Gray" BorderThickness="1" Margin="8" CornerRadius="4" Padding="8">
<DockPanel>
<!-- Header with New Event button -->
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,8">
<Button Command="{Binding CreateNewEventCommand}" DockPanel.Dock="Right" Padding="8,4">
<StackPanel Orientation="Horizontal" Spacing="4">
<TextBlock Text="+" FontSize="16" FontWeight="Bold" VerticalAlignment="Center"/>
<TextBlock Text="New Event" VerticalAlignment="Center"/>
</StackPanel>
</Button>
<TextBlock Text="Events" FontSize="16" FontWeight="SemiBold" VerticalAlignment="Center"/>
</DockPanel>
<!-- Filter -->
<StackPanel DockPanel.Dock="Top" Spacing="6" Margin="0,0,0,8">
<TextBlock Text="Filters" FontWeight="SemiBold" FontSize="12"/>
<TextBox Watermark="Filter by event name..." Text="{Binding FilterEventName}"/>
</StackPanel>
<!-- Event List -->
<ListBox ItemsSource="{Binding Events}"
SelectedItem="{Binding SelectedEvent}">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="vm:EventDisplay">
<StackPanel Spacing="2">
<TextBlock Text="{Binding Name}" FontWeight="SemiBold"/>
<TextBlock Text="{Binding Start, StringFormat='{}{0:d}'}" FontSize="11" Foreground="Gray"/>
<TextBlock Text="{Binding End, StringFormat='to {0:d}'}" FontSize="11" Foreground="Gray"/>
<ItemsControl ItemsSource="{Binding TournamentNames}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="x:String">
<TextBlock Text="{Binding, StringFormat='Game: {0}'}" FontSize="10" Foreground="#1976D2"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
</Border>
<!-- Right Panel: Event Editor -->
<Border Grid.Column="1" Grid.Row="1" BorderBrush="Gray" BorderThickness="1" Margin="8" CornerRadius="4" Padding="8">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="Event Details" FontSize="16" FontWeight="SemiBold" Margin="0,0,0,8"/>
<StackPanel DockPanel.Dock="Bottom" Spacing="6" Margin="0,8,0,0">
<Button Content="Save Event" Command="{Binding SaveEventCommand}" HorizontalAlignment="Stretch" IsEnabled="{Binding IsEditing}"/>
<Button Content="Delete Event" Command="{Binding DeleteEventCommand}" HorizontalAlignment="Stretch" IsEnabled="{Binding IsEditing}"/>
</StackPanel>
<ScrollViewer>
<StackPanel Spacing="8" IsEnabled="{Binding IsEditing}">
<!-- Event Name -->
<StackPanel Spacing="4">
<TextBlock Text="Event Name" FontWeight="SemiBold"/>
<TextBox Text="{Binding EventName}"/>
</StackPanel>
<!-- Start Date -->
<StackPanel Spacing="4">
<TextBlock Text="Start Date" FontWeight="SemiBold"/>
<CalendarDatePicker SelectedDate="{Binding EventStart}"/>
</StackPanel>
<!-- End Date -->
<StackPanel Spacing="4">
<TextBlock Text="End Date" FontWeight="SemiBold"/>
<CalendarDatePicker SelectedDate="{Binding EventEnd}"/>
</StackPanel>
<!-- Tournaments / Games Section -->
<StackPanel Spacing="4">
<TextBlock Text="Tournaments" FontWeight="SemiBold"/>
<!-- Add Game Dropdown -->
<Grid ColumnDefinitions="*,Auto" ColumnSpacing="4">
<ComboBox Grid.Column="0" ItemsSource="{Binding AvailableGamesToAdd}" SelectedItem="{Binding SelectedGameToAdd}">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="vm:GameOption">
<TextBlock Text="{Binding DisplayName}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Button Grid.Column="1" Content="Add" Command="{Binding AddGameToEventCommand}" IsEnabled="{Binding SelectedGameToAdd, Converter={x:Static ObjectConverters.IsNotNull}}" VerticalAlignment="Center"/>
</Grid>
<!-- Tournament List -->
<ListBox ItemsSource="{Binding Tournaments}"
SelectedItem="{Binding SelectedTournament}"
MinHeight="100"
MaxHeight="200">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="vm:TournamentDisplay">
<StackPanel Spacing="2">
<TextBlock Text="{Binding GameName}" FontWeight="SemiBold"/>
<TextBlock Text="{Binding S1RuleSetName, StringFormat='Stage 1: {0}'}" FontSize="11" Foreground="Gray"/>
<TextBlock Text="{Binding S2RuleSetName, StringFormat='Stage 2: {0}'}" FontSize="11" Foreground="Gray" IsVisible="{Binding S2RuleSet, Converter={x:Static ObjectConverters.IsNotNull}}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Content="Remove Selected" Command="{Binding RemoveGameFromEventCommand}" IsEnabled="{Binding SelectedTournament, Converter={x:Static ObjectConverters.IsNotNull}}" HorizontalAlignment="Left"/>
</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>