Beispiel #1
0
        private void InsertBlank(Graphics g, INote note, Point barStart, bool useFlats, int pixelsPerSquare)
        {
            // Calculate horizontal position of note
            int   pixelsIntoBar = note.Offset * pixelsPerSquare / 4;
            Point noteCentre    = barStart;

            noteCentre.Offset(pixelsIntoBar + pixelsPerSquare / 2,
                              (note.VerticalOffset(useFlats) - Score.MinVerticalOffset) * pixelsPerSquare / 3);
            using (Font font = new Font("Arial Rounded MT", pixelsPerSquare / 3 - 2, FontStyle.Bold))
                using (Font accFont = new Font("Arial Rounded MT", pixelsPerSquare / 4, FontStyle.Bold))
                {
                    StringFormat sf = new StringFormat
                    {
                        Alignment     = StringAlignment.Center,
                        LineAlignment = StringAlignment.Center
                    };
                    string noteStr = note.ToString(useFlats);
                    SizeF  size    = g.MeasureString(noteStr.Substring(0, 1), font);
                    using (Brush fillBrush = new SolidBrush((note as ColouredNote).BackColour))
                    {
                        g.FillRectangle(fillBrush, noteCentre.X - size.Width / 2,
                                        noteCentre.Y - size.Height / 2, size.Width, size.Height);
                        if (noteStr.Length > 1)
                        {
                            SizeF accSize = g.MeasureString(noteStr.Substring(1), accFont);
                            g.FillRectangle(fillBrush,
                                            noteCentre.X + size.Width / 2 - accSize.Width / 2,
                                            noteCentre.Y - pixelsPerSquare / 10 - accSize.Height / 2,
                                            accSize.Width, accSize.Height);
                        }
                    }
                }
        }
Beispiel #2
0
        private bool NoteHitTest(Point mousePt, Image img, INote note, Point barStart, bool useFlats, int pixelsPerSquare)
        {
            using (Graphics g = Graphics.FromImage(img))
            {
                if (note.Pitch >= Note.StartRepeat)
                {
                    return(SpecialNoteHitTest(mousePt, g, note, barStart, useFlats, pixelsPerSquare));
                }

                // Calculate horizontal position of note
                int   pixelsIntoBar = note.Offset * pixelsPerSquare / 4;
                Point noteCentre    = barStart;
                noteCentre.Offset(pixelsIntoBar + pixelsPerSquare / 2,
                                  (note.VerticalOffset(useFlats) - Score.MinVerticalOffset) * pixelsPerSquare / 3);
                using (Font font = new Font("Arial Rounded MT", pixelsPerSquare / 3 - 2, FontStyle.Bold))
                    using (Font accFont = new Font("Arial Rounded MT", pixelsPerSquare / 4, FontStyle.Bold))
                    {
                        StringFormat sf = new StringFormat
                        {
                            Alignment     = StringAlignment.Center,
                            LineAlignment = StringAlignment.Center
                        };
                        string noteStr = note.ToString(useFlats);
                        SizeF  size    = g.MeasureString(noteStr.Substring(0, 1), font);
                        if ((new RectangleF(noteCentre.X - size.Width / 2,
                                            noteCentre.Y - size.Height / 2, size.Width, size.Height)).Contains(mousePt))
                        {
                            return(true);
                        }
                        if (noteStr.Length > 1)
                        {
                            SizeF accSize = g.MeasureString(noteStr.Substring(1), accFont);
                            if ((new RectangleF(noteCentre.X + size.Width / 2 - accSize.Width / 2,
                                                noteCentre.Y - pixelsPerSquare / 10 - accSize.Height / 2,
                                                accSize.Width, accSize.Height)).Contains(mousePt))
                            {
                                return(true);
                            }
                        }
                    }
                return(false);
            }
        }
Beispiel #3
0
 private void InsertNote(Graphics g, INote note, Point barStart, bool useFlats, int pixelsPerSquare, bool selected)
 {
     if (note.Pitch >= Note.StartRepeat)
     {
         RenderSpecial(g, note, barStart, useFlats, pixelsPerSquare, selected);
     }
     else
     {
         // Calculate horizontal position of note
         int   pixelsIntoBar = note.Offset * pixelsPerSquare / 4;
         Point noteCentre    = barStart;
         noteCentre.Offset(pixelsIntoBar + pixelsPerSquare / 2,
                           (note.VerticalOffset(useFlats) - Score.MinVerticalOffset) * pixelsPerSquare / 3);
         using (Font font = new Font("Arial Rounded MT", pixelsPerSquare / 3 - 2, FontStyle.Bold))
             using (Font accFont = new Font("Arial Rounded MT", pixelsPerSquare / 4, FontStyle.Bold))
             {
                 StringFormat sf = new StringFormat
                 {
                     Alignment     = StringAlignment.Center,
                     LineAlignment = StringAlignment.Center
                 };
                 string noteStr = note.ToString(useFlats);
                 SizeF  size    = g.MeasureString(noteStr.Substring(0, 1), font);
                 using (Brush txtBrush = selected ? new SolidBrush(Color.Red) : new SolidBrush((note as ColouredNote).ForeColour))
                 {
                     g.DrawString(noteStr.Substring(0, 1), font, txtBrush, noteCentre, sf);
                     if (noteStr.Length > 1)
                     {
                         g.DrawString(noteStr.Substring(1), accFont, txtBrush,
                                      new PointF(noteCentre.X + size.Width / 2, noteCentre.Y - pixelsPerSquare / 10), sf);
                     }
                     if (note.Duration > 4)
                     {
                         using (Pen p = new Pen(txtBrush, pixelsPerSquare / 36.0f))
                             g.DrawLine(p, noteCentre.X + size.Width, noteCentre.Y - pixelsPerSquare / 10,
                                        noteCentre.X + pixelsPerSquare * (note.Duration / 4 - 1), noteCentre.Y - pixelsPerSquare / 10);
                     }
                 }
             }
     }
 }