📄 gdiplus.cpp
字号:
f->Controls->Add(label2);
f->Controls->Add(label3);
f->Controls->Add(label4);
f->Controls->Add(textBox1);
f->Controls->Add(textBox2);
f->Controls->Add(textBox3);
f->Controls->Add(textBox4);
System::Windows::Forms::DialogResult res = f->ShowDialog();
if(res == System::Windows::Forms::DialogResult::OK )
{
pActiveDoc->nShapeLeft = UInt16::Parse(textBox1->Text);
pActiveDoc->nShapeTop = UInt16::Parse(textBox2->Text);
pActiveDoc->nShapeWidth = UInt16::Parse(textBox3->Text);
pActiveDoc->nShapeHeight = UInt16::Parse(textBox4->Text);
pActiveView->HandleEllipseDraw();
f->Close();
}
}
void CMainWindow::DrawRect()
{
Form* f = new Form();
//Get the document of active view
CGDIPlusView* pActiveView = dynamic_cast<CGDIPlusView*> (this->ActiveMdiChild);
CGDIPlusDoc* pActiveDoc = pActiveView->GetDocument();
f->AutoScaleBaseSize = System::Drawing::Size(5, 13);
f->Text = "Draw Rectangle";
f->ClientSize = System::Drawing::Size(300, 125);
Button* button1 = new Button();
button1->Location = System::Drawing::Point(70, 100);
button1->Size = System::Drawing::Size(60, 20);
button1->TabIndex = 1;
button1->Text = "OK";
button1->DialogResult = System::Windows::Forms::DialogResult::OK ;//Make this "OK" button
Button* button2 = new Button();
button2->Location = System::Drawing::Point(150, 100);
button2->Size = System::Drawing::Size(60, 20);
button2->TabIndex = 6;
button2->Text = "Cancel";
//Left
TextBox* textBox1 = new TextBox();
textBox1->Location = System::Drawing::Point(80, 15);
textBox1->Text = "10"; //pActiveDoc->nThinWidth.ToString();
textBox1->TabIndex = 1;
textBox1->Size = System::Drawing::Size(64, 20);
//Top
TextBox* textBox2 = new TextBox();
textBox2->Location = System::Drawing::Point(80, 45);
textBox2->Text = "10"; //pActiveDoc->nThickWidth.ToString();
textBox2->TabIndex = 2;
textBox2->Size = System::Drawing::Size(64, 20);
Label* label1 = new Label();
label1->Location = System::Drawing::Point(15, 20);
label1->Text = "Left:";
label1->Size = System::Drawing::Size(50, 16);
label1->TabIndex = 3;
Label* label2 = new Label();
label2->Location = System::Drawing::Point(15, 50);
label2->Text = "Top:";
label2->Size = System::Drawing::Size(50, 16);
label2->TabIndex = 4;
//PSK START
TextBox* textBox3 = new TextBox();
textBox3->Location = System::Drawing::Point(220, 15);
textBox3->Text = "50"; //pActiveDoc->nThinWidth.ToString();
textBox3->TabIndex = 1;
textBox3->Size = System::Drawing::Size(64, 20);
TextBox* textBox4 = new TextBox();
textBox4->Location = System::Drawing::Point(220, 45);
textBox4->Text = "25"; //pActiveDoc->nThickWidth.ToString();
textBox4->TabIndex = 2;
textBox4->Size = System::Drawing::Size(64, 20);
Label* label3 = new Label();
label3->Location = System::Drawing::Point(155, 20);
label3->Text = "Width:";
label3->Size = System::Drawing::Size(50, 16);
label3->TabIndex = 3;
Label* label4 = new Label();
label4->Location = System::Drawing::Point(155, 50);
label4->Text = "Height:";
label4->Size = System::Drawing::Size(50, 16);
label4->TabIndex = 4;
//END
f->FormBorderStyle = FormBorderStyle::FixedDialog;
// Set the MaximizeBox to false to remove the maximize box.
f->MaximizeBox = false;
// Set the MinimizeBox to false to remove the minimize box.
f->MinimizeBox = false;
// Set the accept button of the form to button1.
f->AcceptButton = button1;
// Set the cancel button of the form to button2.
f->CancelButton = button2;
f->StartPosition = FormStartPosition::CenterScreen;
f->Controls->Add(button1);
f->Controls->Add(button2);
f->Controls->Add(label1);
f->Controls->Add(label2);
f->Controls->Add(label3);
f->Controls->Add(label4);
f->Controls->Add(textBox1);
f->Controls->Add(textBox2);
f->Controls->Add(textBox3);
f->Controls->Add(textBox4);
System::Windows::Forms::DialogResult res = f->ShowDialog();
if(res == System::Windows::Forms::DialogResult::OK )
{
//Draw Rectange in the View
pActiveDoc->nShapeLeft = Int16::Parse(textBox1->Text);
pActiveDoc->nShapeTop = Int16::Parse(textBox2->Text);
pActiveDoc->nShapeWidth = Int16::Parse(textBox3->Text);
pActiveDoc->nShapeHeight = Int16::Parse(textBox4->Text);
pActiveView->HandleRectDraw();
f->Close();
}
}
void CMainWindow::DrawText()
{
Form* f = new Form();
//Get the document of active view
CGDIPlusView* pActiveView = dynamic_cast<CGDIPlusView*> (this->ActiveMdiChild);
CGDIPlusDoc* pActiveDoc = pActiveView->GetDocument();
f->AutoScaleBaseSize = System::Drawing::Size(5, 13);
f->Text = "Draw String";
f->ClientSize = System::Drawing::Size(200, 140);
Button* button1 = new Button();
button1->Location = System::Drawing::Point(40, 100);
button1->Size = System::Drawing::Size(60, 20);
button1->TabIndex = 1;
button1->Text = "OK";
button1->DialogResult = System::Windows::Forms::DialogResult::OK ;//Make this "OK" button
Button* button2 = new Button();
button2->Location = System::Drawing::Point(120, 100);
button2->Size = System::Drawing::Size(60, 20);
button2->TabIndex = 6;
button2->Text = "Cancel";
TextBox* textBox1 = new TextBox();
textBox1->Location = System::Drawing::Point(15, 40);
textBox1->TabIndex = 1;
textBox1->Size = System::Drawing::Size(100, 20);
Label* label1 = new Label();
label1->Location = System::Drawing::Point(15, 20);
label1->Text = "Please Enter the text:";
label1->Size = System::Drawing::Size(130, 16);
label1->TabIndex = 3;
f->FormBorderStyle = FormBorderStyle::FixedDialog;
f->MaximizeBox = false;
f->MinimizeBox = false;
f->AcceptButton = button1;
f->CancelButton = button2;
f->StartPosition = FormStartPosition::CenterScreen;
f->Controls->Add(button1);
f->Controls->Add(button2);
f->Controls->Add(label1);
f->Controls->Add(textBox1);
String* pstrText;
System::Windows::Forms::DialogResult res = f->ShowDialog();
if(res == System::Windows::Forms::DialogResult::OK )
{
pstrText = textBox1->Text;
f->Close();
}
else
{
return;
}
//END FORM
FontDialog* pFontDialog;
pFontDialog = new FontDialog();
Color colorTxtColor = Color::Black;
Drawing::Font* pTxtFont;
if ( pFontDialog->ShowDialog() != DialogResult::Cancel )
{
colorTxtColor = pFontDialog->get_Color();
pTxtFont = pFontDialog->get_Font();
}
pActiveView->HandleTextDraw(pstrText, pTxtFont, colorTxtColor);
}
void CMainWindow::DrawLine()
{
Form* f = new Form();
//Get the document of active view
CGDIPlusView* pActiveView = dynamic_cast<CGDIPlusView*> (this->ActiveMdiChild);
CGDIPlusDoc* pActiveDoc = pActiveView->GetDocument();
f->AutoScaleBaseSize = System::Drawing::Size(5, 13);
f->Text = "Draw Line";
f->ClientSize = System::Drawing::Size(300, 125);
Button* button1 = new Button();
button1->Location = System::Drawing::Point(70, 100);
button1->Size = System::Drawing::Size(60, 20);
button1->TabIndex = 1;
button1->Text = "OK";
button1->DialogResult = System::Windows::Forms::DialogResult::OK ;//Make this "OK" button
Button* button2 = new Button();
button2->Location = System::Drawing::Point(150, 100);
button2->Size = System::Drawing::Size(60, 20);
button2->TabIndex = 6;
button2->Text = "Cancel";
//Left
TextBox* textBox1 = new TextBox();
textBox1->Location = System::Drawing::Point(80, 15);
textBox1->Text = "10"; //pActiveDoc->nThinWidth.ToString();
textBox1->TabIndex = 1;
textBox1->Size = System::Drawing::Size(64, 20);
//Top
TextBox* textBox2 = new TextBox();
textBox2->Location = System::Drawing::Point(80, 45);
textBox2->Text = "10"; //pActiveDoc->nThickWidth.ToString();
textBox2->TabIndex = 2;
textBox2->Size = System::Drawing::Size(64, 20);
Label* label1 = new Label();
label1->Location = System::Drawing::Point(15, 20);
label1->Text = "Point1-X:";
label1->Size = System::Drawing::Size(55, 16);
label1->TabIndex = 3;
Label* label2 = new Label();
label2->Location = System::Drawing::Point(15, 50);
label2->Text = "Point1-Y:";
label2->Size = System::Drawing::Size(55, 16);
label2->TabIndex = 4;
//PSK START
TextBox* textBox3 = new TextBox();
textBox3->Location = System::Drawing::Point(220, 15);
textBox3->Text = "50"; //pActiveDoc->nThinWidth.ToString();
textBox3->TabIndex = 1;
textBox3->Size = System::Drawing::Size(64, 20);
TextBox* textBox4 = new TextBox();
textBox4->Location = System::Drawing::Point(220, 45);
textBox4->Text = "25"; //pActiveDoc->nThickWidth.ToString();
textBox4->TabIndex = 2;
textBox4->Size = System::Drawing::Size(64, 20);
Label* label3 = new Label();
label3->Location = System::Drawing::Point(155, 20);
label3->Text = "Point2-X:";
label3->Size = System::Drawing::Size(55, 16);
label3->TabIndex = 3;
Label* label4 = new Label();
label4->Location = System::Drawing::Point(155, 50);
label4->Text = "Point2-Y:";
label4->Size = System::Drawing::Size(55, 16);
label4->TabIndex = 4;
//END
f->FormBorderStyle = FormBorderStyle::FixedDialog;
// Set the MaximizeBox to false to remove the maximize box.
f->MaximizeBox = false;
// Set the MinimizeBox to false to remove the minimize box.
f->MinimizeBox = false;
// Set the accept button of the form to button1.
f->AcceptButton = button1;
// Set the cancel button of the form to button2.
f->CancelButton = button2;
f->StartPosition = FormStartPosition::CenterScreen;
f->Controls->Add(button1);
f->Controls->Add(button2);
f->Controls->Add(label1);
f->Controls->Add(label2);
f->Controls->Add(label3);
f->Controls->Add(label4);
f->Controls->Add(textBox1);
f->Controls->Add(textBox2);
f->Controls->Add(textBox3);
f->Controls->Add(textBox4);
System::Windows::Forms::DialogResult res = f->ShowDialog();
if(res == System::Windows::Forms::DialogResult::OK )
{
pActiveDoc->nShapeLeft = UInt16::Parse(textBox1->Text);
pActiveDoc->nShapeTop = UInt16::Parse(textBox2->Text);
pActiveDoc->nShapeWidth = UInt16::Parse(textBox3->Text);
pActiveDoc->nShapeHeight = UInt16::Parse(textBox4->Text);
pActiveView->HandleLineDraw();
f->Close();
}
}
void CMainWindow::DrawFilledEllipse()
{
Form* f = new Form();
//Get the document of active view
CGDIPlusView* pActiveView = dynamic_cast<CGDIPlusView*> (this->ActiveMdiChild);
CGDIPlusDoc* pActiveDoc = pActiveView->GetDocument();
f->AutoScaleBaseSize = System::Drawing::Size(5, 13);
f->Text = "Draw Filled Ellipse";
f->ClientSize = System::Drawing::Size(300, 125);
Button* button1 = new Button();
button1->Location = System::Drawing::Point(70, 100);
button1->Size = System::Drawing::Size(60, 20);
button1->TabIndex = 1;
button1->Text = "OK";
button1->DialogResult = System::Windows::Forms::DialogResult::OK ;//Make this "OK" button
Button* button2 = new Button();
button2->Location = System::Drawing::Point(150, 100);
button2->Size = System::Drawing::Size(60, 20);
button2->TabIndex = 6;
button2->Text = "Cancel";
//Left
TextBox* textBox1 = new TextBox();
textBox1->Location = System::Drawing::Point(80, 15);
textBox1->Text = "10"; //pActiveDoc->nThinWidth.ToString();
textBox1->TabIndex = 1;
textBox1->Size = System::Drawing::Size(64, 20);
//Top
TextBox* textBox2 = new TextBox();
textBox2->Location = System::Drawing::Point(80, 45);
textBox2->Text = "10"; //pActiveDoc->nThickWidth.ToString();
textBox2->TabIndex = 2;
textBox2->Size = System::Drawing::Size(64, 20);
Label* label1 = new Label();
label1->Location = System::Drawing::Point(15, 20);
label1->Text = "Left:";
label1->Size = System::Drawing::Size(50, 16);
label1->TabIndex = 3;
Label* label2 = new Label();
label2->Location = System::Drawing::Point(15, 50);
label2->Text = "Top:";
label2->Size = System::Drawing::Size(50, 16);
label2->TabIndex = 4;
//PSK START
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -