예제 #1
0
        private void addStage()
        {
            if (tabControlCategories.SelectedTab != null)
            {
                var form = new CustomInputBox("Create a new stage", "Enter stage name");
                var result = form.ShowDialog();
                string input = form.returnValue;

                if (result == DialogResult.OK && !input.Equals(""))
                {
                    TabControl selectedTabControlStages = this.getSelectedTabControlStages();

                    if (selectedTabControlStages != null)
                    {
                        foreach (TabPage tab in selectedTabControlStages.TabPages)
                        {
                            if (tab.Name.Equals("competitorsTabPage"))
                            {
                                Control[] matchedControls = tab.Controls.Find("CompetitorsDataGridView", false);
                                if (matchedControls.Length > 0)
                                {
                                    int[,] points = getPointsFromFile();

                                    TabPage tabPageStage = new TabPage(input);
                                    OsDataGridView dataGridViewStage = new OsDataGridView(points);
                                    dataGridViewStage.Name = "OsDataGridView";

                                    DataGridView competitorsDataGridView = (DataGridView)matchedControls[0];
                                    foreach(DataGridViewRow row in competitorsDataGridView.Rows)
                                    {
                                        dataGridViewStage.Rows.Add(row.Cells[0].Value, row.Cells[1].Value, row.Cells[2].Value);
                                    }
                                    tabPageStage.Controls.Add(dataGridViewStage);
                                    selectedTabControlStages.TabPages.Add(tabPageStage);
                                }
                            }
                        }
                    } 
                    else
                        MessageBox.Show("Tab not found", "Failed to create");
                }
            }
            else
            {
                MessageBox.Show("Create a category first", "Failed to create");
            }
        }
예제 #2
0
        private void tabContextMenuCategories_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            String item = e.ClickedItem.ToString();
            if (item.Equals("Rename"))
            {
                var form = new CustomInputBox(item.ToString(), "Enter the name", tabControlCategories.SelectedTab.Text);
                var result = form.ShowDialog();
                string input = form.returnValue;

                if (result == DialogResult.OK && !input.Equals(""))
                    tabControlCategories.SelectedTab.Text = input;
            }
            else if (item.Equals("Delete"))
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure want to remove '"
                    + tabControlCategories.SelectedTab.Text+ "' category?", "Remove", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    tabControlCategories.TabPages.Remove(tabControlCategories.SelectedTab);
                }
            }
            else if (item.Equals("Add OS"))
            {
                addStage();
            }
            
        }
예제 #3
0
        private void addCategory()
        {
            var form = new CustomInputBox("Create a category", "Enter category name");
            var result = form.ShowDialog();
            string input = form.returnValue;

            if (result == DialogResult.OK && !input.Equals(""))
            {
                
                TabControl tabControlStages = new TabControl();
                tabControlStages.Dock = DockStyle.Fill;
                tabControlStages.Name = "stagesTabControl";
                tabControlStages.MouseClick += tabControlCategories_MouseClick;
                tabControlStages.MouseDown += new MouseEventHandler(tc_MouseDown);
                tabControlStages.MouseUp += new MouseEventHandler(tc_MouseUp);
                tabControlStages.MouseMove += new MouseEventHandler(tc_MouseMove);
                tabControlStages.DragOver += new DragEventHandler(tc_DragOver);
                tabControlStages.AllowDrop = true;

                TabPage competitorsTabPage = new TabPage();
                competitorsTabPage.Text = "Competitors";
                competitorsTabPage.Name = "competitorsTabPage";
                CompetitorsDataGridView competitorsDataGridView = new CompetitorsDataGridView();
                competitorsTabPage.Controls.Add(competitorsDataGridView);
                tabControlStages.TabPages.Add(competitorsTabPage);

                TabPage categoryTabPage = new TabPage(input);
                categoryTabPage.Controls.Add(tabControlStages);

                tabControlCategories.TabPages.Add(categoryTabPage);
            }
        }