public void Add(string msg) { uci.SetMsg(msg); if (uci.command == "option") { COption op = new COption(); op.name = uci.GetValue("name", "type"); if (GetOption(op.name) == null) { uci.GetValue("type", out op.type); uci.GetValue("default", out op.def); uci.GetValue("min", out op.min); uci.GetValue("max", out op.max); list.Add(op); } } }
public void Uciok() { int y = 0; panOptions.Controls.Clear(); optionList.Sort(); for (int n = 0; n < optionList.list.Count; n++) { string oName = $"optionN{n}"; string lName = $"optionN{n}"; COption o = optionList.list[n]; switch (o.type) { case "spin": var nud = new NumericUpDown(); nud.Name = oName; nud.Minimum = Convert.ToInt32(o.min); nud.Maximum = Convert.ToInt32(o.max); nud.Value = Convert.ToInt32(engine.GetOption(o.name, o.def)); nud.Location = new Point(3, y); nud.TextAlign = HorizontalAlignment.Right; panOptions.Controls.Add(nud); var lab = new Label(); lab.Name = lName; lab.Text = o.name; lab.Location = new Point(128, y); panOptions.Controls.Add(lab); y += 24; break; case "check": var check = new CheckBox(); check.Name = oName; check.Text = o.name; check.Checked = Convert.ToBoolean(engine.GetOption(o.name, o.def)); check.Location = new Point(3, y); panOptions.Controls.Add(check); y += 24; break; } } process.Terminate(); }
List <string> GetOptions() { List <string> list = new List <string>(); for (int n = 0; n < optionList.list.Count; n++) { string oName = $"optionN{n}"; var c = panOptions.Controls.Find(oName, false); if (c.Length == 0) { continue; } COption o = optionList.list[n]; string value; switch (o.type) { case "spin": NumericUpDown nud = (c[0]) as NumericUpDown; value = nud.Value.ToString(); if (o.def != value) { list.Add($"name {o.name} value {value}"); } break; case "check": CheckBox check = (c[0]) as CheckBox; value = check.Checked ? "true" : "false"; if (o.def != value) { list.Add($"name {o.name} value {value}"); } break; } } return(list); }