Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new Tournament
        /// </summary>
        /// <param name="td">A tournament dialog of the current OS which implentes the interface</param>
        /// <returns>true: New Tournament created; false: no new tournament</returns>
        public bool NewTournament(ITournamentDialog td)
        {
            if (activeTournament != null)
            {
                if (!activeIO.ShowMessageWithOKCancel(ActiveLanguage.ExistingTournament))
                {
                    return false;
                }
            }

            td.Title = ActiveLanguage.NewTournament;
            td.TabTitleBasic = ActiveLanguage.Basic;
            td.TabTitleAdvanced = ActiveLanguage.Advanced;
            td.Controll = new TournamentController(activeIO, ActiveLanguage);
            td.SetPresets();
            if (td.ShowDialog() == true)
            {
                activeTournament = new Tournament();
                return true;
            }
            return false;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves the tournament
        /// </summary>
        /// <param name="tournament">the tournament whcich should be saved</param>
        /// <param name="autosave">if its an autosave, the user shouldn  see a savefile-dialog</param>
        public void SaveTournament(Tournament tournament, bool autosave = false)
        {
            string file = "";
            if (autosave)
            {

            }
            else
            {
                for (int i = 0; i < Settings.FileExtensions.Length / 2; i++)
                    fileManager.AddFilter("*" + Settings.FileExtensions[i], ActiveLanguage.FileExtensionNames[i], i != 0);
                if (fileManager.Save())
                    file = fileManager.FileName;
                else
                    return;
            }
            if (file != "")
            {
                using (StreamWriter fs = new StreamWriter(file))
                    fs.Write(JsonConvert.SerializeObject(tournament));

            }
        }