Пример #1
0
 public void LostFocusCommandExecute_EditModeFalse()
 {
     Chord c = new Chord();
     c.IsSelected = true;
     c.LostFocusCommandExecute();
     Assert.IsTrue(c.IsEditMode == false, "Chord should not been in Edit mode.");
 }
Пример #2
0
 public void LostFocusCommandExecute_DeselectsChord()
 {
     Chord c = new Chord();
     c.IsSelected = true;
     c.LostFocusCommandExecute();
     Assert.IsTrue(c.IsSelected == false, "Chord should have been deselected.");
 }
Пример #3
0
 public void Transpose_UpUpExample()
 {
     Chord c = new Chord();
     c.Name = "C";
     c.Transpose(ChordDefinition.TransposeType.Up);
     c.Transpose(ChordDefinition.TransposeType.Up);
     Assert.IsTrue(c.Name == "D", "'C' double up transposed should be equal to 'D'.");
 }
Пример #4
0
 public void Transpose_UpAndDownSameAsOriginal_Simple()
 {
     Chord c = new Chord();
     var chordName = "Cm";
     c.Name = chordName;
     c.Transpose(ChordDefinition.TransposeType.Up);
     c.Transpose(ChordDefinition.TransposeType.Down);
     Assert.IsTrue(c.Name == chordName, "Chord should be equal to the original chord.");
 }
Пример #5
0
 public void DocumentVM_DeleteSelectedChord_DeletesTheChord()
 {
     FakeDocumentViewModel document = new FakeDocumentViewModel();
     var line = new ChordLine();
     var chord = new Chord();
     line.Chords.Add(chord);
     document.ChordLines.Add(line);
     document.SelectedChord = chord;
     document.DeleteSelectedChord();
     Assert.IsNull(document.SelectedChord, "SelectedChord should be null.");
     Assert.AreEqual(line.Chords.Count, 0, "There should be 0 chords in the line now.");
 }
Пример #6
0
        private void MouseLeftDownCommandExecute(MouseEventArgs param)
        {
            Point p = param.GetPosition(param.Source as UIElement);
            var res = VisualTreeHelper.HitTest(param.Source as UIElement, p);
            if (res.VisualHit is DependencyObject && res.VisualHit != null)
            {
                var result = Ancestors.FindAncestorOfType<ChordView>(res.VisualHit as DependencyObject);
                if (result != null)
                {
                    foreach (ChordLine line in ChordLines)
                    {
                        foreach (Chord chord in line.Chords)
                        {
                            if (chord.IsSelected) chord.IsSelected = false;
                        }
                    }

                    // Set selected chord:

                    _selectedChordView = (result as ChordView);
                    _selectedChord = ((result as ChordView).DataContext as Chord);
                    _selectedChord.IsSelected = true;

                    _mainWindowModel.NotesPlayed = _selectedChord.Notes;

                }
                else
                {
                    _selectedChordView = null;
                    if (_selectedChord != null)
                    {
                        _selectedChord.IsSelected = false;
                    }
                    _selectedChord = null;

                    _mainWindowModel.NotesPlayed = null;
                }
            }
            else
            {
                Console.WriteLine();
            }
        }
Пример #7
0
        // -------------------------------------
        // [METHODS]
        // -------------------------------------
        // -- Mouse Methods (Not testable)
        private void MouseDoubleClickCommandExecute(MouseButtonEventArgs param)
        {
            // Get Mouse position.
            Point p = param.GetPosition(param.Source as Control);

            // Find highest level control that was hit.
            var res = VisualTreeHelper.HitTest(param.Source as Control, p);

            // If we did hit something.
            if (res.VisualHit is DependencyObject && res.VisualHit != null)
            {
                var result = Ancestors.FindAncestorOfType<ChordLineView>(res.VisualHit as DependencyObject);
                if (result != null)
                {
                    var chord_result = Ancestors.FindAncestorOfType<ChordView>(res.VisualHit as DependencyObject);
                    if (chord_result == null)
                    {
                        Chord newChord = new Chord();
                        newChord.Margin = (int)(Math.Round(p.X) - 15) + ",0,0,0";

                        ((result as ChordLineView).DataContext as ChordLine).Chords.Add(newChord);
                        newChord.IsEditMode = true;
                        newChord.IsSelected = true;
                    }
                    else
                    {
                        ((chord_result as ChordView).DataContext as Chord).IsEditMode = true;
                        (chord_result as ChordView).FocusAndSelect();
                    }
                }
            }
        }
Пример #8
0
 public virtual void DeleteSelectedChord()
 {
     if (_selectedChord != null)
     {
         ChordLine line = ChordLines.First<ChordLine>(f => f.Chords.Contains(_selectedChord));
         if (line != null)
         {
             line.Chords.Remove(_selectedChord);
             _selectedChord = null;
         }
     }
 }
Пример #9
0
 public void NameChanged_ValidChord_SetsBorderColorBlack()
 {
     Chord c = new Chord();
     c.Name = "C";
     Assert.IsTrue(c.BorderColor == Brushes.Black, "Border should have been Black.");
 }
Пример #10
0
 public void NameChanged_ValidChord_AddsNotes()
 {
     Chord c = new Chord();
     c.Name = "C";
     Assert.IsTrue(c.Notes.Count > 0, "There should have been items in the Notes collection.");
 }