个人代码库のC#千千静听 - 桌面歌词 (功能模拟)

using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.DoubleBuffered = true;//开启双缓存,显示能够更平滑。
            this.Size = SystemInformation.WorkingArea.Size;//默认以整个桌面为大小。这样就可以显示全部文字!
        }



        Point mouse_offset;
        private void Form_MouseDown(object sender , MouseEventArgs e)
        {
            mouse_offset = e.Location; //将当前鼠标相对于“窗体”左上角的坐标赋值给mouse_offset
        }

        private void Form_MouseMove(object sender , MouseEventArgs e)
        {

            if ( e.Button == MouseButtons.Left )
            {
                Left = Control.MousePosition.X - mouse_offset.X;
                Top = Control.MousePosition.Y - mouse_offset.Y;
            }
        }

        string strText2Show = "俺是谁嗫?";
        private void Form1_Paint(object sender , PaintEventArgs e)
        {
            GraphicsPath buttonPath = new GraphicsPath();
            System.Drawing.Rectangle newRectangle = this.ClientRectangle;

            string stringText = strText2Show;//要显示的字符串。

            FontFamily family = new FontFamily("Arial");//修改字体。
            int fontStyle = (int)FontStyle.Regular;//字体字形,eg:加粗或倾斜?
            int emSize = 72;//字体大小
            Point origin = new Point(0 , 700-72);//显示的位置。
            StringFormat format = StringFormat.GenericDefault;//文本布局信息


            // 使用“字符串”显示。
            buttonPath.AddString(stringText ,
                family ,
                fontStyle ,
                emSize ,
                origin ,
                format);

            this.Region = new System.Drawing.Region(buttonPath);
            this.BackColor = Color.Red;
        }

        private void Form1_Click(object sender , System.EventArgs e)
        {
            strText2Show = "这是变化后的文本!";
            this.Refresh();
        }
    }
}

posted @ 2010-11-20 22:34  Asion Tang  阅读(1749)  评论(0编辑  收藏  举报