private void LoadProperties() { try { _startMeasure = (from a in Cache.Measures where a.Id == _startChord.Measure_Id select a).SingleOrDefault(); _endMeasure = (from a in Cache.Measures where a.Id == _endChord.Measure_Id select a).SingleOrDefault(); _startStaff = (from a in Cache.Staffs where a.Id == _startMeasure.Staff_Id select a).SingleOrDefault(); _endState = (from a in Cache.Staffs where a.Id == _endMeasure.Staff_Id select a).SingleOrDefault(); } catch (Exception ex) { Exceptions.HandleException(ex); } if (_startStaff != null) if (_endState != null) _isSameStaff = _startStaff.Id != _endState.Id; if (_isSameStaff) { EA.GetEvent<DeSelectAll>().Publish(string.Empty); //TODO show message: //At this time, slurs and ties cannot be drawn when the 2 notes are on different staffs. //however, audibly, ties are handled properly; } else { if (EditorState.IsComposing) { EA.GetEvent<DeSelectAll>().Publish(string.Empty); } _stem1 = (_Enum.Orientation)_startNote.Orientation; _stem2 = (_Enum.Orientation)_endNote.Orientation; _locX1 = _startChord.Location_X; _locY1 = _startNote.Location_Y; _locX2 = _endChord.Location_X; _locY2 = _endNote.Location_Y; if (_stem1 != _stem2) { _locY2 = _locY2 + ((_stem1 == _Enum.Orientation.Up) ? 25 : -25); } var point1 = Infrastructure.Support.Utilities.CoordinateSystem.TranslateCoordinatesToCompositionCoordinates(_startStaff.Id, _startMeasure.Sequence, _startMeasure.Index, _locX1, _locY1); var point2 = Infrastructure.Support.Utilities.CoordinateSystem.TranslateCoordinatesToCompositionCoordinates(_endState.Id, _endMeasure.Sequence, _endMeasure.Index, _locX2, _locY2); int fineTuneX = -37; int fineTuneY = 0; var xOffset = Defaults.StaffDimensionWidth + Defaults.CompositionLeftMargin + fineTuneX; _point1 = new Point(point1.X + fineTuneX, _locY1 + fineTuneY); _point2 = new Point(point2.X + fineTuneX, _locY2 + fineTuneY); _deltaX = Math.Abs(_point1.X - _point2.X); _deltaY = Math.Abs(_point1.Y - _point2.Y); } }
public void OnUpdateEditPopupTargetMeasureViewModel(object obj) { _viewModel = (MeasureViewModel)obj; _measure = _viewModel.Measure; }
public static void OnArrangeMeasure(Repository.DataService.Measure measure) { //this method calculates measure.Spacing then raises the MeasureLoaded event. the measure.Spacing property is //only used to calculate chord spacing when spacingMode is 'constant.' For now, however, we call this method //no matter what the spaingMode is becase this method raises the arrangeVerse event and the arrangeVerse event //should be raised for all spacingModes. TODO: decouple measure spacing from verse spacing. or at the very least //encapsulate the switch block in 'if then else' block so it only executes when the spacingMode is 'constant'. //'EditorState.Ratio * .9' expression needs to be revisited. Measure = measure; ObservableCollection<Chord> chords = ChordManager.GetActiveChords(Measure.Chords); if (chords.Count > 0) { ChordManager.Initialize(); SetNotegroupContext(); _measureChordNotegroups = NotegroupManager.ParseMeasure(out _chordStartTimes, out _chordInactiveTimes); switch (Preferences.MeasureArrangeMode) { case _Enum.MeasureArrangementMode.DecreaseMeasureWidth: _ea.GetEvent<AdjustMeasureWidth>().Publish(new Tuple<Guid, double>(Measure.Id, Preferences.MeasureMaximumEditingSpace)); break; case _Enum.MeasureArrangementMode.IncreaseMeasureSpacing: measure.Spacing = Convert.ToInt32(Math.Ceiling((int.Parse(Measure.Width) - (Infrastructure.Constants.Measure.Padding * 2)) / chords.Count)); _ea.GetEvent<MeasureLoaded>().Publish(Measure.Id); break; case _Enum.MeasureArrangementMode.ManualResizePacked: measure.Spacing = Convert.ToInt32(Math.Ceiling((int.Parse(Measure.Width) - (Infrastructure.Constants.Measure.Padding * 2)) / Measure.Chords.Count)); _ea.GetEvent<MeasureLoaded>().Publish(Measure.Id); break; case _Enum.MeasureArrangementMode.ManualResizeNotPacked: measure.Spacing = (int)Math.Ceiling(measure.Spacing * EditorState.Ratio * .9); _ea.GetEvent<MeasureLoaded>().Publish(Measure.Id); break; } if (!EditorState.IsOpening) { _ea.GetEvent<ArrangeVerse>().Publish(Measure); } } }
public static void Reset() { IsCollaboration = false; IsAuthor = false; IsComposing = false; DoubleClick = false; ToolType = null; Tool = null; DurationType = null; DurationCaption = null; Duration = null; Dotted = null; Accidental = string.Empty; Measure = null; }