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.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TrackerLibrary;
using TrackerLibrary.Models; using TrackerLibrary.Models;
namespace TrackerWPFUI.ViewModels namespace TrackerWPFUI.ViewModels
@ -12,6 +13,7 @@ namespace TrackerWPFUI.ViewModels
{ {
public TournamentModel Tournament { get; set; } public TournamentModel Tournament { get; set; }
private string _tournamentName;
private BindableCollection<int> _rounds = new BindableCollection<int>(); private BindableCollection<int> _rounds = new BindableCollection<int>();
private BindableCollection<MatchupModel> _matchups = new BindableCollection<MatchupModel>(); private BindableCollection<MatchupModel> _matchups = new BindableCollection<MatchupModel>();
private bool _unplayedOnly; private bool _unplayedOnly;
@ -22,16 +24,24 @@ namespace TrackerWPFUI.ViewModels
private MatchupModel _selectedMatchup; private MatchupModel _selectedMatchup;
private int _selectedRound = 0; private int _selectedRound = 0;
public TournamentViewerViewModel(TournamentModel model) public TournamentViewerViewModel(TournamentModel model)
{ {
Tournament = model; Tournament = model;
TournamentName = model.TournamentName;
LoadRounds(); LoadRounds();
} }
public string TournamentName
{
get {
return $"Tournament: {_tournamentName}" ;
}
set { _tournamentName = value;
NotifyOfPropertyChange(() => TournamentName);
}
}
public int SelectedRound public int SelectedRound
{ {
get { return _selectedRound; } get { return _selectedRound; }
@ -103,15 +113,12 @@ namespace TrackerWPFUI.ViewModels
set { _matchups = value; } set { _matchups = value; }
} }
public BindableCollection<int> Rounds public BindableCollection<int> Rounds
{ {
get { return _rounds; } get { return _rounds; }
set { _rounds = value; } set { _rounds = value; }
} }
private void LoadRounds() private void LoadRounds()
{ {
Rounds.Clear(); 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}"/> SelectedItem="{Binding Path=SelectedTournament,Mode=OneWayToSource}"/>
<!--<TextBlock x:Name="SelectedTournament_TournamentName"/>--> <!--<TextBlock x:Name="SelectedTournament_TournamentName"/>-->
</StackPanel> </StackPanel>
<Border Grid.Row="2" Grid.Column="2" BorderThickness="1"
<ContentControl x:Name="ActiveItem" Grid.Row="2" Grid.Column="2"/> Margin="10 10 0 0" BorderBrush="Gray" >
<ContentControl x:Name="ActiveItem" Margin="5" />
</Border>
</Grid> </Grid>
</Window> </Window>