public void Load(IAutoSaveDialog iad, bool autosave) { bool overwrite = true; string filename = ""; if (autosave) { string[] filenames = ActiveIO.GetAutosaveFiles(); List <AutosaveFile> files = new List <AutosaveFile>(); for (int i = filenames.Length - 1; i >= 0; i--) { files.Add(new AutosaveFile(filenames[i])); } iad.Init(files); iad.ShowDialog(); overwrite = iad.GetDialogReturn(); filename = iad.GetFileName(); } else { if (ActiveTournament != null) { if (!ActiveIO.ShowMessageWithOKCancel("The current tournament will be overwritten.")) { overwrite = false; } } } if (overwrite == true) { ActiveTournament = ActiveIO.Load(filename); } }
public void RemovePlayer(int index, bool disqualify = false) { Player player = ActiveTournament.Participants[index]; string text = "remove"; if (Started) { text = "drop"; } else if (Started & disqualify) { text = "disqualify"; } if (ActiveIO.ShowMessageWithOKCancel("Do you really want to " + text + " " + player.DisplayName + "?")) { if (text == "remove") { ActiveTournament.RemovePlayer(player); } else if (text == "drop") { ActiveTournament.DropPlayer(player); } else if (text == "disqualify") { ActiveTournament.DisqualifyPlayer(player); } } }
public void SetImage() { ActiveIO.NewImage(); if (!timerWindow.SetImage(new Uri(ActiveIO.TempImgPath))) { ActiveIO.ShowMessage("The Image is invalid."); } }
public bool GetResults(List <Pairing> pairings, string buttonGetResultsText, bool CutIsEnabled, bool update = false, bool end = false) { if (update) { ActiveTournament.GetResults(pairings, true); return(true); } if (pairings.Count == 1) { end = true; } bool allResultsEdited = true; if (ActiveTournament.Rule.IsDrawPossible || ActiveTournament.bonus) { foreach (Pairing p in pairings) { if (!p.ResultEdited) { allResultsEdited = false; break; } } } if (allResultsEdited) { if (CheckResults(pairings) || ActiveTournament.bonus) { ActiveTournament.GetResults(pairings); } else { ActiveIO.ShowMessage("One ore more results are invalid."); return(false); } } else { ActiveIO.ShowMessage("There is a result missing."); return(false); } if (end) { if (!ActiveTournament.CutStarted) { ActiveTournament.CalculateWonBye(); } //DataGridPairing.Visibility = System.Windows.Visibility.Hidden; //ChangeGUIState(false, true); } else { //ChangeGUIState(false); } ActiveTournament.Sort(); return(true); }
public void EditPairings(IPairingDialog ipd, string buttonGetResultsText, bool CutIsEnabled) { ipd.SetParticipants(ActiveTournament.Participants); ipd.SetPairings(ActiveTournament.Pairings); ipd.ShowDialog(); if (ipd.GetDialogResult()) { ActiveTournament.Pairings = ipd.GetPairings(); ActiveIO.Save(ActiveTournament, true, buttonGetResultsText, CutIsEnabled, "ChangePairings"); } }
public void StartTimer(string startTime) { bool timeOK = startTime == ""; if (timeOK) { ActiveTimer.StartTimer(); } else { int pos = startTime.IndexOf(':'); int check = startTime.LastIndexOf(':'); int starthour = 0, startmin = 0; timeOK = true; if (pos != check) { timeOK = false; } if (pos >= 3 || pos == 0) { timeOK = false; } if ((pos == 1 && startTime.Length >= 5) || startTime.Length >= 6) { timeOK = false; } try { starthour = Int32.Parse(startTime.Substring(0, pos)); } catch (Exception) { timeOK = false; } try { startmin = Int32.Parse(startTime.Substring(pos + 1)); } catch (Exception) { timeOK = false; } if (timeOK) { ActiveTimer.StartTimer(starthour, startmin); } else { ActiveIO.ShowMessage("The Time is only allowed in the format HH:MM."); } } }
public void ShowTimerWindow(ITimerWindow itw) { timerWindow = itw; timerWindow.SetTimer(ActiveTimer); string imgurl = ActiveIO.GetImagePath(); if (imgurl != "" && imgurl != null) { timerWindow.SetImage(new Uri(imgurl)); } timerWindow.SetLabelColor(ActiveIO.GetColor()); timerWindow.SetTextSize(ActiveIO.GetSize()); timerWindow.Show(); }
public bool StartTournament(string buttonGetResultsText, bool CutIsEnabled) { if (ActiveTournament.Participants.Count != 0) { firststart = true; Started = true; ActiveIO.Save(ActiveTournament, true, buttonGetResultsText, CutIsEnabled, "TournamentStart"); return(true); } else { ActiveIO.ShowMessage("Tournament can't be started without player"); return(false); } }
public void NewTournament(ITournamentDialog itd) { if (ActiveTournament != null) { if (!ActiveIO.ShowMessageWithOKCancel("The current tournament will be overwritten.")) { return; } } itd.SetIO(ActiveIO); itd.ShowDialog(); if (itd.GetDialogResult()) { ActiveTournament = itd.GetTournament(); ActiveTimer.DefaultTime = ActiveTournament.Rule.DefaultTime; } }
public string Print(bool print, bool pairings = false, bool results = false) { string file = ""; if (!pairings && ActiveTournament != null) { file = ActiveIO.Print(ActiveTournament); } else if (pairings) { file = ActiveIO.Print(ActiveTournament, results); } if (print) { Process.Start("file://" + file); } return(file); }
public void GetBBCode(IOutputDialog iod, IClipboard ic) { iod.ShowDialog(); if (iod.GetDialogResult()) { StringBuilder sb = new StringBuilder(); if (iod.IsResultOutput()) { sb.Append(ActiveIO.GetBBCode(ActiveTournament, false, true)); } if (iod.IsTableOutput()) { sb.Append(ActiveIO.GetBBCode(ActiveTournament, true)); } if (iod.IsPairingOutput()) { sb.Append(ActiveIO.GetBBCode(ActiveTournament, false)); } ic.SetText(sb.ToString()); } }
public void Import(ITournamentDialog itd, bool csv) { if (csv) { ActiveTournament = ActiveIO.CSVImport(); } else { ActiveTournament = ActiveIO.GOEPPImport(); } if (ActiveTournament != null) { itd.SetTournament(ActiveTournament); itd.SetIO(ActiveIO); itd.ShowDialog(); if (itd.IsChanged()) { ChangeTournament(itd.GetTournament()); } ActiveTimer.DefaultTime = ActiveTournament.Rule.DefaultTime; } }
public void SetTimerTextSize(double size) { ActiveIO.WriteSize(size); timerWindow.SetTextSize(size); }
public void SetTimerLabelColor(bool white) { ActiveIO.WriteColor(white); timerWindow.SetLabelColor(white); }
public void Save(string GetResultsText, bool CutIsEnabled, bool autosave = false, string text = "Pairings_Round") { ActiveIO.Save(ActiveTournament, autosave, GetResultsText, CutIsEnabled, text + ActiveTournament.Rounds.Count); }
public void GOEPPExport() { ActiveIO.GOEPPExport(ActiveTournament); }
public void PrintScoreSheet() { string file = ActiveIO.PrintScoreSheet(ActiveTournament); Process.Start("file://" + file); }