69 lines
2.1 KiB
C#
69 lines
2.1 KiB
C#
using Caliburn.Micro;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using TrackerLibrary;
|
|
using TrackerLibrary.Models;
|
|
|
|
namespace TrackerWPFUI.ViewModels
|
|
{
|
|
public class ShellViewModel : Conductor<object>,IHandle<TournamentModel> //ActiveItem in Itemcontrol tells whats going on
|
|
{
|
|
|
|
public ShellViewModel()
|
|
{
|
|
// Initialize the database connections
|
|
GlobalConfig.InitializeConnections(DatabaseType.Sql);
|
|
|
|
EventAggregationProvider.TrackerEventAggregator.Subscribe(this);
|
|
|
|
_existingTournaments = new BindableCollection<TournamentModel>(GlobalConfig.Connection.GetTournament_All());
|
|
//ActivateItem(new CreatePrizeViewModel());
|
|
//ActivateItem(new CreateTeamViewModel());
|
|
//ActivateItem(new CreatePersonViewModel());
|
|
}
|
|
public void CreateTournament()
|
|
{
|
|
ActivateItem(new CreateTournamentViewModel());
|
|
}
|
|
|
|
public void LoadTournament()
|
|
{
|
|
if (SelectedTournament !=null && !string.IsNullOrWhiteSpace(SelectedTournament.TournamentName))
|
|
{
|
|
ActivateItem(new TournamentViewerViewModel(SelectedTournament));
|
|
}
|
|
}
|
|
|
|
public void Handle(TournamentModel message)
|
|
{
|
|
// Open the tournamentViewer to the given tournament
|
|
ExistingTournaments.Add(message);
|
|
SelectedTournament = message;
|
|
}
|
|
|
|
private BindableCollection<TournamentModel> _existingTournaments;
|
|
private TournamentModel _SelectedTournament;
|
|
|
|
public BindableCollection<TournamentModel> ExistingTournaments
|
|
{
|
|
get { return _existingTournaments; }
|
|
set { _existingTournaments = value; }
|
|
}
|
|
|
|
|
|
public TournamentModel SelectedTournament
|
|
{
|
|
get { return _SelectedTournament; }
|
|
set
|
|
{
|
|
_SelectedTournament = value;
|
|
NotifyOfPropertyChange(() => SelectedTournament);
|
|
LoadTournament();
|
|
}
|
|
}
|
|
}
|
|
}
|