From 7151d222f87d4a81884514db3c337f1ad4ce94fe Mon Sep 17 00:00:00 2001 From: Tim Young Date: Thu, 27 Jul 2017 15:20:32 -0500 Subject: [PATCH] working on Person Form --- EduNetworkBuilder/EduNetworkBuilder.csproj | 9 + EduNetworkBuilder/NB.cs | 56 ++++++ EduNetworkBuilder/NetworkBuilder.Designer.cs | 14 +- EduNetworkBuilder/NetworkBuilder.cs | 9 + EduNetworkBuilder/PersonClass.cs | 3 + .../PersonProfileForm.Designer.cs | 178 ++++++++++++++++++ EduNetworkBuilder/PersonProfileForm.cs | 60 ++++++ EduNetworkBuilder/PersonProfileForm.resx | 120 ++++++++++++ .../Resources/languages/edustrings.resx | 4 + 9 files changed, 451 insertions(+), 2 deletions(-) create mode 100644 EduNetworkBuilder/PersonProfileForm.Designer.cs create mode 100644 EduNetworkBuilder/PersonProfileForm.cs create mode 100644 EduNetworkBuilder/PersonProfileForm.resx diff --git a/EduNetworkBuilder/EduNetworkBuilder.csproj b/EduNetworkBuilder/EduNetworkBuilder.csproj index 902a6bd..858ac88 100644 --- a/EduNetworkBuilder/EduNetworkBuilder.csproj +++ b/EduNetworkBuilder/EduNetworkBuilder.csproj @@ -150,6 +150,12 @@ + + Form + + + PersonProfileForm.cs + @@ -203,6 +209,9 @@ OptionsWindow.cs + + PersonProfileForm.cs + ResXFileCodeGenerator Designer diff --git a/EduNetworkBuilder/NB.cs b/EduNetworkBuilder/NB.cs index 9ae13cb..fd5ff9d 100644 --- a/EduNetworkBuilder/NB.cs +++ b/EduNetworkBuilder/NB.cs @@ -707,6 +707,62 @@ namespace EduNetworkBuilder return mac; } + public static string TextPromptBox(string Prompt, Icon theIcon=null, bool isPassword = false) + { + return TextPromptBox(Prompt, "", "", theIcon, isPassword); + } + public static string TextPromptBox(string Prompt, string Title, Icon theIcon = null, bool isPassword=false) + { + return TextPromptBox(Prompt, Title, "", theIcon, isPassword); + } + public static string TextPromptBox(string Prompt, string Title, string oldtext, Icon theIcon, bool isPassword) + { + //we need to choose a language: + int yspace = 10; + Form TextInputForm = new Form(); + TextInputForm.Text = Prompt; + Label lblText = new Label(); + lblText.Location = new Point(5, 5); + lblText.AutoSize = true; + lblText.Text = Prompt; + if(theIcon != null) + TextInputForm.Icon = theIcon; + if (oldtext == null) oldtext = ""; + + TextBox tbEvent = new TextBox(); + tbEvent.Location = new Point(lblText.Location.X, lblText.Location.Y + lblText.Height + yspace); + tbEvent.Width = 120; + tbEvent.Text = oldtext;//Populate it with the old data if we can + if (isPassword) + tbEvent.PasswordChar = '*'; + + TextInputForm.Width = tbEvent.Location.X + tbEvent.Width + 30; + TextInputForm.Height = 90; + TextInputForm.AutoSize = true; + + Button btnAccept = new Button(); + btnAccept.Location = new Point(tbEvent.Location.X, tbEvent.Location.Y + tbEvent.Height + yspace); + btnAccept.Text = "OK"; + btnAccept.Click += (s, g) => { Button b = (Button)s; Form f = (Form)b.Parent; f.Close(); }; + + Button btnCancel = new Button(); + btnCancel.Location = new Point(btnAccept.Location.X + btnAccept.Width + 10, tbEvent.Location.Y + tbEvent.Height + 10); + btnCancel.Text = "Cancel"; + btnCancel.Click += (s, g) => { Button b = (Button)s; Form f = (Form)b.Parent; tbEvent.Text = ""; f.Close(); }; + + + TextInputForm.Controls.Add(lblText); + TextInputForm.Controls.Add(tbEvent); + TextInputForm.Controls.Add(btnAccept); + TextInputForm.Controls.Add(btnCancel); + + TextInputForm.AcceptButton = btnAccept; + TextInputForm.CancelButton = btnCancel; + + TextInputForm.ShowDialog(); + return tbEvent.Text; + } + public static bool MAC_Exists(string MAC) { Network myNet = GetNetwork(); diff --git a/EduNetworkBuilder/NetworkBuilder.Designer.cs b/EduNetworkBuilder/NetworkBuilder.Designer.cs index 4d908bc..0078652 100644 --- a/EduNetworkBuilder/NetworkBuilder.Designer.cs +++ b/EduNetworkBuilder/NetworkBuilder.Designer.cs @@ -80,6 +80,7 @@ this.HelpPanel = new System.Windows.Forms.Panel(); this.cbViewTitles = new System.Windows.Forms.CheckBox(); this.myProgressBar = new System.Windows.Forms.ProgressBar(); + this.classSetupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.msMainMenuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbNetworkView)).BeginInit(); this.HelpPanel.SuspendLayout(); @@ -156,7 +157,8 @@ this.pasteToolStripMenuItem, this.undoToolStripMenuItem, this.optionsToolStripMenuItem, - this.changeLanguageToolStripMenuItem}); + this.changeLanguageToolStripMenuItem, + this.classSetupToolStripMenuItem}); this.editToolStripMenuItem.Name = "editToolStripMenuItem"; this.editToolStripMenuItem.Size = new System.Drawing.Size(47, 24); this.editToolStripMenuItem.Text = "Edit"; @@ -536,7 +538,7 @@ // this.cbViewTitles.AutoSize = true; this.cbViewTitles.Location = new System.Drawing.Point(7, 9); - this.cbViewTitles.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.cbViewTitles.Margin = new System.Windows.Forms.Padding(4); this.cbViewTitles.Name = "cbViewTitles"; this.cbViewTitles.Size = new System.Drawing.Size(18, 17); this.cbViewTitles.TabIndex = 10; @@ -553,6 +555,13 @@ this.myProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.myProgressBar.TabIndex = 11; // + // classSetupToolStripMenuItem + // + this.classSetupToolStripMenuItem.Name = "classSetupToolStripMenuItem"; + this.classSetupToolStripMenuItem.Size = new System.Drawing.Size(203, 26); + this.classSetupToolStripMenuItem.Text = "Class Setup"; + this.classSetupToolStripMenuItem.Click += new System.EventHandler(this.classSetupToolStripMenuItem_Click); + // // BuilderWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); @@ -640,6 +649,7 @@ private System.Windows.Forms.CheckBox cbViewTitles; private System.Windows.Forms.ToolStripMenuItem VLANToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem SolvedVLANToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem classSetupToolStripMenuItem; } } diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index 780b727..4796b31 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -124,6 +124,7 @@ namespace EduNetworkBuilder pasteToolStripMenuItem.Text = NB.Translate("NB_pasteToolStripMenuItem", OurSettings); undoToolStripMenuItem.Text = NB.Translate("NB_undoToolStripMenuItem", OurSettings); optionsToolStripMenuItem.Text = NB.Translate("NB_optionsToolStripMenuItem", OurSettings); + classSetupToolStripMenuItem.Text = NB.Translate("NB_ClassSetup", OurSettings); allToolStripMenuItem.Text = NB.Translate("_All", OurSettings); dHCPRequestToolStripMenuItem.Text = NB.Translate("NB_NetViewDHCP", OurSettings); clearArpTableToolStripMenuItem.Text = NB.Translate("NB_NetViewClr", OurSettings); @@ -1797,5 +1798,13 @@ namespace EduNetworkBuilder UpdateVisuals(); } } + + private void classSetupToolStripMenuItem_Click(object sender, EventArgs e) + { + PersonProfileForm PPF = new PersonProfileForm(); + this.Hide(); + PPF.ShowDialog(); + this.Show(); + } } } \ No newline at end of file diff --git a/EduNetworkBuilder/PersonClass.cs b/EduNetworkBuilder/PersonClass.cs index db55a73..525c500 100644 --- a/EduNetworkBuilder/PersonClass.cs +++ b/EduNetworkBuilder/PersonClass.cs @@ -20,7 +20,10 @@ namespace EduNetworkBuilder /// The full name of the person. Can have spaces and punctuation. Can change as one wants it changed. /// public string FullName = ""; + List Passwords; + + string PasswordHint = ""; /// /// The AltPassword is mainly used to hold the admin decrypting password. The student account will /// use this to encrypt the student password, so the admin can open their file. diff --git a/EduNetworkBuilder/PersonProfileForm.Designer.cs b/EduNetworkBuilder/PersonProfileForm.Designer.cs new file mode 100644 index 0000000..9f73677 --- /dev/null +++ b/EduNetworkBuilder/PersonProfileForm.Designer.cs @@ -0,0 +1,178 @@ +namespace EduNetworkBuilder +{ + partial class PersonProfileForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tcTabControl = new System.Windows.Forms.TabControl(); + this.TabProfile = new System.Windows.Forms.TabPage(); + this.TabClasswork = new System.Windows.Forms.TabPage(); + this.tbUsername = new System.Windows.Forms.TextBox(); + this.lblUsername = new System.Windows.Forms.Label(); + this.tbFullName = new System.Windows.Forms.TextBox(); + this.lblFullName = new System.Windows.Forms.Label(); + this.btnChangePassword = new System.Windows.Forms.Button(); + this.btnExit = new System.Windows.Forms.Button(); + this.tvClasswork = new System.Windows.Forms.TreeView(); + this.tcTabControl.SuspendLayout(); + this.TabProfile.SuspendLayout(); + this.TabClasswork.SuspendLayout(); + this.SuspendLayout(); + // + // tcTabControl + // + this.tcTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tcTabControl.Controls.Add(this.TabProfile); + this.tcTabControl.Controls.Add(this.TabClasswork); + this.tcTabControl.Location = new System.Drawing.Point(12, 12); + this.tcTabControl.Name = "tcTabControl"; + this.tcTabControl.SelectedIndex = 0; + this.tcTabControl.Size = new System.Drawing.Size(418, 280); + this.tcTabControl.TabIndex = 0; + // + // TabProfile + // + this.TabProfile.Controls.Add(this.btnChangePassword); + this.TabProfile.Controls.Add(this.lblFullName); + this.TabProfile.Controls.Add(this.tbFullName); + this.TabProfile.Controls.Add(this.lblUsername); + this.TabProfile.Controls.Add(this.tbUsername); + this.TabProfile.Location = new System.Drawing.Point(4, 25); + this.TabProfile.Name = "TabProfile"; + this.TabProfile.Padding = new System.Windows.Forms.Padding(3); + this.TabProfile.Size = new System.Drawing.Size(410, 251); + this.TabProfile.TabIndex = 0; + this.TabProfile.Text = "Profile"; + this.TabProfile.UseVisualStyleBackColor = true; + // + // TabClasswork + // + this.TabClasswork.Controls.Add(this.tvClasswork); + this.TabClasswork.Location = new System.Drawing.Point(4, 25); + this.TabClasswork.Name = "TabClasswork"; + this.TabClasswork.Padding = new System.Windows.Forms.Padding(3); + this.TabClasswork.Size = new System.Drawing.Size(410, 251); + this.TabClasswork.TabIndex = 1; + this.TabClasswork.Text = "Classwork"; + this.TabClasswork.UseVisualStyleBackColor = true; + // + // tbUsername + // + this.tbUsername.Enabled = false; + this.tbUsername.Location = new System.Drawing.Point(100, 19); + this.tbUsername.Name = "tbUsername"; + this.tbUsername.Size = new System.Drawing.Size(124, 22); + this.tbUsername.TabIndex = 0; + // + // lblUsername + // + this.lblUsername.AutoSize = true; + this.lblUsername.Location = new System.Drawing.Point(17, 22); + this.lblUsername.Name = "lblUsername"; + this.lblUsername.Size = new System.Drawing.Size(73, 17); + this.lblUsername.TabIndex = 1; + this.lblUsername.Text = "Username"; + // + // tbFullName + // + this.tbFullName.Location = new System.Drawing.Point(99, 59); + this.tbFullName.Name = "tbFullName"; + this.tbFullName.Size = new System.Drawing.Size(125, 22); + this.tbFullName.TabIndex = 2; + // + // lblFullName + // + this.lblFullName.AutoSize = true; + this.lblFullName.Location = new System.Drawing.Point(23, 63); + this.lblFullName.Name = "lblFullName"; + this.lblFullName.Size = new System.Drawing.Size(71, 17); + this.lblFullName.TabIndex = 3; + this.lblFullName.Text = "Full Name"; + // + // btnChangePassword + // + this.btnChangePassword.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnChangePassword.Location = new System.Drawing.Point(310, 9); + this.btnChangePassword.Name = "btnChangePassword"; + this.btnChangePassword.Size = new System.Drawing.Size(94, 42); + this.btnChangePassword.TabIndex = 4; + this.btnChangePassword.Text = "Change Password"; + this.btnChangePassword.UseVisualStyleBackColor = true; + // + // btnExit + // + this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnExit.Location = new System.Drawing.Point(351, 298); + this.btnExit.Name = "btnExit"; + this.btnExit.Size = new System.Drawing.Size(75, 23); + this.btnExit.TabIndex = 1; + this.btnExit.Text = "Exit"; + this.btnExit.UseVisualStyleBackColor = true; + // + // tvClasswork + // + this.tvClasswork.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.tvClasswork.Location = new System.Drawing.Point(6, 6); + this.tvClasswork.Name = "tvClasswork"; + this.tvClasswork.Size = new System.Drawing.Size(131, 239); + this.tvClasswork.TabIndex = 0; + // + // PersonProfileForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(442, 333); + this.Controls.Add(this.btnExit); + this.Controls.Add(this.tcTabControl); + this.Name = "PersonProfileForm"; + this.Text = "PersonProfileForm"; + this.Load += new System.EventHandler(this.PersonProfileForm_Load); + this.tcTabControl.ResumeLayout(false); + this.TabProfile.ResumeLayout(false); + this.TabProfile.PerformLayout(); + this.TabClasswork.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TabControl tcTabControl; + private System.Windows.Forms.TabPage TabProfile; + private System.Windows.Forms.Label lblUsername; + private System.Windows.Forms.TextBox tbUsername; + private System.Windows.Forms.TabPage TabClasswork; + private System.Windows.Forms.TextBox tbFullName; + private System.Windows.Forms.Button btnChangePassword; + private System.Windows.Forms.Label lblFullName; + private System.Windows.Forms.Button btnExit; + private System.Windows.Forms.TreeView tvClasswork; + } +} \ No newline at end of file diff --git a/EduNetworkBuilder/PersonProfileForm.cs b/EduNetworkBuilder/PersonProfileForm.cs new file mode 100644 index 0000000..6ba46c8 --- /dev/null +++ b/EduNetworkBuilder/PersonProfileForm.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace EduNetworkBuilder +{ + public partial class PersonProfileForm : Form + { + PersonClass CurrentUser = null; + string FileName = ""; + + public PersonProfileForm(string filename = "") + { + InitializeComponent(); + + Icon = Properties.Resources.NBIco; + LanguagifyComponents(); + FileName = filename; + + //We do LocalSetup at load time. This saves us some grief. + } + + private void PersonProfileForm_Load(object sender, EventArgs e) + { + LocalSetup(); + } + + private void LanguagifyComponents() + { + lblFullName.Text = NB.Translate("PPF_FullName"); + lblUsername.Text = NB.Translate("PPF_UserName"); + TabClasswork.Text = NB.Translate("PPF_TabClasswork"); + TabProfile.Text = NB.Translate("PPF_TabProfile"); + btnExit.Text = NB.Translate("NB_exitToolStripMenuItem"); + } + + private void LocalSetup() + { + if(FileName == "") + { + //Prompt for a username + String Dest = NB.TextPromptBox("Enter a username for the teacher."); + if (Dest == "") Close();//No name given or canceled. + + //Find a directory for it. + } + else + { + //Try to load the file. Close form & give error if it fails + } + } + + } +} \ No newline at end of file diff --git a/EduNetworkBuilder/PersonProfileForm.resx b/EduNetworkBuilder/PersonProfileForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/EduNetworkBuilder/PersonProfileForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/EduNetworkBuilder/Resources/languages/edustrings.resx b/EduNetworkBuilder/Resources/languages/edustrings.resx index d730f17..17c376e 100644 --- a/EduNetworkBuilder/Resources/languages/edustrings.resx +++ b/EduNetworkBuilder/Resources/languages/edustrings.resx @@ -1689,4 +1689,8 @@ Hide Device NB_Hide = Hide + + Class Setup + NB_ClassSetup = Class Setup + \ No newline at end of file