欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#實(shí)現(xiàn)簡(jiǎn)單的窗口抖動(dòng)

 更新時(shí)間:2021年07月21日 12:25:38   作者:氪金萬歲~  
這篇文章主要為大家詳細(xì)介紹了C#實(shí)現(xiàn)簡(jiǎn)單的窗口抖動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了C#實(shí)現(xiàn)簡(jiǎn)單的窗口抖動(dòng)的具體代碼,供大家參考,具體內(nèi)容如下

屬性賦值:

1、查看屬性的類型,如果是C#中預(yù)定義的15種屬性類型,直接賦值

(1)查看屬性類型:鼠標(biāo)懸停在屬性單詞上;
(2)C#中預(yù)定義的屬性類型

2、排除第一種,符號(hào)后面試著敲空格,如果出現(xiàn)智能提示直接敲小數(shù)點(diǎn),選擇一個(gè)合適的選項(xiàng)分號(hào)結(jié)束

3、遇到特殊類型Color,等號(hào)后面直接使用屬性類型單詞點(diǎn),選擇一個(gè)分號(hào)結(jié)束

簡(jiǎn)單的窗口抖動(dòng)案例

項(xiàng)目分析

1、首先添加窗口加載(load)事件,頁面加載時(shí)設(shè)置窗口的大小,初始位置,在視圖的工具箱中給窗口添加按鈕(button);并設(shè)置button對(duì)象的text屬性的屬性值.

2、給button對(duì)象設(shè)置單擊(click)事件;

3、改變窗口的位置(設(shè)置線程);

4、設(shè)置for循環(huán),點(diǎn)擊時(shí)執(zhí)行多次;

5、添加隨機(jī)色(背景)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//全部都是命名空間
using System.Threading;

namespace _02窗口抖動(dòng)
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }
    private void Form1_Load(object sender, EventArgs e)
    {
      this.BackColor = Color.Pink;
      //設(shè)置窗口的大小
      this.Width = 300;
      this.Height = 300;
      //窗口初識(shí)位置
      this.Left = 300;
      this.Top = 300;
      //button按鈕設(shè)置文本為“按鈕”
      button1.Text = "按鈕";
      button1.Width = 80;
      button1.Height = 40;
      button1.BackColor = Color.SkyBlue;
    }

    private void button1_Click(object sender, EventArgs e)
    {
     //設(shè)置隨機(jī)色
      Random r = new Random();
      for (int i=0;i<5;i++) {
        //this.BackColor = Color.Plum;
        this.Left = 303;
        //線程:代碼執(zhí)行的路線進(jìn)程
        //方法:小括號(hào)分號(hào)結(jié)束,給括號(hào)中填參數(shù)
        Thread.Sleep(20);
        this.Top = 303;
        Thread.Sleep(20);
        //this.BackColor = Color.Tomato;
        this.Left = 300;
        Thread.Sleep(20);
        this.Left = 297;
        Thread.Sleep(20);
        this.Top = 300;
        Thread.Sleep(20);
        this.Top = 297;
        Thread.Sleep(20);
        //this.BackColor = Color.SteelBlue;
        this.Left = 300;
        Thread.Sleep(20);
        this.Left = 307;
        Thread.Sleep(20);
        this.Top = 300;
        Thread.Sleep(20);
        this.Left = 300;
        //this.BackColor = Color.Pink;
      }
      //隨機(jī)色
      this.BackColor = Color.FromArgb(r.Next(256), r.Next(256), r.Next(256));
    }
  }
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論