Beispiel #1
0
        /// <summary>
        /// Allows to add new task control
        /// </summary>
        /// <param name="id">task ID</param>
        /// <param name="tabControl">TabControl to add to</param>
        private void AddUserControl(TabControl tabControl, long id = -1)
        {
            try
            {
                tabControl.SelectTab(
                    tabControl.TabPages
                        .Cast<TabPage>()
                        .First(x => x.Tag != null
                                    && x.Tag.ToString() == id.ToString(CultureInfo.InvariantCulture)));
            }
            catch (Exception)
            {
                var tp = new TabPage {Tag = id};
                var tuc = new TaskUserControl(this, id) {Dock = DockStyle.Fill};
                tuc.TaskOpened += AddUserControl;
                tuc.TaskClosed += TucTaskClosed;
                tp.Controls.Add(tuc);

                tabControl.TabPages.Add(tp);
                tabControl.SelectTab(tp);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Event of task closed
 /// </summary>
 /// <param name="uc">TaskUserControl</param>
 private void TucTaskClosed(TaskUserControl uc)
 {
     Populate();
     GetTabControl.TabPages.Remove((TabPage) uc.Parent);
 }