示例#1
0
        /// <summary>
        /// EndUpdate and generate Undo/Redo command buffer if there is any
        /// modification happend since BeginUpdate called.
        /// </summary>
        public void EndUpdate()
        {
            if (!inUpdating)
                throw new InvalidOperationException(
                    "You must call BeginUpdate before call EndUpdate.");

            // Compare modified key values.
            if (modifiedKeys != null && modifiedKeys.Count > 0)
            {
                List<EditCurveKey> oldKeyValues =
                    new List<EditCurveKey>(modifiedKeys.Count);

                List<EditCurveKey> newKeyValues =
                    new List<EditCurveKey>(modifiedKeys.Count);

                foreach (EditCurveKey savedKey in modifiedKeys.Values)
                {
                    EditCurveKey curKey;
                    if (keys.TryGetValue(savedKey.Id, out curKey))
                    {
                        if (!curKey.Equals(savedKey))
                        {
                            // Saved value is already cloned.
                            oldKeyValues.Add(savedKey);
                            newKeyValues.Add(curKey.Clone());
                        }
                    }
                }

                if (newKeyValues.Count != 0)
                {
                    dirty = true;
                    if (commandHistory != null)
                        commandHistory.Add(new EditCurveKeyUpdateCommand(
                            this, oldKeyValues, newKeyValues));
                }
            }
            modifiedKeys = null;

            // Compare states
            bool stateChanged = state != savedState;
            if (commandHistory != null && stateChanged)
                commandHistory.Add(new EditCurveStateChangeCommand(
                    this, savedState, state));

            savedState = null;
            inUpdating = false;

            if (stateChanged) FireStateChangeEvent();
        }
示例#2
0
        /// <summary>
        /// Apply new EditCurveState.
        /// </summary>
        /// <param name="newState"></param>
        public void ApplyState(EditCurveState newState)
        {
            if (newState == null) throw new ArgumentNullException("newState");

            inUpdating = true;
            Name = newState.Name;
            PreLoop = newState.PreLoop;
            PostLoop = newState.PostLoop;
            inUpdating = false;
            FireStateChangeEvent();
        }
示例#3
0
        /// <summary>
        /// Begin update curve parameters.
        /// </summary>
        /// <remarks>It records curve satte and key values modification between
        /// BeginUpdate and EndUpdate method.</remarks>
        public void BeginUpdate()
        {
            if (inUpdating)
                throw new InvalidOperationException("BeginUpdate called twice.");

            modifiedKeys = new Dictionary<long, EditCurveKey>();
            savedState = (EditCurveState)state.Clone();

            inUpdating = true;
        }
        public EditCurveStateChangeCommand(EditCurve curve, EditCurveState oldState,
                                                                EditCurveState newState)
        {
            if (oldState == null) throw new ArgumentNullException("oldState");
            if (newState == null) throw new ArgumentNullException("newState");

            this.curve = curve;
            this.oldState = (EditCurveState)oldState.Clone();
            this.newState = (EditCurveState)newState.Clone();
        }