Exemplo n.º 1
0
        //When the score is clicked
        private void ScorePictureBox_MouseClick(object sender, MouseEventArgs e)
        {
            //Get a copy of currentMidiObjects Events
            MidiEvent[] CurrentMidiEvents = new MidiEvent[0];
            Array.Resize(ref CurrentMidiEvents, CurrentMidiObject.Track.Events.Length);
            Array.Copy(CurrentMidiObject.Track.Events, CurrentMidiEvents, CurrentMidiObject.Track.Events.Length);

            //Select Current Action
            switch (CurrentAction)
            {
            case "note":
                CurrentMidiObject.Track.Events = AddNote(CurrentMidiEvents, new MidiEvent(CurrentCellXPosition, CurrentNoteLength, 0, NOTE_DOWN, CurrentChannel, Convert.ToByte(127 - CurrentCellYPosition), CurrentNoteVelocity));
                break;

            case "delete":
                DeleteEvent(CurrentMidiEvents, e);
                break;

            case "tempo":
                AddTempoEvent(CurrentMidiEvents, CurrentTempo);
                break;

            case "instrument":
                AddInstrumentEvent(CurrentMidiEvents, CurrentInstrument);
                break;

            default:
                break;
            }
            ScorePictureBox.Refresh();
        }
Exemplo n.º 2
0
 //Open a Composition
 public void OpenFile(String FilePath)
 {
     CurrentMidiObject.OpenMidiFile(FilePath);
     //Calculate the amount of extra score to draw
     Properties.Settings.Default.SixteenNoteMeasureCount = ((CurrentMidiObject.FarthestEvent - (CurrentMidiObject.FarthestEvent % COLUMNS_IN_16BEAT_MEASURE)) / COLUMNS_IN_16BEAT_MEASURE) + 4;
     PaintGrid();
     ScorePictureBox.Refresh();
 }
Exemplo n.º 3
0
 //Calculate Current MousePosition & relative Cell Value, Calculate Selection Rectangle
 public void ScorePictureBox_MouseMove(object sender, MouseEventArgs e)
 {
     //Give the Score focus, to allow mouse scroll Up/Down.
     ScorePanel.Focus();
     try
     {
         CurrentMousePosition.X = MousePosition.X - this.Parent.Location.X - ScorePictureBox.Location.X - 73;
         CurrentMousePosition.Y = MousePosition.Y - this.Parent.Location.Y - ScorePictureBox.Location.Y - 98;
         CurrentCellXPosition   = (CurrentMousePosition.X / CellWidth);
         CurrentCellYPosition   = (CurrentMousePosition.Y / CellHeight);
         if (CurrentAction == "note" && SnapperTool == true && CurrentNoteLength != 0)
         {
             //If Snapper is on, Snap to nearest musically relevant position
             CurrentCellXPosition   = (CurrentCellXPosition - CurrentCellXPosition % CurrentNoteLength);
             CurrentMousePosition.X = CurrentCellXPosition * CellWidth;
         }
     }
     catch { /*do nothing*/ }
     // Create the selection rectangle from my selection start and end points.
     if (CurrentAction == "select" && SelectStartPoint.Y != POINT_FLAG_VALUE)
     {
         SelectEndPoint = CurrentMousePosition;
         RectStartPoint = SelectStartPoint;
         RectEndPoint   = SelectEndPoint;
         if (SelectStartPoint.X <= SelectEndPoint.X)
         {
             //Do not swap X's
             if (SelectStartPoint.Y <= SelectEndPoint.Y)
             { /*Leave them*/
             }
             else
             {/*Swap Y's*/
                 RectStartPoint = new Point(RectStartPoint.X, SelectEndPoint.Y);
                 RectEndPoint   = new Point(RectEndPoint.X, SelectStartPoint.Y);
             }
         }
         else
         {//Swap X's
             RectStartPoint = new Point(SelectEndPoint.X, RectStartPoint.Y);
             RectEndPoint   = new Point(SelectStartPoint.X, RectEndPoint.Y);
             if (SelectStartPoint.Y <= SelectEndPoint.Y)
             { /*Leave them*/
             }
             else
             { /*Swap Y's*/
                 RectStartPoint = new Point(RectStartPoint.X, SelectEndPoint.Y);
                 RectEndPoint   = new Point(RectEndPoint.X, SelectStartPoint.Y);
             }
         }
         ScorePictureBox.Refresh();
     }
 }
Exemplo n.º 4
0
        //Mouse Down over score
        private void ScorePictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            //Record the mouseUp position as Cell CoOrds
            if (CurrentAction == "select" && (SelectStartPoint.Y != POINT_FLAG_VALUE) && (SelectEndPoint.Y != POINT_FLAG_VALUE))
            {
                //Record the selected Notes!
                RecordSelectedNotes(RectStartPoint, RectEndPoint);

                //Reset to Flag Points
                SelectStartPoint = new Point(0, POINT_FLAG_VALUE);
                SelectEndPoint   = new Point(0, POINT_FLAG_VALUE);
                ScorePictureBox.Refresh();
            }
        }