public Subscribe ( string paramname, Action |
||
paramname | string | |
act | Action |
|
리턴 | void |
public DynamicReconfigureStringBox(DynamicReconfigureInterface dynamic, ParamDescription pd, string def) { this.def = def; name = pd.name; this.dynamic = dynamic; InitializeComponent(); description.Text = name + ":"; JustTheTip.Content = pd.description; dynamic.Subscribe(name, changed); ignore = false; text = Box.Text; }
public DynamicReconfigureCheckbox(DynamicReconfigureInterface dynamic, ParamDescription pd, bool def) { this.def = def; name = pd.name; this.dynamic = dynamic; InitializeComponent(); description.Content = name + ":"; JustTheTip.Content = pd.description; _checkBox.IsChecked = def; dynamic.Subscribe(name, changed); ignore = false; }
public DynamicReconfigureStringDropdown(DynamicReconfigureInterface dynamic, ParamDescription pd, object def, object max, object min, string edit_method) { this.def = def; this.max = max; this.min = min; this.edit_method = edit_method.Replace("'enum'", "'Enum'"); Dictionary<string, string> parsed = EnumParser.Parse(this.edit_method); string[] vals = parsed["Enum"].Split(new[] {'}'}, StringSplitOptions.RemoveEmptyEntries); List<Dictionary<string, string>> descs = vals.Select(s => EnumParser.SubParse(s + "}")).ToList(); descs = descs.Except(descs.Where(d => d.Count == 0)).ToList(); enumdescription = new EnumDescription(); enumdescription.Enum = new EnumValue[descs.Count]; enumdescription.enum_description = parsed["enum_description"]; Type tdesc = typeof (EnumValue); for (int i = 0; i < descs.Count; i++) { Dictionary<string, string> desc = descs[i]; EnumValue newval = new EnumValue(); foreach (string s in desc.Keys) { FieldInfo fi = tdesc.GetField(s); if (fi.FieldType == typeof (int)) fi.SetValue(newval, int.Parse(desc[s])); else fi.SetValue(newval, desc[s]); } enumdescription.Enum[i] = newval; } name = pd.name.data; this.dynamic = dynamic; InitializeComponent(); for (int i = 0; i < enumdescription.Enum.Length; i++) { if (!types.ContainsKey(enumdescription.Enum[i].type)) { throw new Exception("HANDLE " + enumdescription.Enum[i].type); } switch (types[enumdescription.Enum[i].type]) { case DROPDOWN_TYPE.INT: { ComboBoxItem cbi = new ComboBoxItem {Tag = int.Parse(enumdescription.Enum[i].value), Content = enumdescription.Enum[i].name, ToolTip = new ToolTip {Content = enumdescription.Enum[i].description + " (" + enumdescription.Enum[i].value + ")"}}; @enum.Items.Add(cbi); if (i == 0) { @enum.SelectedValue = this.def; dynamic.Subscribe(name, (Action<int>) changed); } else if (enumdescription.Enum[i].type != enumdescription.Enum[i - 1].type) throw new Exception("NO CHANGSIES MINDSIES"); } break; case DROPDOWN_TYPE.STR: { ComboBoxItem cbi = new ComboBoxItem {Tag = enumdescription.Enum[i].value, Content = enumdescription.Enum[i].name, ToolTip = new ToolTip {Content = enumdescription.Enum[i].description}}; @enum.Items.Add(cbi); if (i == 0) { @enum.SelectedValue = this.def; dynamic.Subscribe(name, (Action<string>) changed); } else if (enumdescription.Enum[i].type != enumdescription.Enum[i - 1].type) throw new Exception("NO CHANGSIES MINDSIES"); } break; } } description.Content = name + ":"; JustTheTip.Content = pd.description.data; ignore = false; }