Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
                }
            }
        }
Exemplo n.º 3
0
 public void SetImage()
 {
     ActiveIO.NewImage();
     if (!timerWindow.SetImage(new Uri(ActiveIO.TempImgPath)))
     {
         ActiveIO.ShowMessage("The Image is invalid.");
     }
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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");
            }
        }
Exemplo n.º 6
0
        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.");
                }
            }
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
 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);
     }
 }
Exemplo n.º 9
0
 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;
     }
 }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
 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());
     }
 }
Exemplo n.º 12
0
 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;
     }
 }
Exemplo n.º 13
0
 public void SetTimerTextSize(double size)
 {
     ActiveIO.WriteSize(size);
     timerWindow.SetTextSize(size);
 }
Exemplo n.º 14
0
 public void SetTimerLabelColor(bool white)
 {
     ActiveIO.WriteColor(white);
     timerWindow.SetLabelColor(white);
 }
Exemplo n.º 15
0
 public void Save(string GetResultsText, bool CutIsEnabled, bool autosave = false, string text = "Pairings_Round")
 {
     ActiveIO.Save(ActiveTournament, autosave, GetResultsText, CutIsEnabled, text + ActiveTournament.Rounds.Count);
 }
Exemplo n.º 16
0
 public void GOEPPExport()
 {
     ActiveIO.GOEPPExport(ActiveTournament);
 }
Exemplo n.º 17
0
        public void PrintScoreSheet()
        {
            string file = ActiveIO.PrintScoreSheet(ActiveTournament);

            Process.Start("file://" + file);
        }