コード例 #1
0
ファイル: TimeSortedList.cs プロジェクト: hlorenzi/composer
        public IEnumerable <T> EnumerateAffectingRange(Util.TimeRange timeRange)
        {
            T   lastItem = default(T);
            var gotFirst = false;

            foreach (var item in this.internalList)
            {
                var itemTime = this.getTimeFunc(item);
                if (timeRange.Overlaps(itemTime))
                {
                    if (!gotFirst)
                    {
                        gotFirst = true;
                        if (itemTime > timeRange.Start)
                        {
                            yield return(lastItem);
                        }
                    }
                    yield return(item);
                }

                if (itemTime <= timeRange.Start)
                {
                    lastItem = item;
                }
            }

            if (!gotFirst)
            {
                yield return(lastItem);
            }
        }
コード例 #2
0
 public void RemoveOverlappingRange(Util.TimeRange timeRange, System.Predicate <T> matching = null)
 {
     internalList.RemoveAll(item =>
                            this.getTimeRangeFunc(item).OverlapsRange(timeRange) &&
                            (matching == null || matching(item))
                            );
 }
コード例 #3
0
        public ElementPitchedNote(
            ViewManager manager,
            Project.TrackPitchedNotes projectTrackPitchedNode,
            Project.PitchedNote pitchedNote)
            : base(manager)
        {
            this.projectTrackPitchedNode = projectTrackPitchedNode;
            this.projectPitchedNote      = pitchedNote;
            this.interactableRegions     = new List <InteractableRegion>();
            this.segments = new List <Segment>();

            this.timeRange = this.projectPitchedNote.timeRange;
            this.pitch     = this.projectPitchedNote.pitch;

            this.assignedTrack = -1;
            for (var i = 0; i < this.manager.rows[0].trackSegments.Count; i++)
            {
                var trackPitchedNote = (this.manager.rows[0].trackSegments[i] as TrackSegmentPitchedNotes);
                if (trackPitchedNote != null &&
                    trackPitchedNote.projectTracks.Contains(this.projectTrackPitchedNode))
                {
                    this.assignedTrack = i;
                    break;
                }
            }
        }
コード例 #4
0
        public override void Drag()
        {
            this.timeRange =
                this.projectPitchedNote.timeRange.OffsetBy(this.manager.DragTimeOffsetClampedToRow);

            this.pitch =
                this.projectPitchedNote.pitch.OffsetMidiPitchBy(this.manager.DragMidiPitchOffset);
        }
コード例 #5
0
        public void EraseRange(Util.TimeRange timeRange, Util.Pitch?onlyAtPitch = null)
        {
            this.SplitNotesAt(timeRange.Start, onlyAtPitch);
            this.SplitNotesAt(timeRange.End, onlyAtPitch);

            this.notes.RemoveOverlappingRange(timeRange,
                                              (note) => !onlyAtPitch.HasValue || note.pitch.MidiPitch == onlyAtPitch.Value.MidiPitch);
        }
コード例 #6
0
 public Row(ViewManager manager, Util.TimeRange timeRange, bool isLastRow)
 {
     this.manager             = manager;
     this.timeRange           = timeRange;
     this.resizeEndTime       = timeRange.End;
     this.trackSegments       = new List <TrackSegment>();
     this.interactableRegions = new List <InteractableRegion>();
     this.isLastRow           = isLastRow;
 }
コード例 #7
0
        public override void EndModify()
        {
            this.projectPitchedNote.timeRange = this.timeRange;
            this.projectPitchedNote.pitch     = this.pitch;

            this.manager.project.InsertPitchedNote(
                this.manager.project.GetTrackIndex(this.projectTrackPitchedNode),
                this.projectPitchedNote);
        }
コード例 #8
0
ファイル: TimeSortedList.cs プロジェクト: hlorenzi/composer
 public IEnumerable <T> EnumerateOverlappingRange(Util.TimeRange timeRange)
 {
     foreach (var item in this.internalList)
     {
         if (timeRange.Overlaps(this.getTimeFunc(item)))
         {
             yield return(item);
         }
     }
 }
コード例 #9
0
ファイル: ViewManager.cs プロジェクト: hlorenzi/composer
 public IEnumerable <Row> EnumerateRowsInTimeRange(Util.TimeRange timeRange)
 {
     foreach (var row in this.rows)
     {
         if (row.timeRange.OverlapsRange(timeRange))
         {
             yield return(row);
         }
     }
 }
コード例 #10
0
 public override void CutRange(Util.TimeRange timeRange)
 {
     this.SplitNotesAt(timeRange.Start);
     this.SplitNotesAt(timeRange.End);
     this.notes.RemoveOverlappingRange(timeRange);
     foreach (var note in this.notes.EnumerateEntirelyAfter(timeRange.End))
     {
         note.timeRange = note.timeRange.OffsetBy(-timeRange.Duration);
     }
 }
コード例 #11
0
 public override void OnPressLeft(bool ctrlKey, bool shiftKey)
 {
     if (shiftKey)
     {
         this.timeRange.Duration =
             System.Math.Max(
                 this.manager.TimeSnap,
                 this.timeRange.Duration - this.manager.TimeSnap);
     }
     else
     {
         this.timeRange =
             this.timeRange.OffsetBy(-this.manager.TimeSnap);
     }
 }
コード例 #12
0
ファイル: Project.cs プロジェクト: hlorenzi/composer
        public void CutRange(Util.TimeRange timeRange)
        {
            foreach (var track in this.tracks)
            {
                track.CutRange(timeRange);
            }

            this.sectionBreaks.RemoveAll(sb => timeRange.Overlaps(sb.time));
            foreach (var sectionBreak in this.sectionBreaks.Clone())
            {
                if (sectionBreak.time >= timeRange.Start)
                {
                    this.RemoveSectionBreak(sectionBreak);
                    sectionBreak.time -= timeRange.Duration;
                    this.InsertSectionBreak(sectionBreak);
                }
            }

            this.keyChanges.RemoveAll(kc => timeRange.Overlaps(kc.time));
            foreach (var keyChange in this.keyChanges.Clone())
            {
                if (keyChange.time >= timeRange.Start)
                {
                    this.RemoveKeyChange(keyChange);
                    keyChange.time -= timeRange.Duration;
                    this.InsertKeyChange(keyChange);
                }
            }

            this.meterChanges.RemoveAll(mc => timeRange.Overlaps(mc.time));
            foreach (var meterChange in this.meterChanges.Clone())
            {
                if (meterChange.time >= timeRange.Start)
                {
                    this.RemoveMeterChange(meterChange);
                    meterChange.time -= timeRange.Duration;
                    this.InsertMeterChange(meterChange);
                }
            }

            this.length -= timeRange.Duration;
        }
コード例 #13
0
ファイル: TimeSortedList.cs プロジェクト: hlorenzi/composer
 public void RemoveOverlappingRange(Util.TimeRange timeRange)
 {
     internalList.RemoveAll(item => timeRange.Overlaps(this.getTimeFunc(item)));
 }
コード例 #14
0
 public abstract void CutRange(Util.TimeRange timeRange);
コード例 #15
0
ファイル: TimeRange.cs プロジェクト: hlorenzi/composer
 public bool OverlapsRangeInclusive(Util.TimeRange other)
 {
     return(this.start <= other.end && this.end >= other.start);
 }
コード例 #16
0
ファイル: TimeRange.cs プロジェクト: hlorenzi/composer
 public bool OverlapsRange(Util.TimeRange other)
 {
     return(this.start < other.end && this.end > other.start);
 }