Пятница, Ноябрь 27, 2020

Цвет формы,надписи

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 prog1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            while (Visible)
            {
                for (int c = 0; c < 254; c++)
                {
                    this.BackColor = Color.FromArgb(255 - c, c, c);
                    Application.DoEvents();
                    System.Threading.Thread.Sleep(10);
                }
                for (int c = 254; c >= 0 &&Visible; c--)
                {
                    this.BackColor = Color.FromArgb(255 - c, c, c);
                    Application.DoEvents();
                    System.Threading.Thread.Sleep(10);
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true)
            {
                if (label1.BackColor == Color.Red)
                {
                    label1.BackColor = Color.Blue;
                }
                else
                {
                    label1.BackColor = Color.Red;
                }
            }
            else
            {
                MessageBox.Show("Поставь галочку");
            }
        }
    }
}

Back to Top