/// <summary>
        /// Add to list of track sample track as chosen
        /// </summary>
        /// <param name="sample"></param>
        public void Duplicate(ToDoSample sample)
        {
            var index           = _currentTrack.Samples.IndexOf(sample) + 1;
            var duplicateSample = new ToDoSample()
            {
                InitialTact = sample.InitialTact,
                Size        = sample.Size,
                TrackRef    = _currentTrack,
                Name        = sample.Name + "(" + _currentTrack.Samples.Count + ")"
            };

            this.DataBaseContext.Samples.InsertOnSubmit(duplicateSample);
            this.DataBaseContext.SubmitChanges();
            _currentTrack.Samples.Insert(index, duplicateSample);

            foreach (var note in sample.Notes)
            {
                var duplicateNote = new ToDoNote()
                {
                    Duration   = note.Duration,
                    MidiNumber = note.MidiNumber,
                    Position   = note.Position,
                    Tact       = (duplicateSample.InitialTact - sample.InitialTact) + note.Tact,
                    SampleRef  = duplicateSample
                };
                DataBaseContext.Notes.InsertOnSubmit(duplicateNote);
                DataBaseContext.SubmitChanges();
                duplicateSample.Notes.Add(duplicateNote);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Add new track to the database and collections.
        /// </summary>
        public void AddTrack()
        {
            var trackNumber = 1;

            if (this._currentProject.Tracks.Any())
            {
                trackNumber = this._currentProject.Tracks.Count + 1;
            }
            var trackName = AppResources.TrackString + " " + trackNumber;

            var newTrack = new ToDoTrack
            {
                Name       = trackName,
                ProjectRef = this._currentProject,
                Instrument = this.DataBaseContext.Instruments.First()
            };

            this.DataBaseContext.Tracks.InsertOnSubmit(newTrack);
            this.DataBaseContext.SubmitChanges();
            this._currentProject.Tracks.Add(newTrack);
            newTrack.Instruments = new ObservableCollection <ToDoInstrument>(this.DataBaseContext.Instruments);

            var sample = new ToDoSample
            {
                InitialTact = 1,
                Size        = 4,
                TrackRef    = newTrack,
                Name        = newTrack.Name + "_" + newTrack.Samples.Count
            };

            this.DataBaseContext.Samples.InsertOnSubmit(sample);
            this.DataBaseContext.SubmitChanges();
            newTrack.Samples.Add(sample);
        }
        /// <summary>
        /// Add new Sample to the database and collections.
        /// </summary>
        public void AddSample(byte size)
        {
            var lastSample   = _currentTrack.Samples.LastOrDefault();
            var initialTact  = lastSample == null ? 1 : lastSample.InitialTact + lastSample.Size;
            var nameAddition = lastSample == null ? 0 : lastSample.Id;
            var sample       = new ToDoSample
            {
                InitialTact = initialTact,
                Size        = size,
                TrackRef    = _currentTrack,
                Name        = _currentTrack.Name + "_" + nameAddition
            };

            this.DataBaseContext.Samples.InsertOnSubmit(sample);
            this.DataBaseContext.SubmitChanges();
            _currentTrack.Samples.Add(sample);
        }
Beispiel #4
0
        /// <summary>
        /// Add a project with specific name to the database and collections.
        /// </summary>
        /// <param name="projectName">Name of project</param>
        /// <returns>New project</returns>
        public ToDoProject CreateProject(string projectName)
        {
            var newProject = new ToDoProject()
            {
                Name         = projectName,
                CreationTime = DateTime.Now,
                Tempo        = 120
            };

            this.DataBaseContext.Projects.InsertOnSubmit(newProject);
            this.DataBaseContext.SubmitChanges();
            this._projectsList.Add(newProject);

            var trackName = AppResources.TrackString + " 1";
            var newTrack  = new ToDoTrack
            {
                Name       = trackName,
                ProjectRef = newProject,
                Instrument = this.DataBaseContext.Instruments.First()
            };

            this.DataBaseContext.Tracks.InsertOnSubmit(newTrack);
            this.DataBaseContext.SubmitChanges();
            newProject.Tracks.Add(newTrack);

            var sample = new ToDoSample
            {
                InitialTact = 1,
                Size        = 4,
                TrackRef    = newTrack,
                Name        = newTrack.Name + "_" + newTrack.Samples.Count
            };

            this.DataBaseContext.Samples.InsertOnSubmit(sample);
            this.DataBaseContext.SubmitChanges();
            newTrack.Samples.Add(sample);

            return(newProject);
        }
Beispiel #5
0
 /// <summary>
 /// Query database and load the information for sample
 /// </summary>
 /// <param name="sampleId">ID of loading sample</param>
 public override void LoadData(int sampleId)
 {
     this._currentSample = this.DataBaseContext.Samples.FirstOrDefault(x => x.Id == sampleId);
     Tacts = new ObservableCollection <PianoRollContext>();
     if (_currentSample == null)
     {
         return;
     }
     for (var i = _currentSample.InitialTact; i < _currentSample.InitialTact + _currentSample.Size; i++)
     {
         var tact = new PianoRollContext(i);
         tact.AddedNote   += OnAddedNote;
         tact.DeletedNote += OnDeletedNote;
         foreach (var key in tact.Keys)
         {
             key.Notes =
                 new ObservableCollection <ToDoNote>(_currentSample.Notes.Where
                                                         (x => x.MidiNumber == (byte)key.Value && x.Tact == tact.TactNumber));
         }
         Tacts.Add(tact);
     }
 }
 /// <summary>
 /// Fix bugs with null value of reference
 /// </summary>
 public void RestoreReferences(ToDoSample movedSample)
 {
     movedSample.TrackRef = _currentTrack;
 }