自定义屏幕保护

2023-11-19


一、设计器页面及代码(Form2.Designer.cs):

namespace 自定义屏保
{
    partial class Form2
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.label4 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            this.SuspendLayout();
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.BackColor = System.Drawing.Color.Transparent;
            this.label4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label4.ForeColor = System.Drawing.Color.White;
            this.label4.Location = new System.Drawing.Point(177, 137);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(55, 14);
            this.label4.TabIndex = 7;
            this.label4.Text = "label4";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.BackColor = System.Drawing.Color.Transparent;
            this.label3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label3.ForeColor = System.Drawing.Color.White;
            this.label3.Location = new System.Drawing.Point(175, 110);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(55, 14);
            this.label3.TabIndex = 6;
            this.label3.Text = "label3";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.BackColor = System.Drawing.Color.Transparent;
            this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label2.ForeColor = System.Drawing.Color.White;
            this.label2.Location = new System.Drawing.Point(175, 85);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(55, 14);
            this.label2.TabIndex = 5;
            this.label2.Text = "label2";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.BackColor = System.Drawing.Color.Transparent;
            this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label1.ForeColor = System.Drawing.Color.White;
            this.label1.Location = new System.Drawing.Point(175, 60);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(55, 14);
            this.label1.TabIndex = 4;
            this.label1.Text = "label1";
            // 
            // timer1
            // 
            this.timer1.Interval = 1;
            // 
            // Form2
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
            this.BackgroundImage = global::自定义屏保.Properties.Resources.黑帖;
            this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
            this.ClientSize = new System.Drawing.Size(284, 261);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Name = "Form2";
            this.Text = "Form2";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Timer timer1;

    }
}

二、代码如下(Form2.cs):

   
  
  
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace 自定义屏保 {     public partial class Form2 : Form     {         int fontSize = 0;//字休大小
        public Form2()         {             InitializeComponent();             InitEvent();             StartRun();         }
        private void InitEvent()         {             this.SizeChanged += ((s, e) =>             {                 label1.Top = this.Height / 5;//文字从右到左滚动  <---                 label3.Top = (this.Height / 5) * 4;//文字从左到右滚动  --->                 label3.Left = 0 - label2.Width;                 label4.Left = (this.Width / 5) * 4;// 向下滚动                 label4.Top = 0 - label2.Height;//设置当前控件的显示位置                 label2.Left = this.Width / 5;//向上滚动             });
            this.KeyDown += ((a, b) =>             {                 if (b.KeyCode == Keys.Escape)                     this.Close();             });
            this.timer1.Tick += new EventHandler(timer1_Tick);         }
        private void StartRun()         {             this.FormBorderStyle = FormBorderStyle.None;//窗体无边框             this.WindowState = FormWindowState.Maximized;//窗体最大化             this.BackColor = Color.Black;//设置窗体背景为黑色             SetScrollingText();//设置窗体中各控件的样式             timer1.Start();//启动计时器         }
        /// <summary>         /// 在显示预览和屏保前,对窗体中的各控件进行设置         /// </summary>         /// <param panel ="Control">设置父级控件</param>         public void SetScrollingText()         {             fontSize = 20;//设置字体大小             label1.Text = "我非英雄";//设置文本             label1.Font = new Font("宋体", fontSize, FontStyle.Bold);//设置字体样式             label2.Text = "广" + "\n" + "目" + "\n" + "无" + "\n" + "双";//设置纵向文本             label2.Font = new Font("宋体", fontSize, FontStyle.Bold);//设置字体样式             label3.Text = "蛋坏本我";//设置文本             label3.Font = new Font("宋体", fontSize, FontStyle.Bold);//设置字体样式             label4.Text = "张" + "\n" + "嚣" + "\n" + "限" + "\n" + "无";//设置纵向文本             label4.Font = new Font("宋体", fontSize, FontStyle.Bold);//设置字体样式         }
        private void timer1_Tick(object sender, EventArgs e)         {             //文字从右到左滚动             label1.Left = label1.Left - 2;//向左移动             if ((label1.Left + label1.Width) < 1)//当超出左边界时                 label1.Left = this.Width;//在右边出现             //文字从下到上滚动             label2.Top = label2.Top - 1;//向上移动             if ((label2.Top + label2.Height) < 1)//当超出上边界时                 label2.Top = this.Height;//在下边出现             //文字从左到右滚动             if (label3.Left > this.Width)//如果超出右边界                 label3.Left = 0 - label2.Width;//在左边出现             else                 label3.Left = label3.Left + 2;//向右移动             //文字从上到下滚动             if (label4.Top > this.Height)//如果超出下边界                 label4.Top = 0 - label4.Height;//在上边出现             else                 label4.Top = label4.Top + 1;//向下移动         }     } }


三、运行效果:


本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

自定义屏幕保护 的相关文章

随机推荐

  • 开心档-软件开发入门教程网之Bootstrap4 信息提示框

    Bootstrap4 信息提示框 Bootstrap 4 可以很容易实现信息提示框 提示框可以使用 alert 类 后面加上 alert success alert info alert warning alert danger alert
  • Struts2 校验(XML配置校验)

    参考文档 http struts apache org 2 0 9 docs ajax client side validation html http struts apache org 2 0 9 docs pure javascrip
  • 基础篇-常用对称、非对称、摘要加密算法介绍

    本文属于 OpenSSL加密算法库使用系列教程 之一 欢迎查看其它文章 也可以查看 GmSSL国密加密算法库使用系列教程 常见的加密算法可以分成三类 对称加密算法 非对称加密算法 Hash算法 一 对称加密算法 对称加密是使用同一个密钥对信
  • springMVC基于Session实现动态国际化

    1 在spring配置文件中配置资源文件properties的位置及公共名 下列配置指定的properties文件处于src目录下的resources文件夹中 名字为message info properties
  • Unity 反射绑定UI

    ui的名称和定义的字段名要保持一致 using System using System Collections using System Collections Generic using System Linq using System
  • 计算机f g 盘找不到了,电脑E/F盘符突然不见了怎么办

    随着分区工具的普及 越来越多的人起初自己对硬盘重新界定分区 由于目前这些分区软件和平台不兼容造成再次分区的之后 分区会重叠 这会导致以后使用电脑的之后 会时常丢失一个或几个分区 1 首先开启磁盘管理 打开的步骤 右击桌面的计算机界面 管理
  • Compiler- volatile关键字

    为了直观的感受编译器为程序所做的编译优化 我们通过以下的C 程序来进行演示 只能体现编译优化的一小部分hh 请大家预测一下下面代码的输出结果 include
  • didChangeDependencies什么时候被调用

    参考 我先上一个Demo 这个Demo也就是网上面传的比较广的 我们就以这个来举例子说明网上的结论 父级结构中的层级发生变化时didChangeDependencies被调用 这个结论为什么是不完整 import package flutt
  • (2022 COLING)Context-Tuning情景化提示

    论文题目 Title Context Tuning Learning Contextualized Prompts for Natural Language Generation 研究问题 Question 自然语言生成 生成长文本 研究动
  • 5G+边缘计算,对于VR移动电竞游戏来说意味着什么?

    这是一个5G 边缘计算意义的问题 其实对VR游戏 特别是电竞游戏 这类大流量 低延迟的应用服务来说 大多数人第一时间想到的优点会是高达1Gbps s的数据传输速度 虽然事实确实如此 但并不是全部 从技术上讲 无线传输性能的进步能给我们带来更
  • element 可移动dialog

    import Vue from vue v dialogDrag 弹窗拖拽属性 Vue directive dialogDrag bind el binding vnode oldVnode const dialogHeaderEl el
  • ES6数组方法总结

    1 forEach let array 1 2 3 4 array forEach item index array gt console log item forEach会遍历数组 没有返回值 不允许在循环体内写return 不会改变原来
  • 小程序自定义导航栏返回主页

    小程序自定义导航栏返回主页 效果图 在app js中获取状态栏的高度statusBarHeight 自定义组件navbar wxml 自定义组件navbar wxss 自定义组件navbar json 自定义组件navbar js 调用组件
  • 睿智的目标检测60——Tensorflow2 Focal loss详解与在YoloV4当中的实现

    睿智的目标检测60 Tensorflow2 Focal loss详解与在YoloV4当中的实现 学习前言 什么是Focal Loss 一 控制正负样本的权重 二 控制容易分类和难分类样本的权重 三 两种权重控制方法合并 实现方式 学习前言
  • 如何用Stata完成(shui)一篇经济学论文(九):画线性图

    目录 普通线性图 多图并列 一图多线 什么 为什么只讲线形图 因为我只用过线形图 言归正传 我的确只用过线形图 说了跟没说一样 Stata画图给我的感觉一直都是很复杂 很多命令 我觉得好像也没有很多的地方要画图 一般就画个线形图看看趋势 如
  • 2023年,想要年赚百万必懂的道理?

    1 一个人只有经历过风雨沧桑 才会明白一个道理 这个世界最大的监狱就是人的思维 而越狱最好的方式就是人的觉醒 2 人活明白了就会知道 不要拿自己去跟别人比较 后果不是忘记了自己 就是让自己失落 3 如果一个人不向内求 总是拿自己的一点优势去
  • 机器学习可解释性

    20210508 随笔 后续有时间在对概念有了深入理解之后再进行整理 0 引言 今天不想写论文 就想起了之前关注的一个内容 机器学习的可解释性 在之前的时候 或多或少了解这个东西 发现他更多的是从特征的角度来解释 这个特征怎么影响了模型 但
  • python实现货币转换

    实现美元与人民币的转换 2022 4 16 1美元 6 37人民币 moneyStr input 请输入带有标志 RMB rmb USD usd 的钱数 if moneyStr 3 in RMB rmb dollar eval moneyS
  • [java]线程安全问题

    线程安全问题产生有五个产生原因 1 线程的随机调度和抢占式执行 就是这个机制使得线程安全问题产生 2 代码结构 多个线程对同一个变量进行修改 3 原子性 修改操作的是可拆分的 导致脏读问题 4 内存可见性问题 一个线程读一个线程写 5 指令
  • 自定义屏幕保护

    一 设计器页面及代码 Form2 Designer cs namespace 自定义屏保 partial class Form2