Example #1
0
        public void Remove(IDuratedItem <T> durateditem)
        {
            var duration         = durateditem.Duration;
            var durateditem_real =
                durateditem as DuratedItem <T> ??
                items.FirstOrDefault(item => item.Value.Equals(durateditem.Value) && item.Duration == duration);

            elements_start.Remove(durateditem_real, duration.Start);
            elements_end.Remove(durateditem_real, duration.End);

            items.Remove(durateditem_real);

            FieldChanged?.Invoke(duration);

            if (GeneralDuration.Value == duration)
            {
                GeneralDuration_recalc();
            }
            else if (duration.Contains(GeneralDuration.Value.End))
            {
                GeneralDuration_recalc_end();
            }
            else if (duration.Contains(GeneralDuration.Value.Start))
            {
                GeneralDuration_recalc_start();
            }

            ItemRemoved?.Invoke(duration, durateditem.Value);
        }
Example #2
0
        public void Move(IDuratedItem <T> item, Duration newduration)
        {
            var durateditem =
                item as DuratedItem <T> ??
                items.FirstOrDefault(_ => _.Duration == item.Duration && _.Value.Equals(item.Value));

            var oldduration =
                item.Duration;

            if (oldduration == newduration)
            {
                return;
            }

            if (oldduration.Start != newduration.Start)
            {
                elements_start.Remove(durateditem, oldduration.Start);
                elements_start.Add(durateditem, newduration.Start);
            }

            if (oldduration.End != newduration.End)
            {
                elements_end.Remove(durateditem, oldduration.End);
                elements_end.Add(durateditem, newduration.End);
            }

            durateditem.Duration = newduration;

            ItemMoved?.Invoke(oldduration, newduration, item.Value);
        }
Example #3
0
 public PerceptualNote(
     PerceptualNoteID id,
     Duration duration,
     PerceptualTime length,
     IDuratedItem <Cell> cell,
     Note note
     )
 {
     ID            = id;
     this.duration = duration;
     Length        = length;
     Cell          = cell;
     Note          = note;
 }
Example #4
0
        public void Update(IDuratedItem <T> old, T newvalue)
        {
            var durateditem =
                old as DuratedItem <T> ??
                items.FirstOrDefault(
                    item =>
                    item.Duration == old.Duration &&
                    item.Value.Equals(old.Value)
                    );

            if (!old.Value.Equals(newvalue))
            {
                ItemChanged?.Invoke(old.Duration, old.Value, newvalue);
                durateditem.Value = newvalue;
            }
        }
Example #5
0
 public void Remove(IDuratedItem <T> item)
 {
     field1.Remove(item);
     field2.Remove(item);
 }