Пример #1
0
        private static void SetDirectionInCombobox(ComboBox combo, ChaseDirectionType direction)
        {
            string searchFor = null;

            switch (direction)
            {
            case ChaseDirectionType.Attract_Direction:
                searchFor = DIRECTION_DIRECTION;
                break;

            case ChaseDirectionType.Drag_Velocity_Along:
                searchFor = DIRECTION_VELOCITY_ALONG;
                break;

            case ChaseDirectionType.Drag_Velocity_AlongIfVelocityAway:
                searchFor = DIRECTION_VELOCITY_ALONGIFAWAY;
                break;

            case ChaseDirectionType.Drag_Velocity_AlongIfVelocityToward:
                searchFor = DIRECTION_VELOCITY_ALONGIFTOWARD;
                break;

            case ChaseDirectionType.Drag_Velocity_Any:
                searchFor = DIRECTION_VELOCITY_ANY;
                break;

            case ChaseDirectionType.Drag_Velocity_Orth:
                searchFor = DIRECTION_VELOCITY_ORTH;
                break;

            default:
                throw new ApplicationException("Unknown ChasePoint_DirectionType: " + direction.ToString());
            }

            bool foundIt = false;

            for (int cntr = 0; cntr < combo.Items.Count; cntr++)
            {
                TextBlock item = (TextBlock)combo.Items[cntr];

                if (item.Text == searchFor)
                {
                    combo.SelectedIndex = cntr;
                    foundIt             = true;
                    break;
                }
            }

            if (!foundIt)
            {
                throw new ApplicationException("Didn't find the direction in the combo box items: " + direction.ToString());
            }
        }
Пример #2
0
        public static ForceEntry GetNewEntry_Orientation(ChaseDirectionType direction, double value, bool isAccel = true, bool isSpring = false, GradientEntry[] gradient = null)
        {
            ForceEntry retVal = new ForceEntry(false);

            SetDirectionInCombobox(retVal.cboDirection, direction);

            retVal.trkValue.Value   = value;
            retVal.trkValue.Maximum = value * 4;

            retVal.chkIsAccel.IsChecked  = isAccel;
            retVal.chkIsSpring.IsChecked = isSpring;

            retVal.StoreGradient(gradient);

            return(retVal);
        }
Пример #3
0
        public ChaseOrientation_Torque GetChaseObject_Orientation()
        {
            if (_isLinear)
            {
                throw new InvalidOperationException("This method can only be called when the control represents orientation");
            }

            if (!chkEnabled.IsChecked.Value)
            {
                return(null);
            }

            ChaseDirectionType direction = GetDirectionFromCombobox(cboDirection);

            return(new ChaseOrientation_Torque(
                       direction,
                       trkValue.Value,
                       chkIsAccel.IsChecked.Value,
                       chkIsSpring.IsChecked.Value,
                       _gradient));
        }
Пример #4
0
        public ChaseOrientation_Torque(ChaseDirectionType direction, double value, bool isAccel = true, bool isSpring = false, GradientEntry[] gradient = null)
        {
            if (gradient != null && gradient.Length == 1)
            {
                throw new ArgumentException("Gradient must have at least two items if it is populated");
            }

            Direction = direction;
            Value     = value;
            IsAccel   = isAccel;
            IsSpring  = isSpring;

            if (gradient == null || gradient.Length == 0)
            {
                Gradient = null;
            }
            else
            {
                Gradient = gradient;
            }
        }
Пример #5
0
        private static void SetDirectionInCombobox(ComboBox combo, ChaseDirectionType direction)
        {
            string searchFor = null;
            switch (direction)
            {
                case ChaseDirectionType.Attract_Direction:
                    searchFor = DIRECTION_DIRECTION;
                    break;

                case ChaseDirectionType.Drag_Velocity_Along:
                    searchFor = DIRECTION_VELOCITY_ALONG;
                    break;

                case ChaseDirectionType.Drag_Velocity_AlongIfVelocityAway:
                    searchFor = DIRECTION_VELOCITY_ALONGIFAWAY;
                    break;

                case ChaseDirectionType.Drag_Velocity_AlongIfVelocityToward:
                    searchFor = DIRECTION_VELOCITY_ALONGIFTOWARD;
                    break;

                case ChaseDirectionType.Drag_Velocity_Any:
                    searchFor = DIRECTION_VELOCITY_ANY;
                    break;

                case ChaseDirectionType.Drag_Velocity_Orth:
                    searchFor = DIRECTION_VELOCITY_ORTH;
                    break;

                default:
                    throw new ApplicationException("Unknown ChasePoint_DirectionType: " + direction.ToString());
            }

            bool foundIt = false;

            for (int cntr = 0; cntr < combo.Items.Count; cntr++)
            {
                TextBlock item = (TextBlock)combo.Items[cntr];

                if (item.Text == searchFor)
                {
                    combo.SelectedIndex = cntr;
                    foundIt = true;
                    break;
                }
            }

            if (!foundIt)
            {
                throw new ApplicationException("Didn't find the direction in the combo box items: " + direction.ToString());
            }
        }
Пример #6
0
        public static ForceEntry GetNewEntry_Orientation(ChaseDirectionType direction, double value, bool isAccel = true, bool isSpring = false, Tuple<double, double>[] gradient = null)
        {
            ForceEntry retVal = new ForceEntry(false);

            SetDirectionInCombobox(retVal.cboDirection, direction);

            retVal.trkValue.Value = value;
            retVal.trkValue.Maximum = value * 4;

            retVal.chkIsAccel.IsChecked = isAccel;
            retVal.chkIsSpring.IsChecked = isSpring;

            retVal.StoreGradient(gradient);

            return retVal;
        }
Пример #7
0
        private static void GetDesiredVector(out Vector3D unit, out double length, ChasePoint_GetForceArgs e, ChaseDirectionType direction)
        {
            switch (direction)
            {
            case ChaseDirectionType.Drag_Velocity_Along:
            case ChaseDirectionType.Drag_Velocity_AlongIfVelocityAway:
            case ChaseDirectionType.Drag_Velocity_AlongIfVelocityToward:
                unit   = e.VelocityAlongUnit;
                length = e.VelocityAlongLength;
                break;

            case ChaseDirectionType.Attract_Direction:
                unit   = e.DirectionUnit;
                length = e.DirectionLength;
                break;

            case ChaseDirectionType.Drag_Velocity_Any:
                unit   = e.VelocityUnit;
                length = e.VelocityLength;
                break;

            case ChaseDirectionType.Drag_Velocity_Orth:
                unit   = e.VelocityOrthUnit;
                length = e.VelocityOrthLength;
                break;

            default:
                throw new ApplicationException("Unknown DirectionType: " + direction.ToString());
            }
        }
        private static void GetDesiredVector(out Vector3D unit, out double length, ChaseOrientation_GetTorqueArgs e, ChaseDirectionType direction)
        {
            switch (direction)
            {
                case ChaseDirectionType.Drag_Velocity_Along:
                case ChaseDirectionType.Drag_Velocity_AlongIfVelocityAway:
                case ChaseDirectionType.Drag_Velocity_AlongIfVelocityToward:
                    unit = e.AngVelocityAlongUnit;
                    length = e.AngVelocityAlongLength;
                    break;

                case ChaseDirectionType.Attract_Direction:
                    unit = e.Rotation.Axis;
                    length = e.Rotation.Angle;
                    break;

                case ChaseDirectionType.Drag_Velocity_Any:
                    unit = e.AngVelocityUnit;
                    length = e.AngVelocityLength;
                    break;

                case ChaseDirectionType.Drag_Velocity_Orth:
                    unit = e.AngVelocityOrthUnit;
                    length = e.AngVelocityOrthLength;
                    break;

                default:
                    throw new ApplicationException("Unknown DirectionType: " + direction.ToString());
            }
        }
        public ChaseOrientation_Torque(ChaseDirectionType direction, double value, bool isAccel = true, bool isSpring = false, Tuple<double, double>[] gradient = null)
        {
            if (gradient != null && gradient.Length == 1)
            {
                throw new ArgumentException("Gradient must have at least two items if it is populated");
            }

            this.Direction = direction;
            this.Value = value;
            this.IsAccel = isAccel;
            this.IsSpring = isSpring;

            if (gradient == null || gradient.Length == 0)
            {
                this.Gradient = null;
            }
            else
            {
                this.Gradient = gradient;
            }
        }