private void buttonAddContest_Click(object sender, EventArgs e)
        {
            if (m_TabIndex < k_MaxNumberOfContests)
            {
                TabPageObserver tabPageContest = new TabPageObserver();

                if (m_TabIndex == 0)
                {
                    tabPageContest.Padding = new Padding(3);
                }

                FormAddContest newFormContest = new FormAddContest();
                newFormContest.ShowDialog();

                if (newFormContest.DialogResult == DialogResult.OK)
                {
                    IContest newContest = ContestFactory.CreateContest(
                        m_TabIndex + 1,
                        newFormContest.Status,
                        newFormContest.ImagePath,
                        newFormContest.NumberOfWinners,
                        newFormContest.LikeRequired,
                        newFormContest.CommentRequired);
                    m_ListOfContests.Add(newContest);

                    try
                    {
                        newContest.PostContestStatus();
                    }
                    catch (FacebookOAuthException)
                    {
                        MessageBox.Show("Failed to post status: No permissions.");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    tabPageContest.Location = new Point(104, 4);
                    tabPageContest.Name     = string.Format("tabPageContest{0}", m_TabIndex + 1);
                    tabPageContest.Size     = new Size(867, 616);
                    tabPageContest.TabIndex = m_TabIndex;
                    tabPageContest.Text     = string.Format("Contest {0}", m_TabIndex + 1);
                    tabPageContest.UseVisualStyleBackColor = true;
                    tabControlContest.Controls.Add(tabPageContest);
                    buildContest(tabPageContest);
                    m_TabIndex++;

                    m_ReportDeletedContestDelegate += tabPageContest.m_ReportDeletedContestObserver;
                }
            }
            else
            {
                MessageBox.Show("You have reached the maximum number of contests.");
            }
        }
        private void buttonDeleteConstest_Click(object sender, EventArgs e)
        {
            Button          buttonDelete    = (Button)sender;
            TabPageObserver tabPageToDelete = buttonDelete.Parent as TabPageObserver;

            m_ReportDeletedContestDelegate -= tabPageToDelete.m_ReportDeletedContestObserver;
            m_TabIndex--;
            tabControlContest.TabPages.Remove(tabPageToDelete);
            m_ListOfContests.RemoveAt((buttonDelete.Name[buttonDelete.Name.Length - 1] - '0') - 1);

            if (m_TabIndex != 0)
            {
                m_ReportDeletedContestDelegate.Invoke(int.Parse(tabPageToDelete.Text.Split(' ')[1]));
            }
        }
        private void buildContest(TabPageObserver i_CurrentTabPage)
        {
            Label      labelPost                = new Label();
            Label      labelParticipants        = new Label();
            Label      labelPicture             = new Label();
            Label      labelContestrequirements = new Label();
            CheckBox   checkBoxCommentCondition = new CheckBox();
            CheckBox   checkBoxLikeCondition    = new CheckBox();
            TextBox    textBoxDescription       = new TextBox();
            PictureBox pictureBoxAttachedImage  = new PictureBox();
            ListBox    listBoxParticipants      = new ListBox();
            Button     buttonUpdateParticipants = new Button();
            Button     buttonChooseWinner       = new Button();
            Button     buttonDeleteConstest     = new Button();

            buildPostControls(labelPost, textBoxDescription);

            if (m_ListOfContests[m_ListOfContests.Count - 1].m_ImagePath != null)
            {
                buildPictureControls(labelPost, labelPicture, textBoxDescription, pictureBoxAttachedImage);
                i_CurrentTabPage.Controls.Add(labelPicture);
                i_CurrentTabPage.Controls.Add(pictureBoxAttachedImage);
            }

            buildParticipantsControls(labelParticipants, textBoxDescription, listBoxParticipants, checkBoxCommentCondition);
            buildRequirementsControls(labelContestrequirements, checkBoxCommentCondition, checkBoxLikeCondition, textBoxDescription, listBoxParticipants);
            updateRequirementsCheckBoxes(m_ListOfContests[m_ListOfContests.Count - 1], checkBoxCommentCondition, checkBoxLikeCondition);
            buildButtonsControls(listBoxParticipants, buttonUpdateParticipants, buttonChooseWinner, buttonDeleteConstest, labelParticipants);

            i_CurrentTabPage.Controls.Add(labelPost);
            i_CurrentTabPage.Controls.Add(textBoxDescription);
            i_CurrentTabPage.Controls.Add(labelParticipants);
            i_CurrentTabPage.Controls.Add(listBoxParticipants);
            i_CurrentTabPage.Controls.Add(labelContestrequirements);
            i_CurrentTabPage.Controls.Add(checkBoxLikeCondition);
            i_CurrentTabPage.Controls.Add(checkBoxCommentCondition);
            i_CurrentTabPage.Controls.Add(buttonUpdateParticipants);
            i_CurrentTabPage.Controls.Add(buttonChooseWinner);
            i_CurrentTabPage.Controls.Add(buttonDeleteConstest);

            tabControlContest.SelectedTab = i_CurrentTabPage;
        }