Wraps a CurveKey, giving it an ID and a reference to it's owner curve.
コード例 #1
0
ファイル: CurveWrapper.cs プロジェクト: edwinsyarief/Gearset
        /// <summary>
        /// This is the method to use when removing a key in the editor. It will remove
        /// the corresponding KeyWrapper from the control.
        /// </summary>
        /// <param name="key"></param>
        public void RemoveKey(long id)
        {
            KeyWrapper wrapper = Control.Keys[id];

            Control.Keys.Remove(wrapper);
            Curve.Keys.Remove(wrapper.Key);
            ComputeTangents();
        }
コード例 #2
0
        public override void Undo()
        {
            KeyWrapper key = Control.Keys[affectedKey];

            key.SetInTangent(prevTangentInValue);
            key.SetOutTangent(prevTangentOutValue);
            key.TangentInMode  = prevTangentInMode;
            key.TangentOutMode = prevTangentOutMode;
        }
コード例 #3
0
ファイル: ScaleKeysCommand.cs プロジェクト: nanexcool/Gearset
 /// <summary>
 /// Performs the actual movement of the keys.
 /// </summary>
 private void ScaleKeys(Point newMin, Point newMax)
 {
     for (int i = 0; i < affectedKeys.Length; i++)
     {
         // Remap to the new box;
         Point      newPosition = new Point((newMax.X - newMin.X) * normalizedPos[i].X + newMin.X, (newMax.Y - newMin.Y) * normalizedPos[i].Y + newMin.Y);
         KeyWrapper k           = Control.Keys[affectedKeys[i]];
         k.MoveKey((float)(newPosition.X - k.Key.Position), (float)(newPosition.Y - k.Key.Value));
     }
 }
コード例 #4
0
ファイル: CurveWrapper.cs プロジェクト: edwinsyarief/Gearset
        /// <summary>
        /// This is the method to use when adding a key in the editor. It will create
        /// the corresponding KeyWrapper and add it to the control.
        /// </summary>
        public KeyWrapper AddKey(CurveKey key, long id = -1)
        {
            Curve.Keys.Add(key);
            KeyWrapper newKey = new KeyWrapper(key, this, KeyTangentMode.Smooth, id);

            Control.Keys.Add(newKey);
            ComputeTangents();

            return(newKey);
        }
コード例 #5
0
ファイル: CurveWrapper.cs プロジェクト: edwinsyarief/Gearset
 /// <summary>
 /// Computes the tangents of all automatic keys.
 /// </summary>
 public void ComputeTangents()
 {
     for (int i = 0; i < Curve.Keys.Count; i++)
     {
         KeyWrapper wrapper = Control.GetWrapper(Curve.Keys[i]);
         if (wrapper != null)
         {
             wrapper.ComputeTangentIfAuto();
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// Performs the actual movement of the keys.
        /// </summary>
        private void ChangeTangent(float tangent)
        {
            KeyWrapper key = Control.Keys[affectedKey];

            if (selectedTangent == TangentSelectionMode.In)
            {
                key.SetInTangent(tangent);
            }
            else
            {
                key.SetOutTangent(tangent);
            }
        }
コード例 #7
0
        /// <summary>
        /// Creates a new command to select the given keys. You can pass null to deselect all.
        /// </summary>
        public ChangeTangentCommand(CurveEditorControl2 control, long keyId, TangentSelectionMode selectedTangent)
            : base(control)
        {
            // Store the parameters.
            this.selectedTangent = selectedTangent;
            this.affectedKey     = keyId;

            KeyWrapper key = control.Keys[keyId];

            prevTangentInValue  = key.Key.TangentIn;
            prevTangentOutValue = key.Key.TangentOut;
            prevTangentInMode   = key.TangentInMode;
            prevTangentOutMode  = key.TangentOutMode;
        }
コード例 #8
0
        /// <summary>
        /// Performs the actual movement of the keys.
        /// </summary>
        private void MoveKeys(float positionOffset, float valueOffset)
        {
            List <CurveWrapper> affectedCurves = new List <CurveWrapper>();

            for (int i = 0; i < affectedKeys.Length; i++)
            {
                KeyWrapper key = Control.Keys[affectedKeys[i]];
                key.MoveKey(positionOffset, valueOffset);

                // Create the set of curve affected by this move so we can recalculate
                // the auto tangents.
                if (!affectedCurves.Contains(key.Curve))
                {
                    affectedCurves.Add(key.Curve);
                }
            }

            // Compute all auto tangents.
            foreach (CurveWrapper curve in affectedCurves)
            {
                curve.ComputeTangents();
            }
        }
コード例 #9
0
ファイル: CurveWrapper.cs プロジェクト: edwinsyarief/Gearset
 /// <summary>
 /// This method is only to be used when undoing a RemoveKeys command.
 /// </summary>
 internal void RestoreKey(KeyWrapper key)
 {
     Curve.Keys.Add(key.Key);
     Control.Keys.Add(key);
     ComputeTangents();
 }
コード例 #10
0
ファイル: CurveWrapper.cs プロジェクト: bartwe/Gearset
 /// <summary>
 ///     This method is only to be used when undoing a RemoveKeys command.
 /// </summary>
 internal void RestoreKey(KeyWrapper key)
 {
     Curve.Keys.Add(key.Key);
     Control.Keys.Add(key);
     ComputeTangents();
 }
コード例 #11
0
ファイル: CurveWrapper.cs プロジェクト: bartwe/Gearset
        /// <summary>
        ///     This is the method to use when adding a key in the editor. It will create
        ///     the corresponding KeyWrapper and add it to the control.
        /// </summary>
        public KeyWrapper AddKey(CurveKey key, long id = -1)
        {
            Curve.Keys.Add(key);
            var newKey = new KeyWrapper(key, this, KeyTangentMode.Smooth, id);
            Control.Keys.Add(newKey);
            ComputeTangents();

            return newKey;
        }