private static TuningEditorViewModel CopyExistingTuning(Tuning tuning, Instrument targetInstrument)
        {
            if (null == tuning)
            {
                throw new ArgumentNullException("tuning");
            }

            if (null == targetInstrument)
            {
                throw new ArgumentNullException("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);
            });

            tuningEditorVM.Name = tuning.Name;

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

            return(tuningEditorVM);
        }
        public static TuningEditorViewModel EditExistingTuning(ObservableTuning tuning)
        {
            if (null == tuning)
            {
                throw new ArgumentNullException("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);
            });

            tuningEditorVM.Name = tuning.Name;

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

            return(tuningEditorVM);
        }
        public static TuningEditorViewModel AddNewTuning(ObservableInstrument instrument)
        {
            if (null == instrument)
            {
                throw new ArgumentNullException("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);
        }
Exemple #4
0
 public ShowTuningEditorMessage(ObservableTuning tuning, ObservableInstrument targetInstrument, Action <bool> callback = null) : base()
 {
     TuningEditorVM = TuningEditorViewModel.CopyExistingTuning(tuning, targetInstrument);
     Callback       = callback;
 }
Exemple #5
0
 public ShowTuningEditorMessage(ObservableTuning tuning, Action <bool> callback = null) : base()
 {
     TuningEditorVM = TuningEditorViewModel.EditExistingTuning(tuning);
     Callback       = callback;
 }
Exemple #6
0
 public ShowTuningEditorMessage(ObservableInstrument instrument, Action <bool> callback = null) : base()
 {
     TuningEditorVM = TuningEditorViewModel.AddNewTuning(instrument);
     Callback       = callback;
 }