• 个人代码库の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();
            }
        }
    }
    
    
    作者:Asion Tang
    凡是没有注明[转载]的文章,本Blog发表的文章版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    关于lucene断点续索引和增量索引的问题
    发布一个关于统计时间段的MDX语句
    【蛙蛙推荐】想设计一个关于软件开发的元搜索引擎,希望大家支持
    python中and和or的用法
    Hadoop实战中高级部分 之 Hadoop MapReduce高级编程
    (转)对实时分析与离线分析的思考(二)
    数据分析站点导航
    MapReduce:详解Shuffle过程
    分析能力的8个等级(My Level)
    (转)Tire Tree
  • 原文地址:https://www.cnblogs.com/AsionTang/p/1885703.html
Copyright © 2020-2023  润新知