From ebf1a6b04ed665bc7452e50aeb7047960d668573 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Tue, 1 Aug 2017 21:09:05 -0500 Subject: [PATCH] Hide unnecessary tabs when cycling through homework --- .../PersonProfileForm.Designer.cs | 23 ++++---- EduNetworkBuilder/PersonProfileForm.cs | 53 ++++++++++++++++++- 2 files changed, 63 insertions(+), 13 deletions(-) diff --git a/EduNetworkBuilder/PersonProfileForm.Designer.cs b/EduNetworkBuilder/PersonProfileForm.Designer.cs index a66dc72..cb44890 100644 --- a/EduNetworkBuilder/PersonProfileForm.Designer.cs +++ b/EduNetworkBuilder/PersonProfileForm.Designer.cs @@ -38,7 +38,6 @@ this.TabClasswork = new System.Windows.Forms.TabPage(); this.tcTreeData = new System.Windows.Forms.TabControl(); this.tabClass = new System.Windows.Forms.TabPage(); - this.btnImportStudents = new System.Windows.Forms.Button(); this.TabHomework = new System.Windows.Forms.TabPage(); this.btnLaunch = new System.Windows.Forms.Button(); this.btnHWDelete = new System.Windows.Forms.Button(); @@ -62,6 +61,7 @@ this.lblStudentFullName = new System.Windows.Forms.Label(); this.btnStudentChangePassword = new System.Windows.Forms.Button(); this.btnStudentUpdateFile = new System.Windows.Forms.Button(); + this.btnImportStudents = new System.Windows.Forms.Button(); this.tcTabControl.SuspendLayout(); this.TabProfile.SuspendLayout(); this.TabClasswork.SuspendLayout(); @@ -178,16 +178,6 @@ this.tabClass.Text = "Class"; this.tabClass.UseVisualStyleBackColor = true; // - // btnImportStudents - // - this.btnImportStudents.Location = new System.Drawing.Point(6, 6); - this.btnImportStudents.Name = "btnImportStudents"; - this.btnImportStudents.Size = new System.Drawing.Size(152, 23); - this.btnImportStudents.TabIndex = 0; - this.btnImportStudents.Text = "Import Students"; - this.btnImportStudents.UseVisualStyleBackColor = true; - this.btnImportStudents.Click += new System.EventHandler(this.btnImportStudents_Click); - // // TabHomework // this.TabHomework.Controls.Add(this.btnLaunch); @@ -410,6 +400,15 @@ this.btnStudentUpdateFile.Text = "Update File"; this.btnStudentUpdateFile.UseVisualStyleBackColor = true; // + // btnImportStudents + // + this.btnImportStudents.Location = new System.Drawing.Point(6, 6); + this.btnImportStudents.Name = "btnImportStudents"; + this.btnImportStudents.Size = new System.Drawing.Size(152, 23); + this.btnImportStudents.TabIndex = 2; + this.btnImportStudents.Text = "Import Students"; + this.btnImportStudents.UseVisualStyleBackColor = true; + // // PersonProfileForm // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); @@ -460,7 +459,6 @@ private System.Windows.Forms.TextBox tbHWSubmitted; private System.Windows.Forms.Label lblHWDue; private System.Windows.Forms.DateTimePicker dtpHWDue; - private System.Windows.Forms.Button btnImportStudents; private System.Windows.Forms.Button btnHWDelete; private System.Windows.Forms.Button btnLaunch; private System.Windows.Forms.TabPage TabStudent; @@ -470,5 +468,6 @@ private System.Windows.Forms.TextBox tbStudentUsername; private System.Windows.Forms.Button btnStudentUpdateFile; private System.Windows.Forms.Button btnStudentChangePassword; + private System.Windows.Forms.Button btnImportStudents; } } \ No newline at end of file diff --git a/EduNetworkBuilder/PersonProfileForm.cs b/EduNetworkBuilder/PersonProfileForm.cs index e717bbb..26f8594 100644 --- a/EduNetworkBuilder/PersonProfileForm.cs +++ b/EduNetworkBuilder/PersonProfileForm.cs @@ -300,8 +300,59 @@ namespace EduNetworkBuilder private void ChangeTreeDataTab(TreeDataTab WhatTo) { + foreach (TreeDataTab one in Enum.GetValues(typeof(TreeDataTab))) + { + if (one == WhatTo) ShowTabPage(one); + else HideTabPage(one); + } tcTabControl.SelectedIndex = (int)TopTab.classworktab; - tcTreeData.SelectedIndex = (int)WhatTo; + //Now there is just one tab. Select it + //tcTreeData.SelectedIndex = (int)WhatTo; + tcTreeData.SelectedIndex = 0; + } + + private void HideTabPage(TreeDataTab What) + { + TabPage Tab = null; + switch(What) + { + case TreeDataTab.classtab: + Tab = tabClass; + break; + case TreeDataTab.homeworktab: + Tab = TabHomework; + break; + case TreeDataTab.studentstab: + Tab = TabStudents; + break; + case TreeDataTab.studenttab: + Tab = TabStudent; + break; + } + if(tcTreeData.TabPages.Contains(Tab)) + tcTreeData.TabPages.Remove(Tab); + } + + private void ShowTabPage(TreeDataTab What) + { + TabPage Tab = null; + switch (What) + { + case TreeDataTab.classtab: + Tab = tabClass; + break; + case TreeDataTab.homeworktab: + Tab = TabHomework; + break; + case TreeDataTab.studentstab: + Tab = TabStudents; + break; + case TreeDataTab.studenttab: + Tab = TabStudent; + break; + } + if (!tcTreeData.TabPages.Contains(Tab)) + tcTreeData.TabPages.Add(Tab); } private void tvClasswork_Click(object sender, EventArgs e)