/// <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); }
/// <summary> /// Create clone of a selection. /// </summary> /// <param name="selection"></param> /// <returns></returns> public EditCurveKeySelection Clone() { EditCurveKeySelection newSelection = new EditCurveKeySelection(); foreach (long keyId in Keys) { newSelection.Add(keyId, this[keyId]); } return(newSelection); }