Example #1
0
        private static void TestMerge()
        {
            Track a = new Track();
            Track b = new Track();

            a.Merge(b);

            Debug.Assert(a.Count == 1);

            ChannelMessage message = new ChannelMessage(ChannelCommand.NoteOff, 0, 60, 0);

            b.Insert(0, message);
            b.Insert(10, message);
            b.Insert(20, message);
            b.Insert(30, message);
            b.Insert(40, message);

            a.Merge(b);

            Debug.Assert(a.Count == 1 + b.Count - 1);

            a.Clear();

            Debug.Assert(a.Count == 1);

            a.Insert(0, message);
            a.Insert(10, message);
            a.Insert(20, message);
            a.Insert(30, message);
            a.Insert(40, message);

            int count = a.Count;

            a.Merge(b);

            Debug.Assert(a.Count == count + b.Count - 1);
            Debug.Assert(a.GetMidiEvent(0).DeltaTicks == 0);
            Debug.Assert(a.GetMidiEvent(1).DeltaTicks == 0);
            Debug.Assert(a.GetMidiEvent(2).DeltaTicks == 10);
            Debug.Assert(a.GetMidiEvent(3).DeltaTicks == 0);
            Debug.Assert(a.GetMidiEvent(4).DeltaTicks == 10);
            Debug.Assert(a.GetMidiEvent(5).DeltaTicks == 0);
            Debug.Assert(a.GetMidiEvent(6).DeltaTicks == 10);
            Debug.Assert(a.GetMidiEvent(7).DeltaTicks == 0);
            Debug.Assert(a.GetMidiEvent(8).DeltaTicks == 10);
            Debug.Assert(a.GetMidiEvent(9).DeltaTicks == 0);
        }
        private static void TestMerge()
        {
            Track a = new Track();
            Track b = new Track();

            a.Merge(b);

            Debug.Assert(a.Count == 1);

            ChannelMessage message = new ChannelMessage(ChannelCommand.NoteOff, 0, 60, 0);

            b.Insert(0, message);
            b.Insert(10, message);
            b.Insert(20, message);
            b.Insert(30, message);
            b.Insert(40, message);

            a.Merge(b);

            Debug.Assert(a.Count == 1 + b.Count - 1);

            a.Clear();

            Debug.Assert(a.Count == 1);

            a.Insert(0, message);
            a.Insert(10, message);
            a.Insert(20, message);
            a.Insert(30, message);
            a.Insert(40, message);

            int count = a.Count;

            a.Merge(b);

            Debug.Assert(a.Count == count + b.Count - 1);
            Debug.Assert(a.GetMidiEvent(0).DeltaTicks == 0);
            Debug.Assert(a.GetMidiEvent(1).DeltaTicks == 0);
            Debug.Assert(a.GetMidiEvent(2).DeltaTicks == 10);
            Debug.Assert(a.GetMidiEvent(3).DeltaTicks == 0);
            Debug.Assert(a.GetMidiEvent(4).DeltaTicks == 10);
            Debug.Assert(a.GetMidiEvent(5).DeltaTicks == 0);
            Debug.Assert(a.GetMidiEvent(6).DeltaTicks == 10);
            Debug.Assert(a.GetMidiEvent(7).DeltaTicks == 0);
            Debug.Assert(a.GetMidiEvent(8).DeltaTicks == 10);
            Debug.Assert(a.GetMidiEvent(9).DeltaTicks == 0);
        }
 public static Track CopyTrack(Track track, string newName)
 {
     Track ret = null;
     if (track != null)
     {
         try
         {
             ret = new Track(track.FileType, newName);
             ret.Merge(track);
         }
         catch { ret = null; }
     }
     return ret;
 }
        void peTrack_ItemDropped(PEMidiTrack sender, DragEventArgs e)
        {
            var peTrack = e.GetDropObject<PEMidiTrack>();
            peTrack.IfObjectNotNull(x =>
            {
                if (peTrack != sender)
                {
                    DoRequestBackup();

                    Track newTrack = null;
                    if (sender.Track.Sequence == peTrack.Track.Sequence)
                    {
                        newTrack = peTrack.Track;
                        sender.Track.Sequence.MoveTrack(peTrack.Track.GetTrackIndex(), GetInsertAt());
                    }
                    else
                    {
                        if (IsPro && peTrack.Track.Name.IsProTrackName())
                        {
                            newTrack = new Track(FileType.Pro, peTrack.Track.Name);

                            newTrack.Merge(peTrack.Track);
                        }
                        else if (IsPro == false && peTrack.Track.Name.IsProTrackName() == false)
                        {
                            newTrack = new Track(FileType.Guitar5, peTrack.Track.Name);

                            newTrack.Merge(sender.Track);
                        }
                        else
                        {
                            newTrack = peTrack.Track.Clone(sender.Track.FileType);
                        }

                        newTrack.Name = sender.Track.Name;

                        sender.Track.Sequence.Insert(GetInsertAt(), newTrack);

                        if (!ModifierKeys.HasFlag(Keys.Shift))
                        {
                            sender.Track.Sequence.Remove(sender.Track);
                        }
                    }
                    Refresh();
                    SetSelectedItem(newTrack, SelectedDifficulty);

                    t_TrackClicked(this, newTrack, SelectedDifficulty);

                }
            });
            dragItem = null;
        }
        private void buttonCopy_Click(object sender, EventArgs e)
        {
            if (SelectedTrack != null && sequence != null && textBoxTrackName.Text.Length > 0)
            {
                var track = new Track(sequence.FileType, textBoxTrackName.Text);
                track.Merge(SelectedTrack.Track);
                sequence.Add(track);

                Refresh();
                SetSelectedItem(track, SelectedDifficulty);
                if (TrackAdded != null)
                {
                    TrackAdded(this, sequence, track, SelectedDifficulty);
                }
            }
        }