个人代码库のC#千千静听 - 桌面歌词 (功能模拟)
生活随笔
收集整理的這篇文章主要介紹了
个人代码库のC#千千静听 - 桌面歌词 (功能模拟)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
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;//默認(rèn)以整個(gè)桌面為大小。這樣就可以顯示全部文字!}Point mouse_offset;private void Form_MouseDown(object sender , MouseEventArgs e){mouse_offset = e.Location; //將當(dāng)前鼠標(biāo)相對(duì)于“窗體”左上角的坐標(biāo)賦值給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();}}
}
轉(zhuǎn)載于:https://www.cnblogs.com/AsionTang/archive/2010/11/20/1885703.html
總結(jié)
以上是生活随笔為你收集整理的个人代码库のC#千千静听 - 桌面歌词 (功能模拟)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: npm常见命令表
- 下一篇: Codechef Chef Cuts T