TrackBar — бегунок

Скрыть

Показать

Копировать
  Form1.cs  
  • 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 _0052 {
  •  public partial class Form1 : Form {
  •   int red = 0;
  •   int green = 0;
  •   int blue = 0;
  •   public Form1() {
  •    InitializeComponent();
  •    textBoxColor.BackColor = Color.FromArgb(red, green, blue);
  •    panel1.Select();
  •    textBoxRedDec.Text = trackBarRed.Value.ToString();
  •    textBoxRedHex.Text = string.Format("{0:X}", trackBarRed.Value);
  •    textBoxGreenDec.Text = trackBarGreen.Value.ToString();
  •    textBoxGreenHex.Text = string.Format("{0:X}", trackBarGreen.Value);
  •    textBoxBlueDec.Text = trackBarBlue.Value.ToString();
  •    textBoxBlueHex.Text = string.Format("{0:X}", trackBarBlue.Value);
  •    textBoxTextDec.Text = string.Format("{0}, {1}, {2}", red, blue, green);
  •    textBoxTextHex.Text = string.Format("{0:X}{1:X}{2:X}", red, blue, green);
  •   }
  •   private void trackBarRed_Scroll(object sender, EventArgs e) {
  •    textBoxRedDec.Text = trackBarRed.Value.ToString();
  •    textBoxRedHex.Text = string.Format("{0:X}", trackBarRed.Value);
  •    red = trackBarRed.Value;
  •    textBoxColor.BackColor = Color.FromArgb(red, green, blue);
  •    textBoxTextDec.Text = string.Format("{0}, {1}, {2}", red, blue, green);
  •    textBoxTextHex.Text = string.Format("{0:X}{1:X}{2:X}", red, blue, green);
  •   }
  •   private void trackBarGreen_Scroll(object sender, EventArgs e) {
  •    textBoxGreenDec.Text = trackBarGreen.Value.ToString();
  •    textBoxGreenHex.Text = string.Format("{0:X}", trackBarGreen.Value);
  •    green = trackBarGreen.Value;
  •    textBoxColor.BackColor = Color.FromArgb(red, green, blue);
  •    textBoxTextDec.Text = string.Format("{0}, {1}, {2}", red, blue, green);
  •    textBoxTextHex.Text = string.Format("{0:X}{1:X}{2:X}", red, blue, green);
  •   }
  •  
  •   private void trackBarBlue_Scroll(object sender, EventArgs e) {
  •    textBoxBlueDec.Text = trackBarBlue.Value.ToString();
  •    textBoxBlueHex.Text = string.Format("{0:X}", trackBarBlue.Value);
  •    blue = trackBarBlue.Value;
  •    textBoxColor.BackColor = Color.FromArgb(red, green, blue);
  •    textBoxTextDec.Text = string.Format("{0}, {1}, {2}", red, blue, green);
  •    textBoxTextHex.Text = string.Format("{0:X}{1:X}{2:X}", red, blue, green);
  •   }
  •  }
  • }