Ejemplo n.º 1
0
        public static Chord AddNoteToChord(MeasureViewModel mVm)
        {
            _mVm = mVm;
            Chord = GetOrCreate(Measure.Id, Measure.Index * DurationManager.BPM);
            if (Chord != null)
            {
                var note = NoteController.Create(Chord, Measure, Location_X, Location_Y);
                if (note == null) return null;
                Chord.Notes.Add(note);
                Cache.Notes.Add(note);
                SetNotegroupContext();
                ChordNotegroups = NotegroupManager.ParseChord();
                SetNotegroupContext();
                var ng = NotegroupManager.GetNotegroup(note);
                if (ng != null)
                {
                    note.Orientation = ng.Orientation;
                    _ea.GetEvent<FlagNotegroup>().Publish(ng);

                    var notes = GetActiveNotes(Chord.Notes);
                    if (notes.Count == 1)
                    {
                        if (Chord.Notes.Count == 1)
                        {
                            Chord.StartTime = GetChordStarttime(Measure.Index * DurationManager.BPM);
                            Measure.Chords.Add(Chord);
                            Cache.Chords.Add(Chord);
                        }
                        _Enum.NotePlacementMode placementMode = GetNotePlacementMode(out _chord1, out _chord2);
                        Chord.Location_X = GetChordXCoordinate(placementMode, Chord);
                        var chords = GetActiveChords(Measure.Chords);
                        Measure.Duration = (decimal)Convert.ToDouble((from c in chords select c.Duration).Sum());
                        _r.Update(Measure);
                    }
                    note.Location_X = Chord.Location_X;
                }
            }
            if (EditorState.IsCollaboration)
            {
                _ea.GetEvent<MeasureLoaded>().Publish(Measure.Id);
            }
            if (Chord != null && Chord.Duration < 1)
            {
                SpanManager.LocalSpans = _mVm.LocalSpans;
                _ea.GetEvent<SpanMeasure>().Publish(Measure);
            }
            _ea.GetEvent<ShowMeasureFooter>().Publish(_Enum.MeasureFooter.Editing);
            return Chord;
        }
Ejemplo n.º 2
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
     {
         if (!string.IsNullOrEmpty(this.MeasureId))
         {
             vm = new MeasureViewModel(this.MeasureId);
             vm.View = this;
             _ViewModels.measures.Add(vm);
             this.DataContext = vm;
         }
     }
 }
Ejemplo n.º 3
0
 public void OnUpdateEditPopupTargetMeasureViewModel(object obj)
 {
     _viewModel = (MeasureViewModel)obj;
     _measure = _viewModel.Measure;
 }