Exemplo n.º 1
0
        public AddOrUpdateKeyframeCommand(double time, double value, OperatorPart opPartToAddKeyframe)
        {
            var          newKey      = new VDefinition();
            OperatorPart curveOpPart = Animation.GetRegardingAnimationOpPart(opPartToAddKeyframe);

            if (curveOpPart != null)
            {
                // already existing animation, so check for previous keyframe
                var curve = curveOpPart.Func as ICurve;
                if (curve.HasVAt(time))
                {
                    _previousKeyframeValue = curve.GetV(time);
                }

                double?prevU = curve.GetPreviousU(time);
                if (prevU != null)
                {
                    newKey = curve.GetV(prevU.Value);
                }
            }

            newKey.Value = value;

            KeyframeTime          = time;
            _initialKeyframeTime  = time;
            _previousKeyframeTime = time;
            KeyframeValue         = newKey;
            StoreRelevantIds(curveOpPart);
        }
Exemplo n.º 2
0
 public void InitFromVDefinition(VDefinition vdef)
 {
     m_vdef = vdef;
     V      = vdef.Value;
     LeftInterpolationType  = vdef.InEditMode;
     RightInterpolationType = vdef.OutEditMode;
     UpdateControlTangents();
 }
Exemplo n.º 3
0
 public CurvePointControl(double defaultU, VDefinition vdef, ICurve curve, CurveEditor ce)
 {
     InitializeComponent();
     m_CE = ce;
     U    = defaultU;
     InitFromVDefinition(vdef);
     Curve = curve;
     createCount++;
     createBindingsForPositioning();
     XCenterThumb.Cursor = Cursors.Arrow;
     Loaded += CurvePointControl_Loaded;
 }
Exemplo n.º 4
0
        public AddOrUpdateKeyframeCommand(double time, double value, Operator compositionOp, Guid curveInstanceId, Guid curveOpPartId)
        {
            var newKey = new VDefinition()
            {
                Value = value
            };

            KeyframeTime                    = time;
            _previousKeyframeTime           = time;
            KeyframeValue                   = newKey;
            _curveOpToAddKeyframeInstanceID = curveInstanceId;
            StoreCompositionOpIds(compositionOp);
        }
Exemplo n.º 5
0
        public AddOrUpdateKeyframeCommand(double time, VDefinition keyValue, ICurve curve)
        {
            var          func        = curve as OperatorPart.Function;
            OperatorPart curveOpPart = func.OperatorPart;

            if (curve.HasVAt(time))
            {
                _previousKeyframeValue = curve.GetV(time);
            }

            KeyframeTime          = time;
            _initialKeyframeTime  = time;
            _previousKeyframeTime = time;
            KeyframeValue         = keyValue;
            StoreRelevantIds(curveOpPart);
        }
Exemplo n.º 6
0
        private void OnDragDelta(object sender, DragDeltaEventArgs e)
        {
            var delta = new Vector(e.HorizontalChange, e.VerticalChange);

            double deltaU = CurveEditor.xToU(delta.X) - CurveEditor.xToU(0);
            double deltaV = CurveEditor.yToV(delta.Y) - CurveEditor.yToV(0);

            if (m_MoveDirection == MoveDirection.Undecided)
            {
                if (Math.Abs(delta.X) + Math.Abs(delta.Y) > DRAG_THRESHOLD)
                {
                    if (Math.Abs(delta.X) > Math.Abs(delta.Y))
                    {
                        m_MoveDirection     = MoveDirection.Horizontal;
                        XCenterThumb.Cursor = Cursors.ScrollWE;
                    }
                    else
                    {
                        m_MoveDirection     = MoveDirection.Vertical;
                        XCenterThumb.Cursor = Cursors.ScrollNS;
                    }
                }
            }
            else
            {
                CurveEditor.DisableRebuildOnCurveChangeEvents();

                if (m_MoveDirection == MoveDirection.Vertical)
                {
                    V += deltaV;
                }

                if (m_MoveDirection == MoveDirection.Horizontal)
                {
                    // Snap when pressing Shift
                    if (TV != null &&
                        TV.TimeSnapHandler != null &&
                        Keyboard.Modifiers == ModifierKeys.Shift)
                    {
                        var snapU = TV.TimeSnapHandler.CheckForSnapping(U + deltaU);
                        if (!Double.IsNaN(snapU))
                        {
                            deltaU = snapU - U;
                        }
                    }

                    // Prevent overwriting existing keys
                    ManipulateU(U + deltaU);
                }

                switch (m_MoveDirection)
                {
                case MoveDirection.Vertical:
                    _addOrUpdateKeyframeCommand.KeyframeValue = m_vdef;
                    _addOrUpdateKeyframeCommand.Do();
                    break;

                case MoveDirection.Horizontal:
                    _moveKeyframeCommand.NewTime = U;
                    //_moveKeyframeCommand.Do();
                    break;
                }

                m_vdef = Curve.GetV(U);     // since SetOrUpdateV clones vdef, we have to get a new value

                if (TV != null)
                {
                    TV.TriggerRepaint();
                }

                UpdateControlTangents();
                CurveEditor.EnableRebuildOnCurveChangeEvents();
                App.Current.UpdateRequiredAfterUserInteraction = true;
                CurveEditor.UpdateLine(Curve);
                //CurveEditor.UpdateEditBox();
            }
        }