private void cboChaseType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (!_initialized)
                {
                    return;
                }

                ClearChasePanels();

                if (cboChaseType.SelectedValue == null || cboChaseType.SelectedValue.ToString() == "")
                {
                    pnlChaseSettings.Child = null;

                    //TODO: Store a null chase object
                }
                else
                {
                    string text = cboChaseType.SelectedValue.ToString().Replace(" ", "_");

                    ChaseType chaseType;
                    if (Enum.TryParse(text, out chaseType))
                    {
                        switch (chaseType)
                        {
                            case ChaseType.Linear_Velocity:
                                #region Linear_Velocity

                                if (_panel_LinearVelocity == null)
                                {
                                    _panel_LinearVelocity = new LinearVelocity();
                                    _panel_LinearVelocity.Foreground = Brushes.White;
                                    _panel_LinearVelocity.ValueChanged += new EventHandler(PanelChaseSettings_ValueChanged);
                                }

                                pnlChaseSettings.Child = _panel_LinearVelocity;

                                expandChasePosition.IsExpanded = true;

                                #endregion
                                break;

                            case ChaseType.Linear_Force:
                                #region Linear_Force

                                if (_panel_LinearForce == null)
                                {
                                    _panel_LinearForce = new ForceCollection(true);
                                    _panel_LinearForce.Foreground = Brushes.White;
                                    _panel_LinearForce.ValueChanged += new EventHandler(PanelChaseSettings_ValueChanged);
                                }

                                pnlChaseSettings.Child = _panel_LinearForce;

                                expandChasePosition.IsExpanded = true;

                                #endregion
                                break;

                            case ChaseType.Orientation_Velocity:
                                #region Orientation_Velocity

                                if (_panel_OrientationVelocity == null)
                                {
                                    _panel_OrientationVelocity = new OrientationVelocity();
                                    _panel_OrientationVelocity.Foreground = Brushes.White;
                                    _panel_OrientationVelocity.ValueChanged += new EventHandler(PanelChaseSettings_ValueChanged);
                                }

                                pnlChaseSettings.Child = _panel_OrientationVelocity;

                                expandChaseOrientation.IsExpanded = true;

                                #endregion
                                break;

                            case ChaseType.Orientation_Torque:
                                #region Orientation_Torque

                                if (_panel_OrientationForce == null)
                                {
                                    _panel_OrientationForce = new ForceCollection(false);
                                    _panel_OrientationForce.Foreground = Brushes.White;
                                    _panel_OrientationForce.ValueChanged += new EventHandler(PanelChaseSettings_ValueChanged);
                                }

                                pnlChaseSettings.Child = _panel_OrientationForce;

                                expandChaseOrientation.IsExpanded = true;

                                #endregion
                                break;

                            default:
                                throw new ApplicationException("Unknown ChaseType: " + chaseType.ToString());
                        }

                        UpdateChasePanel();
                    }
                    else
                    {
                        throw new ApplicationException("Unknown ChaseType: " + text);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #2
0
        private void cboChaseType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (!_initialized)
                {
                    return;
                }

                ClearChasePanels();

                if (cboChaseType.SelectedValue == null || cboChaseType.SelectedValue.ToString() == "")
                {
                    pnlChaseSettings.Child = null;

                    //TODO: Store a null chase object
                }
                else
                {
                    string text = cboChaseType.SelectedValue.ToString().Replace(" ", "_");

                    ChaseType chaseType;
                    if (Enum.TryParse(text, out chaseType))
                    {
                        switch (chaseType)
                        {
                        case ChaseType.Linear_Velocity:
                            #region Linear_Velocity

                            if (_panel_LinearVelocity == null)
                            {
                                _panel_LinearVelocity               = new LinearVelocity();
                                _panel_LinearVelocity.Foreground    = Brushes.White;
                                _panel_LinearVelocity.ValueChanged += new EventHandler(PanelChaseSettings_ValueChanged);
                            }

                            pnlChaseSettings.Child = _panel_LinearVelocity;

                            expandChasePosition.IsExpanded = true;

                            #endregion
                            break;

                        case ChaseType.Linear_Force:
                            #region Linear_Force

                            if (_panel_LinearForce == null)
                            {
                                _panel_LinearForce               = new ForceCollection(true);
                                _panel_LinearForce.Foreground    = Brushes.White;
                                _panel_LinearForce.ValueChanged += new EventHandler(PanelChaseSettings_ValueChanged);
                            }

                            pnlChaseSettings.Child = _panel_LinearForce;

                            expandChasePosition.IsExpanded = true;

                            #endregion
                            break;

                        case ChaseType.Orientation_Velocity:
                            #region Orientation_Velocity

                            if (_panel_OrientationVelocity == null)
                            {
                                _panel_OrientationVelocity               = new OrientationVelocity();
                                _panel_OrientationVelocity.Foreground    = Brushes.White;
                                _panel_OrientationVelocity.ValueChanged += new EventHandler(PanelChaseSettings_ValueChanged);
                            }

                            pnlChaseSettings.Child = _panel_OrientationVelocity;

                            expandChaseOrientation.IsExpanded = true;

                            #endregion
                            break;

                        case ChaseType.Orientation_Torque:
                            #region Orientation_Torque

                            if (_panel_OrientationForce == null)
                            {
                                _panel_OrientationForce               = new ForceCollection(false);
                                _panel_OrientationForce.Foreground    = Brushes.White;
                                _panel_OrientationForce.ValueChanged += new EventHandler(PanelChaseSettings_ValueChanged);
                            }

                            pnlChaseSettings.Child = _panel_OrientationForce;

                            expandChaseOrientation.IsExpanded = true;

                            #endregion
                            break;

                        default:
                            throw new ApplicationException("Unknown ChaseType: " + chaseType.ToString());
                        }

                        UpdateChasePanel();
                    }
                    else
                    {
                        throw new ApplicationException("Unknown ChaseType: " + text);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }