Started implementing CreateTournament View ande ViewModel

This commit is contained in:
2020-05-17 23:10:43 +02:00
parent 8ae6337c00
commit bcb1a561d4
5 changed files with 264 additions and 1 deletions

View File

@ -75,6 +75,7 @@
<Compile Include="ViewModels\CreatePersonViewModel.cs" /> <Compile Include="ViewModels\CreatePersonViewModel.cs" />
<Compile Include="ViewModels\CreatePrizeViewModel.cs" /> <Compile Include="ViewModels\CreatePrizeViewModel.cs" />
<Compile Include="ViewModels\CreateTeamViewModel.cs" /> <Compile Include="ViewModels\CreateTeamViewModel.cs" />
<Compile Include="ViewModels\CreateTournamentViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" /> <Compile Include="ViewModels\ShellViewModel.cs" />
<Compile Include="Views\CreatePersonView.xaml.cs"> <Compile Include="Views\CreatePersonView.xaml.cs">
<DependentUpon>CreatePersonView.xaml</DependentUpon> <DependentUpon>CreatePersonView.xaml</DependentUpon>
@ -85,6 +86,9 @@
<Compile Include="Views\CreateTeamView.xaml.cs"> <Compile Include="Views\CreateTeamView.xaml.cs">
<DependentUpon>CreateTeamView.xaml</DependentUpon> <DependentUpon>CreateTeamView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\CreateTournamentView.xaml.cs">
<DependentUpon>CreateTournamentView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ShellView.xaml.cs"> <Compile Include="Views\ShellView.xaml.cs">
<DependentUpon>ShellView.xaml</DependentUpon> <DependentUpon>ShellView.xaml</DependentUpon>
</Compile> </Compile>
@ -104,6 +108,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\CreateTournamentView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ShellView.xaml"> <Page Include="Views\ShellView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>

View File

@ -0,0 +1,150 @@
using Caliburn.Micro;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TrackerLibrary.Models;
namespace TrackerWPFUI.ViewModels
{
public class CreateTournamentViewModel : Conductor<object>.Collection.AllActive
{
private string _tournamentName;
private decimal _entryFee;
private BindableCollection<TeamModel> _availableTeams;
private TeamModel _selectedTeamToAdd;
private BindableCollection<TeamModel> _selectedTeams;
private TeamModel _selectedTeamToRemove;
private Screen _activeAddTeamView;
private BindableCollection<PrizeModel> _selectedPrizes;
private PrizeModel _selectedPrizeToRemove;
private Screen _activAddPrizeView;
public string TournamentName
{
get { return _tournamentName; }
set { _tournamentName = value;
NotifyOfPropertyChange(() => TournamentName);
}
}
public decimal EntryFee
{
get { return _entryFee; }
set { _entryFee = value;
NotifyOfPropertyChange(() => EntryFee);
}
}
public BindableCollection<TeamModel> AvailableTeams
{
get { return _availableTeams; }
set { _availableTeams = value; }
}
public TeamModel SelectedTeamToAdd
{
get { return _selectedTeamToAdd; }
set { _selectedTeamToAdd = value;
NotifyOfPropertyChange(() => SelectedTeamToAdd);
}
}
public BindableCollection<TeamModel> SelectedTeams
{
get { return _selectedTeams; }
set { _selectedTeams = value;}
}
public TeamModel SelectedTeamToRemove
{
get { return _selectedTeamToRemove; }
set { _selectedTeamToRemove = value;
NotifyOfPropertyChange(() => SelectedTeamToRemove);
}
}
public Screen ActiveAddTeamView
{
get { return _activeAddTeamView; }
set { _activeAddTeamView = value;
NotifyOfPropertyChange(() => ActiveAddTeamView);
}
}
public BindableCollection<PrizeModel> SelectedPrizes
{
get { return _selectedPrizes; }
set { _selectedPrizes = value; }
}
public PrizeModel SelectedPrizeToRemove
{
get { return _selectedPrizeToRemove; }
set { _selectedPrizeToRemove = value;
NotifyOfPropertyChange(() => SelectedPrizeToRemove);
}
}
public Screen ActiveAddPrizeView
{
get { return _activAddPrizeView; }
set { _activAddPrizeView = value;
NotifyOfPropertyChange(() => ActiveAddPrizeView);
}
}
public bool CanAddTeam()
{
return SelectedTeamToAdd != null;
}
public void AddTeams()
{
}
public void CreateTeam()
{
}
public bool CanRemoveTeam()
{
return SelectedTeamToRemove != null;
}
public void RemoveTeam()
{
}
public void CreatePrize()
{
}
public bool CanRemovePrize()
{
return SelectedPrizeToRemove != null;
}
public void RemovePrize()
{
}
public bool CanCreateTournament()
{
//ToDo - Add logic for createing the tournament
return true;
}
public void CreateTournament()
{
}
}
}

View File

@ -18,8 +18,9 @@ namespace TrackerWPFUI.ViewModels
GlobalConfig.InitializeConnections(DatabaseType.Sql); GlobalConfig.InitializeConnections(DatabaseType.Sql);
_existingTournaments = new BindableCollection<TournamentModel>(GlobalConfig.Connection.GetTournament_All()); _existingTournaments = new BindableCollection<TournamentModel>(GlobalConfig.Connection.GetTournament_All());
//ActivateItem(new CreatePrizeViewModel()); //ActivateItem(new CreatePrizeViewModel());
ActivateItem(new CreateTeamViewModel()); //ActivateItem(new CreateTeamViewModel());
//ActivateItem(new CreatePersonViewModel()); //ActivateItem(new CreatePersonViewModel());
ActivateItem(new CreateTournamentViewModel());
} }
public void CreateTournament() public void CreateTournament()
{ {

View File

@ -0,0 +1,76 @@
<UserControl x:Class="TrackerWPFUI.Views.CreateTournamentView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:TrackerWPFUI.Views"
mc:Ignorable="d" Background="White"
d:DesignHeight="500" d:DesignWidth="600">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Row 0 -->
<TextBlock FontSize="28" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Center">Create Tournament</TextBlock>
<!-- Row 1 -->
<StackPanel Orientation="Vertical" Grid.Column="0" Grid.Row="1" Margin="0 10 10 10">
<TextBlock FontSize="22" >General Info</TextBlock>
<TextBlock Margin="5 0 5 5">Tournament Name</TextBlock>
<TextBox x:Name="TournamentName" Margin="5 0 5 10 "></TextBox>
<TextBlock Margin="5 0 5 5">Entry Fee</TextBlock>
<TextBox x:Name="EntryFee" Margin="5 0 5 10 "></TextBox>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="1" Margin="0 10">
<TextBlock FontSize="22" >Teams Section</TextBlock>
<TextBox x:Name="TeamName" Margin="5 0 5 10 "></TextBox>
<TextBlock Margin="5 0 5 5">Select Team</TextBlock>
<ComboBox x:Name="AvailableTeams" Margin="5 0 5 10"
SelectedItem="{Binding Path=SelectedTeamToAdd, Mode=OneWayToSource}"
DisplayMemberPath="TeamName"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button x:Name="AddTeam" Padding="5" Margin="0 0 5 0">Add Team</Button>
<Button x:Name="CreateTeam" Padding="5" >Create Team</Button>
<Button x:Name="RemoveTeam" Padding="5" Margin="5 0 0 0">Remove Team</Button>
</StackPanel>
<StackPanel x:Name="SelectedTeamsIsVisible" Orientation="Vertical" Margin="5 10 5 0">
<TextBlock Margin="0 0 0 10" >Selected Teams</TextBlock>
<ListBox x:Name="SelectedTeams" DisplayMemberPath="TeamName"
MinHeight="20"
SelectedItem="{Binding Path=SelectedTeamToRemove, Mode=TwoWay}" />
</StackPanel>
<StackPanel x:Name="AddTeamIsVisible" Orientation="Vertical" Margin="5 10 5 0">
<ContentControl x:Name="ActiveAddTeamView"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="2" Grid.Row="1" Margin="10 10 0 10">
<TextBlock FontSize="22" >Prizes Section</TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button x:Name="CreatePrize" Padding="5" Margin="0 0 5 0">Create Prize</Button>
<Button x:Name="RemovePrize" Padding="5" Margin="5 0 0 0">Remove Prize</Button>
</StackPanel>
<StackPanel x:Name="SelectedPrizesIsVisible" Orientation="Vertical" Margin="5 10 5 0">
<TextBlock Margin="0 0 0 10" >Selected Teams</TextBlock>
<ListBox x:Name="SelectedPrizes" DisplayMemberPath="PrizeName"
MinHeight="20"
SelectedItem="{Binding Path=SelectedPrizeToRemove, Mode=TwoWay}" />
</StackPanel>
<StackPanel x:Name="AddPrizeIsVisible" Orientation="Vertical" Margin="5 10 5 0">
<ContentControl x:Name="ActiveAddPrizeView"/>
</StackPanel>
</StackPanel>
<!--Row 2-->
<Button x:Name="CreateTournament" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="3"
Padding="10" Margin="0 0 0 10">
Create Tournament
</Button>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace TrackerWPFUI.Views
{
/// <summary>
/// Interaction logic for CreateTournamentView.xaml
/// </summary>
public partial class CreateTournamentView : UserControl
{
public CreateTournamentView()
{
InitializeComponent();
}
}
}