Esempio n. 1
0
        public void JouerNote( Note note)
        {
            switch (note.Nom)
            {
                case NomNote.Do:using (var soundPlayer = new SoundPlayer(Properties.Resources._do)){soundPlayer.Play();}; break;
                case NomNote.DoDiese: using (var soundPlayer = new SoundPlayer()) { soundPlayer.Play(); }; break;
                case NomNote.Fa: using (var soundPlayer = new SoundPlayer(Properties.Resources.fa)) { soundPlayer.Play(); }; break;
                case NomNote.FaDiese: using (var soundPlayer = new SoundPlayer()) { soundPlayer.Play(); }; break;
                case NomNote.Invalide: ; break;
                case NomNote.La: using (var soundPlayer = new SoundPlayer(Properties.Resources.la)) { soundPlayer.Play(); }; break;
                case NomNote.LaDiese: using (var soundPlayer = new SoundPlayer()) { soundPlayer.Play(); }; break;
                case NomNote.Mi: using (var soundPlayer = new SoundPlayer(Properties.Resources.mi)) { soundPlayer.Play(); }; break;
                case NomNote.Re: using (var soundPlayer = new SoundPlayer(Properties.Resources.re)) { soundPlayer.Play(); }; break;
                case NomNote.ReDiese: using (var soundPlayer = new SoundPlayer()) { soundPlayer.Play(); }; break;
                case NomNote.Si: using (var soundPlayer = new SoundPlayer(Properties.Resources.si)) { soundPlayer.Play(); }; break;
                case NomNote.Sol: using (var soundPlayer = new SoundPlayer(Properties.Resources.sol)) { soundPlayer.Play(); }; break;
                case NomNote.SolDiese: using (var soundPlayer = new SoundPlayer()) { soundPlayer.Play(); }; break;

            }
    }
Esempio n. 2
0
 public bool isSameAs( Note o)
 {
     return (Nom == o.Nom) && (Octave == o.Octave);
 }
Esempio n. 3
0
 private void removeNote( Note n)
 {
     if (n != null){
         pressedKeys_.Remove(n);
         OnRelease(this, new NoteEvent(n));
         Invalidate();
     }
 }
Esempio n. 4
0
        private void addNote( Note n)
        {
            if (n == null)
                return;

            if( pressedKeys_.Find(n) == null){
                pressedKeys_.AddLast(n);
                OnPlay(this, new NoteEvent(n));
                Invalidate();
            }
        }
Esempio n. 5
0
 public NoteEvent(Note n)
 {
     this.note_ = n;
 }
Esempio n. 6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Brush blackBrush = new SolidBrush(Color.Black),
                  whiteBrush = new SolidBrush(Color.White),
                  grayBrush = new SolidBrush(Color.DarkGray),
                  gutterBrush = new SolidBrush(Color.FromArgb(0x20, 0x20, 0x20)),
                  pressedBrush = new SolidBrush(Color.Red);

            int kActualKeyLength = KeyLength + 1;
            int kNumberOfKeys = ClientRectangle.Width / kActualKeyLength + 1;

            Note currentNote;

            // Draw the white keys
            currentNote = new Note(NomNote.Do, startOctave_);
            for ( int i=0; i < kNumberOfKeys; ++i, currentNote = currentNote.next())
            {
                int xStart = kActualKeyLength * i,
                    xEnd = kActualKeyLength * (i + 1) - 1,
                    xBlackStart = xEnd - (KeyLength / 2),
                    blackHeight = (2 * ClientRectangle.Height) / 3;

                Brush noteBrush = whiteBrush;

                if( (pressedKeys_.Find(currentNote) != null) && highlightNotes_ )
                    noteBrush = pressedBrush;

                Rectangle thisKey = new Rectangle(xStart, 0, KeyLength, ClientRectangle.Height),
                          border = new Rectangle(xEnd, 0, 1, ClientRectangle.Height);

                e.Graphics.FillRectangle(noteBrush, thisKey);
                e.Graphics.FillRectangle(grayBrush, border);
            }

            // Draw the black keys
            currentNote = new Note(NomNote.Do, startOctave_);
            for ( int i=0; i < kNumberOfKeys; ++i, currentNote = currentNote.next()){
                // Only draw black keys where they exist
                if (!currentNote.hasBlack() )
                    continue;

                int xEnd = kActualKeyLength * (i+1),
                    blackLength = (2 * kActualKeyLength) / 3,
                    xBlackStart = xEnd - (blackLength / 2),
                    blackHeight = (2 * ClientRectangle.Height) / 3;

                Brush noteBrush = blackBrush;

                if( (pressedKeys_.Find(currentNote.getBlackOf()) != null) && highlightNotes_ )
                    noteBrush = pressedBrush;

                Rectangle blackKey = new Rectangle(xBlackStart, 0, blackLength, blackHeight);
                e.Graphics.FillRectangle(noteBrush, blackKey);
            }

            // Draw the gutter
            if ( showNotes_){
                Rectangle gutter = new Rectangle(0, 0, ClientRectangle.Width, 18 );
                e.Graphics.FillRectangle(gutterBrush, gutter);

                Font font = new Font("Monospace", 8);
                StringFormat format = new StringFormat();
                float x, y = 2.0F;

                currentNote = new Note(NomNote.Do, startOctave_);
                for ( int i=0; i < kNumberOfKeys; ++i, currentNote = currentNote.next()){
                    String toDraw = currentNote.ToString();
                    SizeF size = e.Graphics.MeasureString(toDraw, font);

                    x = (float)kActualKeyLength * i;
                    x += ((float)kActualKeyLength - size.Width) / 2.0F;

                    Brush brush = whiteBrush;
                    if ( (pressedKeys_.Find(currentNote) != null) && highlightNotes_ )
                        brush = pressedBrush;

                    e.Graphics.DrawString(currentNote.ToString(), font, brush, x, y, format);
                }
            } else {
                Rectangle line = new Rectangle(0, 0, ClientRectangle.Width, 2);
                e.Graphics.FillRectangle(gutterBrush, line);
            }
        }
Esempio n. 7
0
        public override bool Equals(object obj)
        {
            Note o = (Note)obj;

            return(Nom == o.Nom && Octave == o.Octave);
        }
Esempio n. 8
0
 public bool isSameAs(Note o)
 {
     return((Nom == o.Nom) && (Octave == o.Octave));
 }