public FormMain()
        {
            InitializeComponent();

              //Initialize private members
              _movingSplitter = false;
              _tournament = null;
              _bracketControls = new List<ControlBracket>();
              _winnerControl = null;
              _currentTournamentFilePath = string.Empty;
        }
        /// <summary>
        /// Deserializes a Tournament object from file and returns it as the result.
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static Tournament Load(string filePath)
        {
            Tournament result = new Tournament();

              using (FileStream sourceFile = new FileStream(filePath, FileMode.Open, FileAccess.Read))
              {
            BinaryFormatter formatter = new BinaryFormatter();
            result = (Tournament)formatter.Deserialize(sourceFile);
              }

              return result;
        }
        /// <summary>
        /// Prompts the user for a dialog and attempts to open the specified tournament file.
        /// </summary>
        private void OpenTournament()
        {
            //Prompt for save here if a tournament is assigned
              bool cancel;
              PromptForSavingExistingTournament(out cancel);

              //If the user canceled, just exit.
              if (cancel)
            return;

              //Get the last save directory that was used
              string lastSaveDirPath = UserSettings.Default.LastSaveDirectory;

              //Create and show the open file dialog
              OpenFileDialog openDialog = new OpenFileDialog();
              openDialog.Filter = DIALOG_FILE_FILTER;
              openDialog.Title = "Open Tournament File";

              //If the user cancels the save dialog, just bail.
              if (openDialog.ShowDialog(this) != DialogResult.OK)
            return;

              //We have a selected file, so attempt to deserialize it
              _tournament = Tournament.Load(openDialog.FileName);

              //Load competitor grid
              LoadCompetitorGridFromTournament();

              //Create tournament controls in the UI
              DrawTournamentBrackets();

              //Set the form caption and file path
              SetTournamentFilePath(openDialog.FileName);

              //Disable the controls on the main form
              SetEditControlUsability(false);
        }
        private void mnuFileNew_Click(object sender, EventArgs e)
        {
            try
              {
            bool cancel;
            PromptForSavingExistingTournament(out cancel);

            //If the user canceled the action, just exit.
            if (cancel)
              return;

            //Reset the tournament, clear the bracket display and grid, and re-enable the UI controls
            _tournament = null;
            SetTournamentFilePath(string.Empty);
            ClearExistingBracketsAndWinner();
            dgCompetitors.Rows.Clear();
            SetEditControlUsability(true);
              }
              catch (Exception ex)
              {
            Ui.DisplayError(ex.Message);
              }
        }
        private void bStart_Click(object sender, EventArgs e)
        {
            try
              {
            try
            {
              this.Cursor = Cursors.WaitCursor;

              //Determine the seed we're to use
              SeedOption seedOption = GetSelectedSeed();

              //Create competitor collection based on what's entered into the form
              List<Competitor> competitors = GetCompetitors();

              //Create the tournament
              _tournament = new Tournament(competitors, seedOption);

              //Disable controls now that the tournament has been created
              SetEditControlUsability(false);

              //If the tournament was seeded randomly, repopulate our competitor grid
              LoadCompetitorGridFromTournament();

              //Draw/create tournament brackets to display on screen
              this.Cursor = Cursors.WaitCursor;
              DrawTournamentBrackets();
            }
            finally
            {
              this.Cursor = Cursors.Default;
            }
              }
              catch (Exception ex)
              {
            Ui.DisplayError(ex.Message);
              }
        }