Random RGB Color



#pragma once

namespace My29 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
///
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
///

public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
///
/// Clean up any resources being used.
///

~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ BtnShowRGB;
protected:
private: System::Windows::Forms::Button^ BRed;
private: System::Windows::Forms::Button^ BtnGreen;
private: System::Windows::Forms::Button^ BtnBlue;
private: System::Windows::Forms::PictureBox^ PctResult;

protected:
private:
///
/// Required designer variable.
///

System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

void InitializeComponent(void)
{
this->BtnShowRGB = (gcnew System::Windows::Forms::Button());
this->BRed = (gcnew System::Windows::Forms::Button());
this->BtnGreen = (gcnew System::Windows::Forms::Button());
this->BtnBlue = (gcnew System::Windows::Forms::Button());
this->PctResult = (gcnew System::Windows::Forms::PictureBox());
(cli::safe_cast
(this->PctResult))->BeginInit();
this->SuspendLayout();
//
// BtnShowRGB
//
this->BtnShowRGB->Location = System::Drawing::Point(12, 185);
this->BtnShowRGB->Name = L"BtnShowRGB";
this->BtnShowRGB->Size = System::Drawing::Size(145, 40);
this->BtnShowRGB->TabIndex = 0;
this->BtnShowRGB->Text = L"Show ColorRGB";
this->BtnShowRGB->UseVisualStyleBackColor = true;
this->BtnShowRGB->Click += gcnew System::EventHandler(this, &Form1::BtnRandomRGB_Click);
//
// BRed
//
this->BRed->Location = System::Drawing::Point(12, 12);
this->BRed->Name = L"BRed";
this->BRed->Size = System::Drawing::Size(145, 42);
this->BRed->TabIndex = 1;
this->BRed->Text = L"Red";
this->BRed->UseVisualStyleBackColor = true;
this->BRed->Click += gcnew System::EventHandler(this, &Form1::BRed_Click);
//
// BtnGreen
//
this->BtnGreen->Location = System::Drawing::Point(12, 60);
this->BtnGreen->Name = L"BtnGreen";
this->BtnGreen->Size = System::Drawing::Size(145, 42);
this->BtnGreen->TabIndex = 2;
this->BtnGreen->Text = L"Green";
this->BtnGreen->UseVisualStyleBackColor = true;
this->BtnGreen->Click += gcnew System::EventHandler(this, &Form1::BtnGreen_Click);
//
// BtnBlue
//
this->BtnBlue->Location = System::Drawing::Point(12, 108);
this->BtnBlue->Name = L"BtnBlue";
this->BtnBlue->Size = System::Drawing::Size(145, 42);
this->BtnBlue->TabIndex = 3;
this->BtnBlue->Text = L"Blue";
this->BtnBlue->UseVisualStyleBackColor = true;
this->BtnBlue->Click += gcnew System::EventHandler(this, &Form1::BtnBlue_Click);
//
// PctResult
//
this->PctResult->Location = System::Drawing::Point(168, 11);
this->PctResult->Name = L"PctResult";
this->PctResult->Size = System::Drawing::Size(369, 213);
this->PctResult->TabIndex = 4;
this->PctResult->TabStop = false;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(550, 236);
this->Controls->Add(this->PctResult);
this->Controls->Add(this->BtnBlue);
this->Controls->Add(this->BtnGreen);
this->Controls->Add(this->BRed);
this->Controls->Add(this->BtnShowRGB);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
(cli::safe_cast
(this->PctResult))->EndInit();
this->ResumeLayout(false);
}
#pragma endregion
//Random RGB Color
int rRed;
int rGreen;
int rBlue;
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
this->MaximizeBox=false;
this->BackColor=Color::Gray;
this->Text="Random RGB Color = Red : "+rRed+" Green : "+rGreen+
" Blue : "+rBlue;
PctResult->BackColor=Color::Black;
PctResult->BorderStyle=Windows::Forms::BorderStyle::Fixed3D;
}
private: System::Void BtnRandomRGB_Click(System::Object^ sender, System::EventArgs^ e) {
PctResult->BackColor=Color::FromArgb(rRed,rGreen,rBlue);
this->Text="Random RGB Color = Red : "+rRed+" Green : "+rGreen+
" Blue : "+rBlue;
}
private: System::Void BRed_Click(System::Object^ sender, System::EventArgs^ e) {
rRed=Random().Next(255);
}
private: System::Void BtnGreen_Click(System::Object^ sender, System::EventArgs^ e) {
rGreen=Random().Next(255);
}
private: System::Void BtnBlue_Click(System::Object^ sender, System::EventArgs^ e) {
rBlue=Random().Next(255);
}
};
}