Exemplo n.º 1
0
        private static TuningEditorViewModel CopyExistingTuning(Tuning tuning, Instrument targetInstrument)
        {
            if (null == tuning)
            {
                throw new ArgumentNullException(nameof(tuning));
            }

            if (null == targetInstrument)
            {
                throw new ArgumentNullException(nameof(targetInstrument));
            }

            TuningEditorViewModel tuningEditorVM = new TuningEditorViewModel(true, false, (name, notes) =>
            {
                FullNote[] rootNotes = new FullNote[notes.Count];

                for (int i = 0; i < notes.Count; i++)
                {
                    rootNotes[i] = notes[i].FullNote;
                }

                targetInstrument.Tunings.Add(name, rootNotes);
            })
            {
                Name = tuning.Name
            };

            foreach (FullNote note in tuning.RootNotes)
            {
                tuningEditorVM.RootNotes.Add(new ObservableNote(note.Clone()));
            }

            return(tuningEditorVM);
        }
Exemplo n.º 2
0
        public static TuningEditorViewModel EditExistingTuning(ObservableTuning tuning)
        {
            if (null == tuning)
            {
                throw new ArgumentNullException(nameof(tuning));
            }

            TuningEditorViewModel tuningEditorVM = new TuningEditorViewModel(false, tuning.ReadOnly, (name, notes) =>
            {
                FullNote[] rootNotes = new FullNote[notes.Count];

                for (int i = 0; i < notes.Count; i++)
                {
                    rootNotes[i] = notes[i].FullNote;
                }

                tuning.Tuning.Update(name, rootNotes);
            })
            {
                Name = tuning.Name
            };

            foreach (ObservableNote note in tuning.Notes)
            {
                tuningEditorVM.RootNotes.Add(new ObservableNote(note.FullNote.Clone()));
            }

            return(tuningEditorVM);
        }
Exemplo n.º 3
0
        public static TuningEditorViewModel AddNewTuning(ObservableInstrument instrument)
        {
            if (null == instrument)
            {
                throw new ArgumentNullException(nameof(instrument));
            }

            TuningEditorViewModel tuningEditorVM = new TuningEditorViewModel(true, false, (name, notes) =>
            {
                FullNote[] rootNotes = new FullNote[notes.Count];

                for (int i = 0; i < notes.Count; i++)
                {
                    rootNotes[i] = notes[i].FullNote;
                }

                instrument.Instrument.Tunings.Add(name, rootNotes);
            });

            for (int i = 0; i < instrument.NumStrings; i++)
            {
                tuningEditorVM.RootNotes.Add(new ObservableNote());
            }

            return(tuningEditorVM);
        }
Exemplo n.º 4
0
 public ShowTuningEditorMessage(ObservableTuning tuning, ObservableInstrument targetInstrument, Action <bool> callback = null) : base()
 {
     TuningEditorVM = TuningEditorViewModel.CopyExistingTuning(tuning, targetInstrument);
     Callback       = callback;
 }
Exemplo n.º 5
0
 public ShowTuningEditorMessage(ObservableTuning tuning, Action <bool> callback = null) : base()
 {
     TuningEditorVM = TuningEditorViewModel.EditExistingTuning(tuning);
     Callback       = callback;
 }
Exemplo n.º 6
0
 public ShowTuningEditorMessage(ObservableInstrument instrument, Action <bool> callback = null) : base()
 {
     TuningEditorVM = TuningEditorViewModel.AddNewTuning(instrument);
     Callback       = callback;
 }