diff --git a/EduNetworkBuilder/NB.cs b/EduNetworkBuilder/NB.cs index 08c4d48..138ea2b 100644 --- a/EduNetworkBuilder/NB.cs +++ b/EduNetworkBuilder/NB.cs @@ -767,7 +767,7 @@ namespace EduNetworkBuilder //we need to choose a language: int yspace = 10; Form TextInputForm = new Form(); - TextInputForm.Text = Prompt; + TextInputForm.Text = Title; Label lblText = new Label(); lblText.Location = new Point(5, 5); lblText.AutoSize = true; @@ -810,6 +810,76 @@ namespace EduNetworkBuilder return tbEvent.Text; } + + public static Dictionary CheckPromptBox(Dictionary Checks) + { + return CheckPromptBox(Checks, "", null); + } + public static Dictionary CheckPromptBox(Dictionary Checks, string Title) + { + return CheckPromptBox(Checks, Title, null); + } + public static Dictionary CheckPromptBox(Dictionary Checks, string Title, Icon theIcon) + { + //we need to choose a language: + Dictionary responses = new Dictionary(); + + int yspace = 10; + Form CheckInputForm = new Form(); + CheckInputForm.Text = Title; + if (theIcon != null) + CheckInputForm.Icon = theIcon; + + int startx = 150; + + int y = 0; + int lastY = 0; + int lastHeight = 0; + foreach(KeyValuePair entry in Checks) + { + //Make a checkbox + CheckBox cb = new CheckBox(); + cb.Name = entry.Key; //Name it so we can know what it is. + cb.Text = entry.Key; //Have it display the right value for a label + cb.Checked = entry.Value; //Have it checked, or not, depending on the value we passed in + + //Put it in the appropriate location + cb.Location = new Point(startx, (y * (cb.Height + yspace)) + yspace); + lastY = cb.Location.Y; + lastHeight = cb.Height; + CheckInputForm.Controls.Add(cb); + } + + CheckInputForm.AutoSize = true; + + Button btnAccept = new Button(); + btnAccept.Location = new Point(startx, lastY + lastHeight + 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,btnAccept.Location.Y); + btnCancel.Text = "Cancel"; + btnCancel.Click += (s, g) => { Button b = (Button)s; Form f = (Form)b.Parent; responses = null; f.Close(); }; + + CheckInputForm.Controls.Add(btnAccept); + CheckInputForm.Controls.Add(btnCancel); + + CheckInputForm.AcceptButton = btnAccept; + CheckInputForm.CancelButton = btnCancel; + + CheckInputForm.ShowDialog(); + foreach (KeyValuePair entry in Checks) + { + if(CheckInputForm.Controls[entry.Key] != null && CheckInputForm.Controls[entry.Key] is CheckBox) + { + CheckBox One = (CheckBox)CheckInputForm.Controls[entry.Key]; + responses.Add(One.Name, One.Checked); + } + } + return responses; + } + public static bool MAC_Exists(string MAC) { Network myNet = GetNetwork();