/// <summary>
        /// Create new selection that result of toggle selection given two selections.
        /// </summary>
        /// <param name="selection">Current selection</param>
        /// <param name="newSelection">New selection</param>
        /// <returns>Toggle selection result.</returns>
        public static EditCurveKeySelection ToggleSelection(
            EditCurveKeySelection selection, EditCurveKeySelection newSelection)
        {
            EditCurveKeySelection result = selection.Clone();

            foreach (long key in newSelection.Keys)
            {
                EditCurveSelections s;
                if (result.TryGetValue(key, out s))
                {
                    // Both selection contains same key, toggle selections value.
                    s = s ^ newSelection[key];

                    if (s != EditCurveSelections.None)
                    {
                        result[key] = s;
                    }
                    else
                    {
                        result.Remove(key);
                    }
                }
                else
                {
                    result.Add(key, newSelection[key]);
                }
            }

            return(result);
        }
Пример #2
0
        public EditCurveKeyAddRemoveCommand(EditCurve curve, EditCurveKey addKey,
                                            EditCurveKeySelection selection)
        {
            this.curve     = curve;
            this.addKey    = true;
            this.selection = selection.Clone();

            keys = new List <EditCurveKey>();
            keys.Add(addKey.Clone());
        }