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; namespace _180926p { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Klik(object sender, EventArgs e) { BackColor = (sender as Control).BackColor; } Random nc = new Random(); private void butRandom_Click(object sender, EventArgs e) { labB.BackColor = Color.FromArgb(nc.Next(256), nc.Next(256), nc.Next(256)); panB.BackColor = Color.FromArgb(nc.Next(256), nc.Next(256), nc.Next(256)); pibB.BackColor = Color.FromArgb(nc.Next(256), nc.Next(256), nc.Next(256)); } private void butGray_Click(object sender, EventArgs e) { int b = nc.Next(256); labB.BackColor = Color.FromArgb(b, b, b); b = nc.Next(256); panB.BackColor = Color.FromArgb(b, b, b); b = nc.Next(256); pibB.BackColor = Color.FromArgb(b, b, b); } private void butCD_Click(object sender, EventArgs e) { ColorDialog cd = new ColorDialog(); DialogResult dr = cd.ShowDialog(); if (dr == DialogResult.OK) { labB.BackColor = cd.Color; panB.BackColor = cd.Color; pibB.BackColor = cd.Color; } else MessageBox.Show("Trhni si","Prý jsi chtěl barvu?",MessageBoxButtons.OK,MessageBoxIcon.Information); } private void Form1_BackColorChanged(object sender, EventArgs e) { rtbVýpis.Text = $@"Barva pozadí formuláře: RGB({BackColor.R},{BackColor.G},{BackColor.B})"; } private void Form1_Load(object sender, EventArgs e) { labB.BackColor = Color.FromArgb(nc.Next(256), nc.Next(256), nc.Next(256)); panB.BackColor = Color.FromArgb(nc.Next(256), nc.Next(256), nc.Next(256)); pibB.BackColor = Color.FromArgb(nc.Next(256), nc.Next(256), nc.Next(256)); BackColor = Color.White; } } }
|