private void UpdateControls(Color color) { // What in the F**K TextBoxNumeric redBox = FindChildByName("RedBox", false) as TextBoxNumeric; if (redBox != null) { redBox.SetText(color.R.ToString(), false); } TextBoxNumeric greenBox = FindChildByName("GreenBox", false) as TextBoxNumeric; if (greenBox != null) { greenBox.SetText(color.G.ToString(), false); } TextBoxNumeric blueBox = FindChildByName("BlueBox", false) as TextBoxNumeric; if (blueBox != null) { blueBox.SetText(color.B.ToString(), false); } m_After.Color = color; if (ColorChanged != null) { ColorChanged.Invoke(this); } }
private void updateControls(Color color) { // [???] TODO: Make this code safer. // [halfofastaple] This code SHOULD (in theory) never crash/not work as intended, but referencing children by their name is unsafe. // Instead, a direct reference to their objects should be maintained. Worst case scenario, we grab the wrong "RedBox". TextBoxNumeric redBox = FindChildByName("RedBox", false) as TextBoxNumeric; if (redBox != null) { redBox.SetText(color.R.ToString(), false); } TextBoxNumeric greenBox = FindChildByName("GreenBox", false) as TextBoxNumeric; if (greenBox != null) { greenBox.SetText(color.G.ToString(), false); } TextBoxNumeric blueBox = FindChildByName("BlueBox", false) as TextBoxNumeric; if (blueBox != null) { blueBox.SetText(color.B.ToString(), false); } after.Color = color; if (ColorChanged != null) { ColorChanged.Invoke(this, EventArgs.Empty); } }