private void ChangeLight(NuGenSVisualLib.Rendering.Lighting.Light light) { if (light != null) { currentLight = light; uiLightEnabled.Checked = light.Enabled; uiColorButton1.SelectedColor = light.Clr; uiLightCastShadows.Checked = light.CastShadows; // load correct control if (light is DirectionalLight) { DirectionalLightControl control = new DirectionalLightControl(); control.Dock = DockStyle.Fill; control.SetData((DirectionalLight)light); control.OnValueUpdate += new EventHandler(control_OnValueUpdate); uiLightingPropPanel.Controls.Add(control); uiLightingPropGroup.Enabled = true; currentLight = light; } else { currentLight = null; foreach (Control control in uiLightingPropPanel.Controls) { control.Dispose(); } uiLightingPropPanel.Controls.Clear(); uiLightingPropGroup.Enabled = false; } } else { currentLight = null; foreach (Control control in uiLightingPropPanel.Controls) { control.Dispose(); } uiLightingPropPanel.Controls.Clear(); uiLightingPropGroup.Enabled = false; } }