Add a checkPromptBox. It generates a simple form with a bunch of checkmarks. We will use this when prompting for initial settings.
This commit is contained in:
parent
ebf1a6b04e
commit
ceba92f3d2
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user