2025年6月8日 星期日 乙巳(蛇)年 三月十二 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > .net

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

时间:02-11来源:作者:点击数:42

代码库の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();
  • }
  • }
  • }

 

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门