working on Person Form

This commit is contained in:
Tim Young 2017-07-27 15:20:32 -05:00
parent d899e21617
commit 7151d222f8
9 changed files with 451 additions and 2 deletions

View File

@ -150,6 +150,12 @@
<Compile Include="Packet.cs" />
<Compile Include="PacketMessage.cs" />
<Compile Include="PersonClass.cs" />
<Compile Include="PersonProfileForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PersonProfileForm.Designer.cs">
<DependentUpon>PersonProfileForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
@ -203,6 +209,9 @@
<EmbeddedResource Include="OptionsWindow.resx">
<DependentUpon>OptionsWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="PersonProfileForm.resx">
<DependentUpon>PersonProfileForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<SubType>Designer</SubType>

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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();
}
}
}

View File

@ -20,7 +20,10 @@ namespace EduNetworkBuilder
/// The full name of the person. Can have spaces and punctuation. Can change as one wants it changed.
/// </summary>
public string FullName = "";
List<string> Passwords;
string PasswordHint = "";
/// <summary>
/// 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.

View File

@ -0,0 +1,178 @@
namespace EduNetworkBuilder
{
partial class PersonProfileForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1689,4 +1689,8 @@
<value>Hide Device</value>
<comment>NB_Hide = Hide</comment>
</data>
<data name="NB_ClassSetup" xml:space="preserve">
<value>Class Setup</value>
<comment>NB_ClassSetup = Class Setup</comment>
</data>
</root>