protected override void UpdateControlObject() { base.UpdateControlObject(); Fold(); numericY.Visible = ControlObject.Type == "float2" || ControlObject.Type == "float3" || ControlObject.Type == "float4"; numericZ.Visible = ControlObject.Type == "float3" || ControlObject.Type == "float4"; numericA.Visible = ControlObject.Type == "float4"; labelUIName.Text = ControlObject.GetControlObject("UIName")?.Value ?? ControlObject.Name; toolTip.SetToolTip(labelUIName, ControlObject.GetControlObject("UIHelp")?.Value); numericX.Maximum = Convert.ToDecimal(UIMaxX); numericY.Maximum = Convert.ToDecimal(UIMaxY); numericZ.Maximum = Convert.ToDecimal(UIMaxZ); numericA.Maximum = Convert.ToDecimal(UIMaxA); numericX.Minimum = Convert.ToDecimal(UIMinX); numericY.Minimum = Convert.ToDecimal(UIMinY); numericZ.Minimum = Convert.ToDecimal(UIMinZ); numericA.Minimum = Convert.ToDecimal(UIMinA); numericX.Increment = numericX.Maximum * 0.005m >= 0.01m ? numericX.Maximum * 0.005m : 0.01m; numericY.Increment = numericY.Maximum * 0.005m >= 0.01m ? numericY.Maximum * 0.005m : 0.01m; numericZ.Increment = numericZ.Maximum * 0.005m >= 0.01m ? numericZ.Maximum * 0.005m : 0.01m; numericA.Increment = numericA.Maximum * 0.005m >= 0.01m ? numericA.Maximum * 0.005m : 0.01m; numericX.Value = Convert.ToDecimal(ValueX); numericY.Value = Convert.ToDecimal(ValueY); numericZ.Value = Convert.ToDecimal(ValueZ); numericA.Value = Convert.ToDecimal(ValueA); }
protected override void UpdateControlObject() { ControlObject UIMax = ControlObject.GetControlObject("UIMax"); if (UIMax != null) { switch (UIMax.Type) { case "int": case "float": string[] value = parse(UIMax.Value); if (value.Length >= 1) { _UIMaxX = value[0]; _UIMaxY = value[0]; _UIMaxZ = value[0]; _UIMaxA = value[0]; } break; case "float2": string[] float2 = parse(UIMax.Value); if (float2.Length >= 2) { _UIMaxX = float2[0]; _UIMaxY = float2[1]; } break; case "float3": string[] float3 = parse(UIMax.Value); if (float3.Length >= 3) { _UIMaxX = float3[0]; _UIMaxY = float3[1]; _UIMaxZ = float3[2]; } break; case "float4": string[] float4 = parse(UIMax.Value); if (float4.Length >= 4) { _UIMaxX = float4[0]; _UIMaxY = float4[1]; _UIMaxZ = float4[2]; _UIMaxA = float4[3]; } break; } } ControlObject UIMin = ControlObject.GetControlObject("UIMin"); if (UIMin != null) { switch (UIMin.Type) { case "int": case "float": string[] value = parse(UIMin.Value); if (value.Length >= 1) { _UIMinX = value[0]; _UIMinY = value[0]; _UIMinZ = value[0]; _UIMinA = value[0]; } break; case "float2": string[] float2 = parse(UIMin.Value); if (float2.Length >= 2) { _UIMinX = float2[0]; _UIMinY = float2[1]; } break; case "float3": string[] float3 = parse(UIMin.Value); if (float3.Length >= 3) { _UIMinX = float3[0]; _UIMinY = float3[1]; _UIMinZ = float3[2]; } break; case "float4": string[] float4 = parse(UIMin.Value); if (float4.Length >= 4) { _UIMinX = float4[0]; _UIMinY = float4[1]; _UIMinZ = float4[2]; _UIMinA = float4[3]; } break; } } switch (ControlObject.Type) { case "int": case "float": string[] value = parse(ControlObject.Value); if (value.Length >= 1) { _ValueX = value[0]; _ValueY = UIMinY; _ValueZ = UIMinZ; _ValueA = UIMinA; } break; case "float2": string[] float2 = parse(ControlObject.Value); if (float2.Length >= 2) { _ValueX = float2[0]; _ValueY = float2[1]; _ValueZ = UIMinZ; _ValueA = UIMinA; } break; case "float3": string[] float3 = parse(ControlObject.Value); if (float3.Length >= 3) { _ValueX = float3[0]; _ValueY = float3[1]; _ValueZ = float3[2]; _ValueA = UIMinA; } break; case "float4": string[] float4 = parse(ControlObject.Value); if (float4.Length >= 4) { _ValueX = float4[0]; _ValueY = float4[1]; _ValueZ = float4[2]; _ValueA = float4[3]; } break; } string[] parse(string str) { Regex regex = new Regex(@"(float|float2|float3|float4|int)\((?<value>.*?)\)"); if (regex.IsMatch(str)) { return(Regex.Replace(regex.Match(str).Groups["value"].Value, @"\s", "").Split(',')); } return(new string[] { str, str, str, str }); //Length >= 4 } }
protected override void UpdateControlObject() { base.UpdateControlObject(); if (ControlObject.Type == "float4") { enabledRows.Add(tableLayoutPanel.RowStyles[4]); enabledRows.Add(tableLayoutPanel.RowStyles[3]); enabledRows.Add(tableLayoutPanel.RowStyles[2]); enabledRows.Add(tableLayoutPanel.RowStyles[1]); } else if (ControlObject.Type == "float3") { tableLayoutPanel.RowStyles[4].Height = 0; enabledRows.Add(tableLayoutPanel.RowStyles[3]); enabledRows.Add(tableLayoutPanel.RowStyles[2]); enabledRows.Add(tableLayoutPanel.RowStyles[1]); } else if (ControlObject.Type == "float2") { tableLayoutPanel.RowStyles[4].Height = 0; tableLayoutPanel.RowStyles[3].Height = 0; enabledRows.Add(tableLayoutPanel.RowStyles[2]); enabledRows.Add(tableLayoutPanel.RowStyles[1]); } else if (ControlObject.Type == "float" || ControlObject.Type == "int") { tableLayoutPanel.RowStyles[4].Height = 0; tableLayoutPanel.RowStyles[3].Height = 0; tableLayoutPanel.RowStyles[2].Height = 0; enabledRows.Add(tableLayoutPanel.RowStyles[1]); } Fold(); labelUIName.Image = IsColor ? Resources.color_swatch : null; labelUIName.Text = $"{ControlObject.GetControlObject("UIName")?.Value ?? ControlObject.Name}"; labelUIName.Update(); toolTip.SetToolTip(labelUIName, ControlObject.GetControlObject("UIHelp")?.Value); trackX.Maximum = IsColor ? 100 : (int)(Convert.ToSingle(UIMaxX) * 100f); trackY.Maximum = IsColor ? 100 : (int)(Convert.ToSingle(UIMaxY) * 100f); trackZ.Maximum = IsColor ? 100 : (int)(Convert.ToSingle(UIMaxZ) * 100f); trackA.Maximum = IsColor ? 100 : (int)(Convert.ToSingle(UIMaxA) * 100f); trackX.Minimum = IsColor ? 0 : (int)(Convert.ToSingle(UIMinX) * 100f); trackY.Minimum = IsColor ? 0 : (int)(Convert.ToSingle(UIMinY) * 100f); trackZ.Minimum = IsColor ? 0 : (int)(Convert.ToSingle(UIMinZ) * 100f); trackA.Minimum = IsColor ? 0 : (int)(Convert.ToSingle(UIMinA) * 100f); trackX.LargeChange = ControlObject.Type == "int" ? 100 : (int)(trackX.Maximum * 0.05f); trackY.LargeChange = ControlObject.Type == "int" ? 100 : (int)(trackX.Maximum * 0.05f); trackZ.LargeChange = ControlObject.Type == "int" ? 100 : (int)(trackX.Maximum * 0.05f); trackA.LargeChange = ControlObject.Type == "int" ? 100 : (int)(trackX.Maximum * 0.05f); trackX.Value = (int)(Convert.ToSingle(ValueX) * 100f); trackY.Value = (int)(Convert.ToSingle(ValueY) * 100f); trackZ.Value = (int)(Convert.ToSingle(ValueZ) * 100f); trackA.Value = (int)(Convert.ToSingle(ValueA) * 100f); textX.Text = ValueX; textY.Text = ValueY; textZ.Text = ValueZ; textA.Text = ValueA; }