private void UpdateChasePanel() { try { lblError.Text = ""; ClearChasePanels(); ChaseType chaseType; if (Enum.TryParse(cboChaseType.SelectedValue.ToString().Replace(" ", "_"), out chaseType)) { switch (chaseType) { case ChaseType.Linear_Velocity: if (_panel_LinearVelocity != null) { _object_LinearVelocity = _panel_LinearVelocity.GetChaseObject(_bodyBall); } break; case ChaseType.Linear_Force: if (_panel_LinearForce != null) { _object_LinearForce = _panel_LinearForce.GetChaseObject_Linear(_bodyBall); } break; case ChaseType.Orientation_Velocity: if (_panel_OrientationVelocity != null) { _object_OrientationVelocity = _panel_OrientationVelocity.GetChaseObject(_bodyBall); } break; case ChaseType.Orientation_Torque: if (_panel_OrientationForce != null) { _object_OrientationForce = _panel_OrientationForce.GetChaseObject_Orientation(_bodyBall); } break; default: throw new ApplicationException("Unknown ChaseType: " + chaseType.ToString()); } } } catch (Exception ex) { lblError.Text = ex.Message; } }
private void ClearChasePanels() { if (_object_LinearVelocity != null) { _object_LinearVelocity.Dispose(); _object_LinearVelocity = null; } if (_object_LinearForce != null) { _object_LinearForce.Dispose(); _object_LinearForce = null; } if (_object_OrientationVelocity != null) { _object_OrientationVelocity.Dispose(); _object_OrientationVelocity = null; } if (_object_OrientationForce != null) { _object_OrientationForce.Dispose(); _object_OrientationForce = null; } }