Advertisement
KuoHsiangYu

DrawingLine3_MyForm.h

Nov 17th, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.85 KB | None | 0 0
  1. #pragma once
  2.  
  3. namespace DrawingLine3
  4. {
  5.  
  6.     using namespace System;
  7.     using namespace System::ComponentModel;
  8.     using namespace System::Collections;
  9.     using namespace System::Windows::Forms;
  10.     using namespace System::Data;
  11.     using namespace System::Drawing;
  12.  
  13.     /// <summary>
  14.     /// MyForm 的摘要
  15.     /// </summary>
  16.     public ref class MyForm : public System::Windows::Forms::Form
  17.     {
  18.     public:
  19.         MyForm(void)
  20.         {
  21.             InitializeComponent();
  22.             //
  23.             //TODO:  在此加入建構函式程式碼
  24.             //
  25.         }
  26.  
  27.     protected:
  28.         /// <summary>
  29.         /// 清除任何使用中的資源。
  30.         /// </summary>
  31.         ~MyForm()
  32.         {
  33.             if (components)
  34.             {
  35.                 delete components;
  36.             }
  37.         }
  38.     private: System::Windows::Forms::Button^  button1;
  39.     protected:
  40.  
  41.     private:
  42.         /// <summary>
  43.         /// 設計工具所需的變數。
  44.         /// </summary>
  45.         System::ComponentModel::Container ^components;
  46.  
  47. #pragma region Windows Form Designer generated code
  48.         /// <summary>
  49.         /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改
  50.         /// 這個方法的內容。
  51.         /// </summary>
  52.         void InitializeComponent(void)
  53.         {
  54.             this->button1 = (gcnew System::Windows::Forms::Button());
  55.             this->SuspendLayout();
  56.             //
  57.             // button1
  58.             //
  59.             this->button1->Location = System::Drawing::Point(197, 226);
  60.             this->button1->Name = L"button1";
  61.             this->button1->Size = System::Drawing::Size(75, 23);
  62.             this->button1->TabIndex = 0;
  63.             this->button1->Text = L"button1";
  64.             this->button1->UseVisualStyleBackColor = true;
  65.             this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
  66.             //
  67.             // MyForm
  68.             //
  69.             this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
  70.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  71.             this->ClientSize = System::Drawing::Size(284, 261);
  72.             this->Controls->Add(this->button1);
  73.             this->Name = L"MyForm";
  74.             this->Text = L"MyForm";
  75.             this->ResumeLayout(false);
  76.  
  77.         }
  78. #pragma endregion
  79.     private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
  80.     {
  81.         Graphics^ G = this->CreateGraphics();
  82.         int Idx = 0;
  83.  
  84.         //for (Idx = 1; Idx <= 100; Idx += 3)
  85.         //{
  86.         //  G->DrawLine(Pens::White, 0, Idx, 200, Idx);
  87.         //  G->DrawLine(Pens::Gray, 0, Idx + 1, 200, Idx + 1);
  88.         //  G->DrawLine(Pens::Black, 0, Idx + 2, 200, Idx + 2);
  89.         //}
  90.  
  91.         G->DrawLine(gcnew Pen(Brushes::Red, 7), 30, 1, 10, 100);
  92.         G->DrawLine(gcnew Pen(Brushes::Orange, 6), 27, 1, 20, 100);
  93.         G->DrawLine(gcnew Pen(Brushes::Yellow, 5), 24, 1, 30, 100);
  94.         G->DrawLine(gcnew Pen(Brushes::Green, 4), 21, 1, 40, 100);
  95.         G->DrawLine(gcnew Pen(Brushes::Blue, 3), 18, 1, 50, 100);
  96.         G->DrawLine(gcnew Pen(Brushes::Indigo, 2), 15, 1, 60, 100);
  97.         G->DrawLine(Pens::Purple, 12, 1, 70, 100);
  98.         G->DrawLine(Pens::Black, 9, 1, 80, 100);
  99.         G->DrawLine(Pens::Gray, 6, 1, 90, 100);
  100.         G->DrawLine(Pens::White, 3, 1, 100, 100);
  101.     }
  102.     };
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement