
#pragma once
namespace My44 {
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::NumericUpDown^ nRed;
protected:
private: System::Windows::Forms::Label^ lblRed;
private: System::Windows::Forms::NumericUpDown^ nGreen;
private: System::Windows::Forms::NumericUpDown^ nBlue;
private: System::Windows::Forms::Label^ lblGreen;
private: System::Windows::Forms::Label^ lblBlue;
private: System::Windows::Forms::PictureBox^ pctResult;
private: System::Windows::Forms::Button^ BtnShowResult;
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->nRed = (gcnew System::Windows::Forms::NumericUpDown());
this->lblRed = (gcnew System::Windows::Forms::Label());
this->nGreen = (gcnew System::Windows::Forms::NumericUpDown());
this->nBlue = (gcnew System::Windows::Forms::NumericUpDown());
this->lblGreen = (gcnew System::Windows::Forms::Label());
this->lblBlue = (gcnew System::Windows::Forms::Label());
this->pctResult = (gcnew System::Windows::Forms::PictureBox());
this->BtnShowResult = (gcnew System::Windows::Forms::Button());
(cli::safe_cast
(cli::safe_cast
(cli::safe_cast
(cli::safe_cast
this->SuspendLayout();
//
// nRed
//
this->nRed->Location = System::Drawing::Point(51, 22);
this->nRed->Name = L"nRed";
this->nRed->Size = System::Drawing::Size(43, 20);
this->nRed->TabIndex = 0;
this->nRed->ValueChanged += gcnew System::EventHandler(this, &Form1::nRed_ValueChanged);
//
// lblRed
//
this->lblRed->AutoSize = true;
this->lblRed->Location = System::Drawing::Point(12, 24);
this->lblRed->Name = L"lblRed";
this->lblRed->Size = System::Drawing::Size(33, 13);
this->lblRed->TabIndex = 1;
this->lblRed->Text = L"Red :";
//
// nGreen
//
this->nGreen->Location = System::Drawing::Point(51, 61);
this->nGreen->Name = L"nGreen";
this->nGreen->Size = System::Drawing::Size(43, 20);
this->nGreen->TabIndex = 2;
this->nGreen->ValueChanged += gcnew System::EventHandler(this, &Form1::nGreen_ValueChanged);
//
// nBlue
//
this->nBlue->Location = System::Drawing::Point(51, 97);
this->nBlue->Name = L"nBlue";
this->nBlue->Size = System::Drawing::Size(43, 20);
this->nBlue->TabIndex = 3;
this->nBlue->ValueChanged += gcnew System::EventHandler(this, &Form1::nBlue_ValueChanged);
//
// lblGreen
//
this->lblGreen->AutoSize = true;
this->lblGreen->Location = System::Drawing::Point(12, 63);
this->lblGreen->Name = L"lblGreen";
this->lblGreen->Size = System::Drawing::Size(42, 13);
this->lblGreen->TabIndex = 4;
this->lblGreen->Text = L"Green :";
//
// lblBlue
//
this->lblBlue->AutoSize = true;
this->lblBlue->Location = System::Drawing::Point(12, 99);
this->lblBlue->Name = L"lblBlue";
this->lblBlue->Size = System::Drawing::Size(34, 13);
this->lblBlue->TabIndex = 5;
this->lblBlue->Text = L"Blue :";
//
// pctResult
//
this->pctResult->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->pctResult->Location = System::Drawing::Point(109, 23);
this->pctResult->Name = L"pctResult";
this->pctResult->Size = System::Drawing::Size(170, 102);
this->pctResult->TabIndex = 6;
this->pctResult->TabStop = false;
//
// BtnShowResult
//
this->BtnShowResult->Location = System::Drawing::Point(12, 131);
this->BtnShowResult->Name = L"BtnShowResult";
this->BtnShowResult->Size = System::Drawing::Size(267, 30);
this->BtnShowResult->TabIndex = 7;
this->BtnShowResult->Text = L"Show Result";
this->BtnShowResult->UseVisualStyleBackColor = true;
this->BtnShowResult->Click += gcnew System::EventHandler(this, &Form1::BtnShowResult_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 162);
this->Controls->Add(this->BtnShowResult);
this->Controls->Add(this->pctResult);
this->Controls->Add(this->lblBlue);
this->Controls->Add(this->lblGreen);
this->Controls->Add(this->nBlue);
this->Controls->Add(this->nGreen);
this->Controls->Add(this->lblRed);
this->Controls->Add(this->nRed);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
(cli::safe_cast
(cli::safe_cast
(cli::safe_cast
(cli::safe_cast
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
//MixColor
int cRed;
int cGreen;
int cBlue;
void UpdateMixColor()
{
pctResult->BackColor=Color::FromArgb(cRed,cGreen,cBlue);
}
private: System::Void nRed_ValueChanged(System::Object^ sender, System::EventArgs^ e) {
cRed=Convert::ToInt32(nRed->Value);
UpdateMixColor();
}
private: System::Void nGreen_ValueChanged(System::Object^ sender, System::EventArgs^ e) {
cGreen=Convert::ToInt32(nGreen->Value);
UpdateMixColor();
}
private: System::Void nBlue_ValueChanged(System::Object^ sender, System::EventArgs^ e) {
cBlue=Convert::ToInt32(nBlue->Value);
UpdateMixColor();
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
nRed->Maximum=255;
nGreen->Maximum=255;
nBlue->Maximum=255;
this->Text="MixColor";
this->MaximizeBox=false;
}
private: System::Void BtnShowResult_Click(System::Object^ sender, System::EventArgs^ e) {
UpdateMixColor();
}
};
}