// // SynthesizedAudioCommandChange.cs // // Author: // Michael Becker // // Copyright (c) 2020 Mike Becker's Software // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . using System; using System.Collections.Generic; using System.Collections.ObjectModel; using MBS.Framework.Drawing; using UniversalEditor.ObjectModels.Multimedia.Audio.Synthesized; using UniversalEditor.Plugins.Collaboration; namespace UniversalEditor.Plugins.Multimedia.UserInterface.Collaboration { public class SynthesizedAudioCommandChange { public class SynthesizedAudioCommandChangeCollection : Collection { private Dictionary _itemsByCommand = new Dictionary(); public bool Contains(SynthesizedAudioCommand command) { return _itemsByCommand.ContainsKey(command); } public SynthesizedAudioCommandChange this[SynthesizedAudioCommand command] { get { if (_itemsByCommand.ContainsKey(command)) return _itemsByCommand[command]; return null; } } protected override void InsertItem(int index, SynthesizedAudioCommandChange item) { base.InsertItem(index, item); _itemsByCommand[item.Command] = item; } protected override void RemoveItem(int index) { _itemsByCommand.Remove(this[index].Command); base.RemoveItem(index); } protected override void ClearItems() { base.ClearItems(); _itemsByCommand.Clear(); } public SynthesizedAudioCommandChange[] GetDeletions() { List list = new List(); for (int i =0; i < Count; i++) { if (this[i].ChangeType == CollaborationChangeType.Deletion) { list.Add(this[i]); } } return list.ToArray(); } } public SynthesizedAudioCommandChange(SynthesizedAudioCommand command, Rectangle bounds, CollaborationChangeType changeType) { this.Command = command; this.Bounds = bounds; this.ChangeType = changeType; } public SynthesizedAudioCommand Command { get; set; } = null; public Rectangle Bounds { get; set; } public CollaborationChangeType ChangeType { get; set; } = CollaborationChangeType.Unknown; } }