私は、Windowsフォームを使用してVisualStudio2010を使用してC++でプログラミングしています。フリギン嫌い!
ベクトル配列を使用したいのですが、ネイティブC ++プログラムで簡単に実行できますが、フォームで使用するウォークスルーの例が見つかりません。
main.cppにcliext/vectorを含めました。Form.hに含めようとすると、それができないと表示されます。ベクトル配列変数を作成しようとすると、
構文エラーがありません';' '<'の前
私がやりたいのは、6つの配列(int / float / 2 Point / 2 String ^)を作成することです。これにより、データを簡単に追加して、後で読み戻すこともできます。
設定方法の例が必要です。
[編集]
動作しないコードを投稿することが、動作する例へのリンクを取得するのにどのように役立つかはわかりませんが、確かに...私はそれに沿って進みます。
ああ、名前空間cliextを使用して追加すると、.hファイルの先頭で、cliextはクラスまたはnamesapceではないと言われています。
エラーの最初のロードは、ベクトル構文がどのように間違っているかに関するものです...その後、変数が未定義であることに起因するエラーのロードが発生します。
#pragma once
namespace Lab6_Draw_V1 {
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>
/// Summary for Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
iPix=1;
sColorLine="Black";
sColor="Black";
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Panel^ panel1;
protected:
private: System::Windows::Forms::ColorDialog^ colorDialog1;
private: System::Windows::Forms::Label^ colorBox1;
private: System::Windows::Forms::RadioButton^ BtnPix1;
private: System::Windows::Forms::RadioButton^ BtnPix3;
private: System::Windows::Forms::RadioButton^ BtnPix5;
private: System::Windows::Forms::ToolStrip^ toolStrip1;
private: System::Windows::Forms::ToolStripButton^ toolStripBtnLine;
private: System::Windows::Forms::ToolStripButton^ toolStripBtnSquare;
private: System::Windows::Forms::ToolStripButton^ toolStripBtnEllipse;
private: System::Windows::Forms::ToolStripButton^ toolStripBtnColor;
private: System::Windows::Forms::Label^ labelPos1;
private: System::Windows::Forms::Label^ labelPos2;
private:
/// <summary>
/// Required designer variable.
Point firstPoint,finalPoint,iSize;
bool Drawing,move;
int iShape;
float iPix;
String^ sColor;
String^ sColorLine;
vector<int> vShape;
vector<Point> vfirstPoint;
vector<Point> vSize;
vector<float> vPix;
vector<String^>^ vfillColor;
vector<String^>^ vlineColor;
private: System::Windows::Forms::RadioButton^ BtnPix7;
private: System::Windows::Forms::RadioButton^ BtnPix10;
private: System::Windows::Forms::RadioButton^ BtnPix15;
private: System::Windows::Forms::Panel^ panel2;
private: System::Windows::Forms::ToolStripButton^ toolStripBtnLineColor;
private: System::Windows::Forms::Label^ colorBox2;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->panel1 = (gcnew System::Windows::Forms::Panel());
this->colorDialog1 = (gcnew System::Windows::Forms::ColorDialog());
this->colorBox1 = (gcnew System::Windows::Forms::Label());
this->BtnPix1 = (gcnew System::Windows::Forms::RadioButton());
this->BtnPix3 = (gcnew System::Windows::Forms::RadioButton());
this->BtnPix5 = (gcnew System::Windows::Forms::RadioButton());
this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());
this->toolStripBtnLine = (gcnew System::Windows::Forms::ToolStripButton());
this->toolStripBtnSquare = (gcnew System::Windows::Forms::ToolStripButton());
this->toolStripBtnEllipse = (gcnew System::Windows::Forms::ToolStripButton());
this->toolStripBtnColor = (gcnew System::Windows::Forms::ToolStripButton());
this->toolStripBtnLineColor = (gcnew System::Windows::Forms::ToolStripButton());
this->labelPos1 = (gcnew System::Windows::Forms::Label());
this->labelPos2 = (gcnew System::Windows::Forms::Label());
this->BtnPix7 = (gcnew System::Windows::Forms::RadioButton());
this->BtnPix10 = (gcnew System::Windows::Forms::RadioButton());
this->BtnPix15 = (gcnew System::Windows::Forms::RadioButton());
this->panel2 = (gcnew System::Windows::Forms::Panel());
this->colorBox2 = (gcnew System::Windows::Forms::Label());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->toolStrip1->SuspendLayout();
this->SuspendLayout();
//
// panel1
//
this->panel1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->panel1->Location = System::Drawing::Point(160, 37);
this->panel1->Name = L"panel1";
this->panel1->Size = System::Drawing::Size(837, 447);
this->panel1->TabIndex = 0;
this->panel1->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::panel1_Paint);
this->panel1->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::panel1_MouseDown);
this->panel1->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::panel1_MouseMove);
this->panel1->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::panel1_MouseUp);
//
// colorBox1
//
this->colorBox1->AutoSize = true;
this->colorBox1->BackColor = System::Drawing::Color::White;
this->colorBox1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->colorBox1->Location = System::Drawing::Point(16, 148);
this->colorBox1->MinimumSize = System::Drawing::Size(37, 37);
this->colorBox1->Name = L"colorBox1";
this->colorBox1->Size = System::Drawing::Size(37, 37);
this->colorBox1->TabIndex = 6;
this->colorBox1->BackColorChanged += gcnew System::EventHandler(this, &Form1::colorBox1_BackColorChanged);
//
// BtnPix1
//
this->BtnPix1->AutoSize = true;
this->BtnPix1->Checked = true;
this->BtnPix1->Location = System::Drawing::Point(83, 213);
this->BtnPix1->Name = L"BtnPix1";
this->BtnPix1->Size = System::Drawing::Size(56, 17);
this->BtnPix1->TabIndex = 7;
this->BtnPix1->TabStop = true;
this->BtnPix1->Text = L"1 Pixel";
this->BtnPix1->UseVisualStyleBackColor = true;
this->BtnPix1->CheckedChanged += gcnew System::EventHandler(this, &Form1::BtnPix1_CheckedChanged);
//
// BtnPix3
//
this->BtnPix3->AutoSize = true;
this->BtnPix3->Location = System::Drawing::Point(83, 236);
this->BtnPix3->Name = L"BtnPix3";
this->BtnPix3->Size = System::Drawing::Size(56, 17);
this->BtnPix3->TabIndex = 8;
this->BtnPix3->Text = L"3 Pixel";
this->BtnPix3->UseVisualStyleBackColor = true;
this->BtnPix3->CheckedChanged += gcnew System::EventHandler(this, &Form1::BtnPix3_CheckedChanged);
//
// BtnPix5
//
this->BtnPix5->AutoSize = true;
this->BtnPix5->Location = System::Drawing::Point(83, 259);
this->BtnPix5->Name = L"BtnPix5";
this->BtnPix5->Size = System::Drawing::Size(56, 17);
this->BtnPix5->TabIndex = 9;
this->BtnPix5->Text = L"5 Pixel";
this->BtnPix5->UseVisualStyleBackColor = true;
this->BtnPix5->CheckedChanged += gcnew System::EventHandler(this, &Form1::BtnPix5_CheckedChanged);
//
// toolStrip1
//
this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(5) {this->toolStripBtnLine,
this->toolStripBtnSquare, this->toolStripBtnEllipse, this->toolStripBtnColor, this->toolStripBtnLineColor});
this->toolStrip1->Location = System::Drawing::Point(0, 0);
this->toolStrip1->Name = L"toolStrip1";
this->toolStrip1->Size = System::Drawing::Size(1016, 25);
this->toolStrip1->TabIndex = 10;
this->toolStrip1->Text = L"toolStrip1";
this->toolStrip1->ItemClicked += gcnew System::Windows::Forms::ToolStripItemClickedEventHandler(this, &Form1::toolStrip1_ItemClicked);
//
// toolStripBtnLine
//
this->toolStripBtnLine->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
this->toolStripBtnLine->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripBtnLine.Image")));
this->toolStripBtnLine->ImageTransparentColor = System::Drawing::Color::Magenta;
this->toolStripBtnLine->Name = L"toolStripBtnLine";
this->toolStripBtnLine->Size = System::Drawing::Size(33, 22);
this->toolStripBtnLine->Text = L"Line";
this->toolStripBtnLine->Click += gcnew System::EventHandler(this, &Form1::toolStripBtnLine_Click);
//
// toolStripBtnSquare
//
this->toolStripBtnSquare->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
this->toolStripBtnSquare->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripBtnSquare.Image")));
this->toolStripBtnSquare->ImageTransparentColor = System::Drawing::Color::Magenta;
this->toolStripBtnSquare->Name = L"toolStripBtnSquare";
this->toolStripBtnSquare->Size = System::Drawing::Size(47, 22);
this->toolStripBtnSquare->Text = L"Square";
this->toolStripBtnSquare->Click += gcnew System::EventHandler(this, &Form1::toolStripBtnSquare_Click);
//
// toolStripBtnEllipse
//
this->toolStripBtnEllipse->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
this->toolStripBtnEllipse->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripBtnEllipse.Image")));
this->toolStripBtnEllipse->ImageTransparentColor = System::Drawing::Color::Magenta;
this->toolStripBtnEllipse->Name = L"toolStripBtnEllipse";
this->toolStripBtnEllipse->Size = System::Drawing::Size(44, 22);
this->toolStripBtnEllipse->Text = L"Ellipse";
this->toolStripBtnEllipse->Click += gcnew System::EventHandler(this, &Form1::toolStripBtnEllipse_Click);
//
// toolStripBtnColor
//
this->toolStripBtnColor->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
this->toolStripBtnColor->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripBtnColor.Image")));
this->toolStripBtnColor->ImageTransparentColor = System::Drawing::Color::Magenta;
this->toolStripBtnColor->Name = L"toolStripBtnColor";
this->toolStripBtnColor->Size = System::Drawing::Size(58, 22);
this->toolStripBtnColor->Text = L"Fill Color";
this->toolStripBtnColor->Click += gcnew System::EventHandler(this, &Form1::toolStripBtnColor_Click);
//
// toolStripBtnLineColor
//
this->toolStripBtnLineColor->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text;
this->toolStripBtnLineColor->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripBtnLineColor.Image")));
this->toolStripBtnLineColor->ImageTransparentColor = System::Drawing::Color::Magenta;
this->toolStripBtnLineColor->Name = L"toolStripBtnLineColor";
this->toolStripBtnLineColor->Size = System::Drawing::Size(65, 22);
this->toolStripBtnLineColor->Text = L"Line Color";
this->toolStripBtnLineColor->Click += gcnew System::EventHandler(this, &Form1::toolStripBtnLineColor_Click);
//
// labelPos1
//
this->labelPos1->AutoSize = true;
this->labelPos1->Location = System::Drawing::Point(712, 504);
this->labelPos1->Name = L"labelPos1";
this->labelPos1->Size = System::Drawing::Size(35, 13);
this->labelPos1->TabIndex = 11;
this->labelPos1->Text = L"label1";
//
// labelPos2
//
this->labelPos2->AutoSize = true;
this->labelPos2->Location = System::Drawing::Point(848, 504);
this->labelPos2->Name = L"labelPos2";
this->labelPos2->Size = System::Drawing::Size(35, 13);
this->labelPos2->TabIndex = 12;
this->labelPos2->Text = L"label2";
//
// BtnPix7
//
this->BtnPix7->AutoSize = true;
this->BtnPix7->Location = System::Drawing::Point(83, 282);
this->BtnPix7->Name = L"BtnPix7";
this->BtnPix7->Size = System::Drawing::Size(56, 17);
this->BtnPix7->TabIndex = 13;
this->BtnPix7->Text = L"7 Pixel";
this->BtnPix7->UseVisualStyleBackColor = true;
this->BtnPix7->CheckedChanged += gcnew System::EventHandler(this, &Form1::BtnPix7_CheckedChanged);
//
// BtnPix10
//
this->BtnPix10->AutoSize = true;
this->BtnPix10->Location = System::Drawing::Point(83, 306);
this->BtnPix10->Name = L"BtnPix10";
this->BtnPix10->Size = System::Drawing::Size(62, 17);
this->BtnPix10->TabIndex = 14;
this->BtnPix10->Text = L"10 Pixel";
this->BtnPix10->UseVisualStyleBackColor = true;
this->BtnPix10->CheckedChanged += gcnew System::EventHandler(this, &Form1::BtnPix10_CheckedChanged);
//
// BtnPix15
//
this->BtnPix15->AutoSize = true;
this->BtnPix15->Location = System::Drawing::Point(83, 329);
this->BtnPix15->Name = L"BtnPix15";
this->BtnPix15->Size = System::Drawing::Size(62, 17);
this->BtnPix15->TabIndex = 15;
this->BtnPix15->Text = L"15 Pixel";
this->BtnPix15->UseVisualStyleBackColor = true;
this->BtnPix15->CheckedChanged += gcnew System::EventHandler(this, &Form1::BtnPix15_CheckedChanged);
//
// panel2
//
this->panel2->BackColor = System::Drawing::Color::White;
this->panel2->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->panel2->Location = System::Drawing::Point(83, 148);
this->panel2->Name = L"panel2";
this->panel2->Size = System::Drawing::Size(37, 37);
this->panel2->TabIndex = 17;
//
// colorBox2
//
this->colorBox2->AutoSize = true;
this->colorBox2->BackColor = System::Drawing::Color::Black;
this->colorBox2->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->colorBox2->Location = System::Drawing::Point(16, 213);
this->colorBox2->MinimumSize = System::Drawing::Size(37, 37);
this->colorBox2->Name = L"colorBox2";
this->colorBox2->Size = System::Drawing::Size(37, 37);
this->colorBox2->TabIndex = 18;
this->colorBox2->BackColorChanged += gcnew System::EventHandler(this, &Form1::colorBox2_BackColorChanged);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(8, 250);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(54, 13);
this->label1->TabIndex = 19;
this->label1->Text = L"Line Color";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(12, 185);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(46, 13);
this->label2->TabIndex = 20;
this->label2->Text = L"Fill Color";
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::Control;
this->ClientSize = System::Drawing::Size(1016, 538);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->colorBox2);
this->Controls->Add(this->panel2);
this->Controls->Add(this->BtnPix15);
this->Controls->Add(this->BtnPix10);
this->Controls->Add(this->BtnPix7);
this->Controls->Add(this->labelPos2);
this->Controls->Add(this->labelPos1);
this->Controls->Add(this->toolStrip1);
this->Controls->Add(this->BtnPix5);
this->Controls->Add(this->BtnPix3);
this->Controls->Add(this->BtnPix1);
this->Controls->Add(this->colorBox1);
this->Controls->Add(this->panel1);
this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
this->MinimumSize = System::Drawing::Size(1024, 530);
this->Name = L"Form1";
this->Text = L"Lab 6 Paint";
this->toolStrip1->ResumeLayout(false);
this->toolStrip1->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void btnColor_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void panel1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
// Loop with case statements for the shapes and colours
// grab data from vector array
}
private: System::Void toolStripBtnColor_Click(System::Object^ sender, System::EventArgs^ e) {
ColorDialog^ MyDialog = gcnew ColorDialog;
// Keeps the user from selecting a custom color.
MyDialog->AllowFullOpen = false;
// Allows the user to get help. (The default is false.)
MyDialog->ShowHelp = true;
// Sets the initial color select to the current text color.
MyDialog->Color = panel1->ForeColor;
// Update the text box color if the user clicks OK
if ( MyDialog->ShowDialog() == ::System::Windows::Forms::DialogResult::OK )
{
colorBox1->BackColor= MyDialog->Color;
sColor = Convert::ToString(colorBox1->BackColor);
// labelColor->Text=sColor;
}
}
private: System::Void panel1_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
if( e->Button== System::Windows::Forms::MouseButtons::Left)
{
Drawing = true;
firstPoint = e->Location;
labelPos1->Text = Convert::ToString(e->Location);
// set shape flag
}
if( e->Button== System::Windows::Forms::MouseButtons::Right)
{
move=true;
iSize.X=finalPoint.X-firstPoint.X;
iSize.Y=finalPoint.Y-firstPoint.Y;
}
}
private: System::Void toolStrip1_ItemClicked(System::Object^ sender, System::Windows::Forms::ToolStripItemClickedEventArgs^ e) {
}
private: System::Void panel1_MouseMove(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)
{
// tempPos = e-> Location; labelPos2-> Text = Convert :: ToString(e-> Location);
if(Drawing)
{
//draw temp outline with no fill and black outline
panel1->Refresh();
auto g = panel1->CreateGraphics();
switch(iShape)
{
case 1:
g->DrawLine(Pens::Black,firstPoint,e->Location);
break;
case 2:
g->DrawRectangle(Pens::Black,firstPoint.X,firstPoint.Y,(e->Location.X-firstPoint.X),(e->Location.Y-firstPoint.Y));
break;
case 3:
g->DrawEllipse(Pens::Black,firstPoint.X,firstPoint.Y,(e->Location.X-firstPoint.X),(e->Location.Y-firstPoint.Y));
default:break;
}
}
if(move)
{
//code
panel1->Refresh();
auto g = panel1->CreateGraphics();
firstPoint=e->Location;
SolidBrush^ myBrush = gcnew SolidBrush(Color::FromArgb(colorBox1->BackColor.A,colorBox1->BackColor.R,colorBox1->BackColor.G,colorBox1->BackColor.B) );
Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
myPen->Width = iPix;
switch(iShape)
{
case 1:
finalPoint.X=iSize.X+firstPoint.X;
finalPoint.Y=iSize.Y+firstPoint.Y;
g->DrawLine(myPen,firstPoint,finalPoint);
break;
case 2:
g->FillRectangle(myBrush,firstPoint.X,firstPoint.Y,iSize.X,iSize.Y);
g->DrawRectangle(myPen,firstPoint.X,firstPoint.Y,iSize.X,iSize.Y);
break;
case 3:
g->FillEllipse(myBrush,firstPoint.X,firstPoint.Y,iSize.X,iSize.Y);
g->DrawEllipse(myPen,firstPoint.X,firstPoint.Y,iSize.X,iSize.Y);
break;
default:break;
}
}
}
private: System::Void panel1_MouseUp(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)
{
if( e->Button== System::Windows::Forms::MouseButtons::Left)
{
finalPoint = e->Location;
labelPos2->Text = Convert::ToString(e->Location);
// draw filled shape
panel1->Refresh();
auto g = panel1->CreateGraphics();
SolidBrush^ myBrush = gcnew SolidBrush(Color::FromArgb(colorBox1->BackColor.A,colorBox1->BackColor.R,colorBox1->BackColor.G,colorBox1->BackColor.B) );
Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
myPen->Width = iPix;
switch(iShape)
{
case 1:
g->DrawLine(myPen,firstPoint,finalPoint);
break;
case 2:
g->FillRectangle(myBrush,firstPoint.X,firstPoint.Y,(e->Location.X-firstPoint.X),(e->Location.Y-firstPoint.Y));
g->DrawRectangle(myPen,firstPoint.X,firstPoint.Y,(e->Location.X-firstPoint.X),(e->Location.Y-firstPoint.Y));
break;
case 3:
g->FillEllipse(myBrush,firstPoint.X,firstPoint.Y,(e->Location.X-firstPoint.X),(e->Location.Y-firstPoint.Y));
g->DrawEllipse(myPen,firstPoint.X,firstPoint.Y,(e->Location.X-firstPoint.X),(e->Location.Y-firstPoint.Y));
break;
default:break;
}
iSize.X=finalPoint.X-firstPoint.X;
iSzie.Y=finalPoint.Y-firstPoint.Y;
vShape.push_back (iShape);
vfirstPoint.push_back (firstPoint);
vSize.push_back (iSize);
vfillColor.push_back (myBrush);
vlineColor.push_back (myPen);
vPix.push_back (iPix);
Drawing=false;
}
else move=false;
}
private: System::Void toolStripBtnLine_Click(System::Object^ sender, System::EventArgs^ e) {
iShape=1;
}
private: System::Void toolStripBtnSquare_Click(System::Object^ sender, System::EventArgs^ e) {
iShape=2;
}
private: System::Void toolStripBtnEllipse_Click(System::Object^ sender, System::EventArgs^ e) {
iShape=3;
}
private: System::Void BtnPix1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
iPix=1;
panel2->Refresh();
auto g = panel2->CreateGraphics();
Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
myPen->Width = iPix;
g->DrawLine(myPen,2,18,33,18);
}
private: System::Void BtnPix3_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
iPix=3;
panel2->Refresh();
auto g = panel2->CreateGraphics();
Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
myPen->Width = iPix;
g->DrawLine(myPen,2,18,33,18);
}
private: System::Void BtnPix5_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
iPix=5;
panel2->Refresh();
auto g = panel2->CreateGraphics();
Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
myPen->Width = iPix;
g->DrawLine(myPen,2,18,33,18);
}
private: System::Void BtnPix7_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
iPix=7;
panel2->Refresh();
auto g = panel2->CreateGraphics();
Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
myPen->Width = iPix;
g->DrawLine(myPen,2,18,33,18);
}
private: System::Void BtnPix10_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
iPix=10;
panel2->Refresh();
auto g = panel2->CreateGraphics();
Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
myPen->Width = iPix;
g->DrawLine(myPen,2,18,33,18);
}
private: System::Void BtnPix15_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
iPix=15;
panel2->Refresh();
auto g = panel2->CreateGraphics();
Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
myPen->Width = iPix;
g->DrawLine(myPen,2,18,33,18);
}
private: System::Void toolStripBtnLineColor_Click(System::Object^ sender, System::EventArgs^ e) {
ColorDialog^ MyDialog = gcnew ColorDialog;
// Keeps the user from selecting a custom color.
MyDialog->AllowFullOpen = false;
// Allows the user to get help. (The default is false.)
MyDialog->ShowHelp = true;
// Sets the initial color select to the current text color.
MyDialog->Color = colorBox2->BackColor;
// Update the text box color if the user clicks OK
if ( MyDialog->ShowDialog() == ::System::Windows::Forms::DialogResult::OK )
{
sColorLine = Convert::ToString(MyDialog->Color);
// labelColorLine->Text=sColorLine;
colorBox2->BackColor= MyDialog->Color;
}
}
private: System::Void colorBox1_BackColorChanged(System::Object^ sender, System::EventArgs^ e) {
panel1->Refresh();
auto g = panel1->CreateGraphics();
SolidBrush^ myBrush = gcnew SolidBrush(Color::FromArgb(colorBox1->BackColor.A,colorBox1->BackColor.R,colorBox1->BackColor.G,colorBox1->BackColor.B) );
Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
myPen->Width = iPix;
switch(iShape)
{
case 1:
g->DrawLine(myPen,firstPoint,finalPoint);
break;
case 2:
g->FillRectangle(myBrush,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
g->DrawRectangle(myPen,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
break;
case 3:
g->FillEllipse(myBrush,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
g->DrawEllipse(myPen,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
break;
default:break;
}
}
private: System::Void colorBox2_BackColorChanged(System::Object^ sender, System::EventArgs^ e) {
panel1->Refresh();
auto g = panel1->CreateGraphics();
SolidBrush^ myBrush = gcnew SolidBrush(Color::FromArgb(colorBox1->BackColor.A,colorBox1->BackColor.R,colorBox1->BackColor.G,colorBox1->BackColor.B) );
Pen^ myPen = gcnew Pen(Color::FromArgb(colorBox2->BackColor.A,colorBox2->BackColor.R,colorBox2->BackColor.G,colorBox2->BackColor.B) );
myPen->Width = iPix;
switch(iShape)
{
case 1:
g->DrawLine(myPen,firstPoint,finalPoint);
break;
case 2:
g->FillRectangle(myBrush,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
g->DrawRectangle(myPen,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
break;
case 3:
g->FillEllipse(myBrush,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
g->DrawEllipse(myPen,firstPoint.X,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
break;
default:break;
}
}
}; }