Control giveControlForType(Type t, System.Reflection.PropertyInfo pi) { Control ct = null; if (t == typeof(float)) { float vt = (float)pi.GetValue(mOwnerNode, null); pi.SetValue(mOwnerNode, float.MaxValue, null); float max = (float)pi.GetValue(mOwnerNode, null); pi.SetValue(mOwnerNode, float.MinValue, null); float min = (float)pi.GetValue(mOwnerNode, null); pi.SetValue(mOwnerNode, vt, null); NumericSliderControl c = new NumericSliderControl(); c.Setup(min, max, true); c.NumericValue = vt; ct = c; } else if (t == typeof(int)) { int vt = (int)pi.GetValue(mOwnerNode, null); pi.SetValue(mOwnerNode, int.MaxValue, null); int max = (int)pi.GetValue(mOwnerNode, null); pi.SetValue(mOwnerNode, int.MinValue, null); int min = (int)pi.GetValue(mOwnerNode, null); pi.SetValue(mOwnerNode, vt, null); NumericSliderControl c = new NumericSliderControl(); c.Setup(min, max, false); c.NumericValue = vt; ct = c; } else if (t == typeof(bool)) { CheckBox cb = new CheckBox(); cb.Checked = (bool)pi.GetValue(mOwnerNode, null); ct = cb; } else { MessageBox.Show("Type " + t.ToString() + " not supported in dialog!"); } return(ct); }
void setControlValueToProperty(Control ctrl, Type t, System.Reflection.PropertyInfo pi) { if (t == typeof(float)) { NumericSliderControl c = (NumericSliderControl)ctrl; pi.SetValue(mOwnerNode, (float)c.NumericValue, null); } else if (t == typeof(int)) { NumericSliderControl c = (NumericSliderControl)ctrl; pi.SetValue(mOwnerNode, (int)c.NumericValue, null); } else if (t == typeof(bool)) { CheckBox c = (CheckBox)ctrl; pi.SetValue(mOwnerNode, (bool)c.Checked, null); } else { MessageBox.Show("Type " + t.ToString() + " not supported in dialog!"); } }