public bool  Equals(EditCurveKeySelection other)
        {
            if (other == null)
            {
                return(false);
            }

            if (this.Count != other.Count)
            {
                return(false);
            }
            foreach (long key in Keys)
            {
                if (!other.ContainsKey(key))
                {
                    return(false);
                }
                if (this[key] != other[key])
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Apply key selection.
        /// </summary>
        /// <param name="newSelection"></param>
        /// <param name="generateCommand"></param>
        public void ApplySelection(EditCurveKeySelection newSelection,
                                   bool generateCommand)
        {
            // Re-create selected keys and store selection information from
            // new selection.
            selectedKeys.Clear();;
            foreach (long id in newSelection.Keys)
            {
                EditCurveKey key = keys.GetValue(id);
                key.Selection = newSelection[id];
                selectedKeys.Add(key.Id, key);
            }

            // Clear de-selected keys selection information.
            foreach (long id in selection.Keys)
            {
                if (!newSelection.ContainsKey(id))
                {
                    EditCurveKey key;
                    if (keys.TryGetValue(id, out key))
                    {
                        key.Selection = EditCurveSelections.None;
                    }
                }
            }

            // Invoke selection change event.
            if (generateCommand == true && !newSelection.Equals(selection) &&
                commandHistory != null)
            {
                commandHistory.Add(new SelectCommand(this, newSelection, selection));
            }

            // Update selection.
            selection = newSelection;
        }