private void determinePVarControls(RatchetMoby moby) { mobyPVarGroup.Controls.Clear(); int yOffset = 15; int xOffset = 5; if (moby.pVarConfig != null) { foreach (MobyPVar pVar in moby.pVarConfig) { switch (pVar.control) { case "float": FloatControl floatControl = new FloatControl(moby.pVars, pVar); floatControl.Location = new Point(xOffset, yOffset); floatControl.OnValueChanged += (s, e) => handleChange(pVar, e); mobyPVarGroup.Controls.Add(floatControl); yOffset += floatControl.Height; break; case "number": IntegerControl intControl = new IntegerControl(moby.pVars, pVar); intControl.Location = new Point(xOffset, yOffset); intControl.OnValueChanged += (s, e) => handleChange(pVar, e); mobyPVarGroup.Controls.Add(intControl); yOffset += intControl.Height; break; } } ; } }
public Form1() { InitializeComponent(); this.FC = new FloatControl(); this.FC.Name = "listBoxHover"; //this.FC.TabStop = false; //this.FC.Visible = false; //this.FC.BackColor = SystemColors.Info; //this.FC.ForeColor = SystemColors.InfoText; }
private void SetControl(ParamDTO param, int position) { dynamic control = new Control(); switch (param.Type) { case "System.Byte": control = new ByteControl(); control.NameProperty = param.Name; break; case "System.Single": control = new FloatControl(); control.NameProperty = param.Name; break; case "System.Drawing.Color": control = new ColorControl(); control.NameProperty = param.Name; break; } this.tableLayoutPanel3.Controls.Add(control, 0, position - 1); }
private void InitFields() { int i = 0; string lbl = ""; Type type = model.GetType(); var parameters = type.GetProperties(); foreach (var pInfo in parameters) { IUIPart part = null; if (pInfo.PropertyType == typeof(int)) { //Создаем соответствующий тип lbl = "INT"; object[] obj = new object[] { lbl }; MethodInfo label = type.GetMethod("SetLabel"); MethodInfo data = type.GetMethod("SetData"); label.Invoke(part, obj); data.Invoke(part, null); } else if (pInfo.PropertyType == typeof(float)) { lbl = "FLOAT"; part = new FloatControl(); object[] obj = new object[] { lbl }; MethodInfo label = type.GetMethod("SetLabel"); MethodInfo data = type.GetMethod("SetData"); label.Invoke(part, obj); data.Invoke(part, null); } else if (pInfo.PropertyType == typeof(string)) { lbl = "STRING"; object[] obj = new object[] { lbl }; MethodInfo label = type.GetMethod("SetLabel"); MethodInfo data = type.GetMethod("SetData"); label.Invoke(part, obj); data.Invoke(part, null); } else if (pInfo.PropertyType == typeof(DateTime)) { lbl = "DATETIME"; object[] obj = new object[] { lbl }; MethodInfo label = type.GetMethod("SetLabel"); MethodInfo data = type.GetMethod("SetData"); label.Invoke(part, obj); data.Invoke(part, null); } part.SetLabel(lbl); part.SetData(model, pInfo); UserControl control = (UserControl)part; control.Top = i * 50; control.Left = 0; Controls.Add(control); } }