Exemplo n.º 1
0
 /// <summary>
 /// 传入进度时间滚动到所在时间的位置
 /// </summary>
 /// <param name="postion">时间/秒</param>
 public void ChangePostion(double postion)
 {
     postion = Math.Floor(postion / 100);
     foreach (Lrc item in LrcList)
     {
         if (item.PostionDouble / 100 == postion)
         {
             LrcNow = item;
             break;
         }
     }
     VerticalCenter = this.Height / 2 - (MarginVertical + FontLrc.FontHeight) / 2;
     offsetY        = LrcNow.point.Y - VerticalCenter;
 }
Exemplo n.º 2
0
        bool overlap = false;//是否移动到某一个图形的控制点;

        private void MouseMoveEvent(object sender, MouseEventArgs e)
        {
            overlap = false;
            Lrc tmp = null;

            foreach (Lrc item in LrcList)
            {
                if ((e.X > item.FontRectangle.X && e.X < item.FontRectangle.X + item.FontRectangle.Width) && (e.Y > item.FontRectangle.Y && e.Y < item.FontRectangle.Y + FontLrc.FontHeight))
                {
                    overlap = true;
                    tmp     = item;
                    break;
                }
            }

            if (overlap)
            {
                if (MouseOnLrc == tmp)
                {
                    return;
                }
                MouseOnLrc = tmp;
                Cursor     = Cursors.Hand;
                if (MouseHoverLrcEvent != null)
                {
                    MouseHoverLrcEvent(this, e);
                }
            }
            else
            {
                MouseOnLrc = null;
                Cursor     = Cursors.Default;
            }

            //if (tmpLine)
            //{

            //    foreach (Lrc item in LrcList)
            //    {

            //        int offsetY = e.Y - item.point.Y;
            //        item.point.Y += offsetY;

            //    }

            //    //LrcNow.point.Y += e.Y - LrcNow.point.Y;
            //}
        }
Exemplo n.º 3
0
 public void Animation_Tick(object sender, EventArgs e)
 {
     offsetY = LrcNow.point.Y - VerticalCenter;
     foreach (var item in LrcList)
     {
         Lrc lrc = item;
         if (Math.Abs(offsetY) <= 1)
         {
             return;
         }
         if (offsetY < 0)
         {
             lrc.point.Y += 2;
         }
         else
         {
             lrc.point.Y -= 2;
         }
     }
     this.Invalidate();
 }
Exemplo n.º 4
0
        private void LrcView_Paint(object sender, PaintEventArgs e)
        {
            if (tmpLine)
            {
                e.Graphics.DrawLine(Pens.White, new Point(0, VerticalCenter + FontLrc.FontHeight / 2), new Point(this.Width, VerticalCenter + FontLrc.FontHeight / 2));
            }
            foreach (var item in LrcList)
            {
                Lrc          lrc          = item as Lrc;
                StringFormat stringFormat = new StringFormat();
                stringFormat.Alignment = StringAlignment.Center; //居中

                Font  font = this.FontLrc.Font;
                Brush pen  = new SolidBrush(this.FontLrc.fontColor);

                if (LrcNow == lrc)
                {
                    font = this.FontNow.Font;
                    pen  = new SolidBrush(this.FontNow.fontColor);
                }

                SizeF sizeF = e.Graphics.MeasureString(lrc.text, font);//测量字符串的宽高;


                Rectangle rectangle = new Rectangle(lrc.point.X, lrc.point.Y, this.Width, (int)sizeF.Height);


                lrc.FontRectangle = new Rectangle(this.Width / 2 - (int)sizeF.Width / 2, lrc.point.Y, (int)sizeF.Width, (int)sizeF.Height);


                if (ShowFontFrame)
                {
                    e.Graphics.DrawRectangle(Pens.Red, lrc.FontRectangle);
                }


                e.Graphics.DrawString(lrc.text, font, pen, rectangle, stringFormat);
            }
        }