Ready built Tournament Tracker

This commit is contained in:
2020-05-19 08:02:30 +02:00
parent 8040d47acb
commit 70a4f3cd42
2 changed files with 54 additions and 9 deletions

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TrackerLibrary;
using TrackerLibrary.Models;
namespace TrackerWPFUI.ViewModels
@ -12,6 +13,7 @@ namespace TrackerWPFUI.ViewModels
{
public TournamentModel Tournament { get; set; }
private string _tournamentName;
private BindableCollection<int> _rounds = new BindableCollection<int>();
private BindableCollection<MatchupModel> _matchups = new BindableCollection<MatchupModel>();
private bool _unplayedOnly;
@ -22,16 +24,24 @@ namespace TrackerWPFUI.ViewModels
private MatchupModel _selectedMatchup;
private int _selectedRound = 0;
public TournamentViewerViewModel(TournamentModel model)
{
Tournament = model;
TournamentName = model.TournamentName;
LoadRounds();
}
public string TournamentName
{
get {
return $"Tournament: {_tournamentName}" ;
}
set { _tournamentName = value;
NotifyOfPropertyChange(() => TournamentName);
}
}
public int SelectedRound
{
get { return _selectedRound; }
@ -103,15 +113,12 @@ namespace TrackerWPFUI.ViewModels
set { _matchups = value; }
}
public BindableCollection<int> Rounds
{
get { return _rounds; }
set { _rounds = value; }
}
private void LoadRounds()
{
Rounds.Clear();
@ -201,6 +208,42 @@ namespace TrackerWPFUI.ViewModels
//}
}
public void ScoreMatch()
{
for (int i = 0; i < SelectedMatchup.Entries.Count; i++)
{
if (i == 0)
{
if (SelectedMatchup.Entries[0].TeamCompeting != null)
{
SelectedMatchup.Entries[0].Score = TeamOneScore;
}
}
if (i == 1)
{
if (SelectedMatchup.Entries[1].TeamCompeting != null)
{
SelectedMatchup.Entries[1].Score = TeamTwoScore;
}
}
}
try
{
TournamentLogic.UpdateTournamentResults(Tournament);
}
catch (Exception ex)
{
System.Windows.MessageBox.Show($"The application had the following error :{ex.Message}");
return;
}
LoadMatchups();
}
}
}

View File

@ -35,7 +35,9 @@
SelectedItem="{Binding Path=SelectedTournament,Mode=OneWayToSource}"/>
<!--<TextBlock x:Name="SelectedTournament_TournamentName"/>-->
</StackPanel>
<ContentControl x:Name="ActiveItem" Grid.Row="2" Grid.Column="2"/>
<Border Grid.Row="2" Grid.Column="2" BorderThickness="1"
Margin="10 10 0 0" BorderBrush="Gray" >
<ContentControl x:Name="ActiveItem" Margin="5" />
</Border>
</Grid>
</Window>