From ceba92f3d2d5dc21856741840d43c63abd54bb2f Mon Sep 17 00:00:00 2001
From: Tim Young <tim.young@lightsys.org>
Date: Wed, 2 Aug 2017 08:30:42 -0500
Subject: [PATCH] Add a checkPromptBox.  It generates a simple form with a
 bunch of checkmarks.  We will use this when prompting for initial settings.

---
 EduNetworkBuilder/NB.cs | 72 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 71 insertions(+), 1 deletion(-)

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<string, bool> CheckPromptBox(Dictionary<string, bool> Checks)
+        {
+            return CheckPromptBox(Checks, "", null);
+        }
+        public static Dictionary<string, bool> CheckPromptBox(Dictionary<string, bool> Checks, string Title)
+        {
+            return CheckPromptBox(Checks, Title, null);
+        }
+        public static Dictionary<string, bool> CheckPromptBox(Dictionary<string,bool> Checks, string Title, Icon theIcon)
+        {
+            //we need to choose a language:
+            Dictionary<string, bool> responses = new Dictionary<string, bool>();
+
+            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<string, bool> 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<string, bool> 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();