public SetBothTangentsCommand(CurveEditorControl2 control, CurveEditorControlsViewModel viewModel, KeyTangentMode tangentMode)
 {
     _control          = control;
     _viewModel        = viewModel;
     _tangentMode      = tangentMode;
     CanExecuteChanged = delegate { };
 }
Exemple #2
0
 internal void SetOutTangent(float tangent, bool computeTangents = true)
 {
     Key.TangentOut = tangent;
     TangentOutMode = KeyTangentMode.Custom;
     if (computeTangents)
     {
         Curve.ComputeTangents();
     }
 }
Exemple #3
0
 /// <summary>
 /// Initializes a KeyWrapper
 /// </summary>
 /// <param name="curveKey">The key to wrap</param>
 /// <param name="curve">The curve that owns curveKey</param>
 /// <param name="id">Pass -1 to autogenerate a new id</param>
 public KeyWrapper(CurveKey curveKey, CurveWrapper curve, KeyTangentMode tangentMode, long id = -1)
 {
     if (id < 0)
         Id = latestId++;
     else
         Id = id;
     Curve = curve;
     Key = curveKey;
     tangentInMode = tangentMode;
     tangentOutMode = tangentMode;
 }
Exemple #4
0
 public void Execute(object parameter)
 {
     if (parameter != null)
     {
         KeyTangentMode mode = (KeyTangentMode)Enum.Parse(typeof(KeyTangentMode), (string)parameter);
         control.SetTangentModes(mode, mode);
     }
     else
     {
         control.SetTangentModes(tangentMode, tangentMode);
     }
     viewModel.OnTangentChanged();
 }
        /// <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;
        }
Exemple #6
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;
        }
        /// <summary>
        ///     Creates a new command to select the given keys. You can pass null to deselect all.
        /// </summary>
        public ChangeTangentModeCommand(CurveEditorControl2 control, KeyTangentMode? newTangentInMode, KeyTangentMode? newTangentOutMode)
            : base(control)
        {
            // Store the parameters.
            _newTangentInMode = newTangentInMode;
            _newTangentOutMode = newTangentOutMode;

            // Store the current selection, if any.
            _affectedKeys = new long[control.Selection.Count];
            var i = 0;
            foreach (var key in control.Selection) {
                _affectedKeys[i++] = key.Id;
            }
        }
Exemple #8
0
 /// <summary>
 /// Initializes a KeyWrapper
 /// </summary>
 /// <param name="curveKey">The key to wrap</param>
 /// <param name="curve">The curve that owns curveKey</param>
 /// <param name="id">Pass -1 to autogenerate a new id</param>
 public KeyWrapper(CurveKey curveKey, CurveWrapper curve, KeyTangentMode tangentMode, long id = -1)
 {
     if (id < 0)
     {
         Id = latestId++;
     }
     else
     {
         Id = id;
     }
     Curve          = curve;
     Key            = curveKey;
     tangentInMode  = tangentMode;
     tangentOutMode = tangentMode;
 }
 public SetBothTangentsCommand(CurveEditorControl2 control, CurveEditorControlsViewModel viewModel, KeyTangentMode tangentMode)
 {
     _control = control;
     _viewModel = viewModel;
     _tangentMode = tangentMode;
     CanExecuteChanged = delegate { };
 }
Exemple #10
0
 internal void SetOutTangent(float tangent, bool computeTangents = true)
 {
     Key.TangentOut = tangent;
     TangentOutMode = KeyTangentMode.Custom;
     if (computeTangents)
         Curve.ComputeTangents();
 }
Exemple #11
0
 /// <summary>
 /// Returns true if the passed KeyTangentMode is automatically, i.e. it is
 /// supposed to be calculated everytime the key is moved.
 /// </summary>
 public bool IsTangentModeAuto(KeyTangentMode tangentMode)
 {
     return tangentMode == KeyTangentMode.Smooth || tangentMode == KeyTangentMode.Linear || tangentMode == KeyTangentMode.Flat;
 }
Exemple #12
0
 public SetBothTangentsCommand(CurveEditorControl2 control, CurveEditorControlsViewModel viewModel, KeyTangentMode tangentMode)
 {
     this.control     = control;
     this.viewModel   = viewModel;
     this.tangentMode = tangentMode;
 }
Exemple #13
0
 /// <summary>
 /// Returns true if the passed KeyTangentMode is automatically, i.e. it is
 /// supposed to be calculated everytime the key is moved.
 /// </summary>
 public bool IsTangentModeAuto(KeyTangentMode tangentMode)
 {
     return(tangentMode == KeyTangentMode.Smooth || tangentMode == KeyTangentMode.Linear || tangentMode == KeyTangentMode.Flat);
 }