Advertisement
Tark_Wight

Untitled

Apr 23rd, 2023
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. #pragma once
  2. #include "point.h"
  3.  
  4.  
  5. namespace WFA {
  6.  
  7. using namespace System;
  8. using namespace System::ComponentModel;
  9. using namespace System::Collections;
  10. using namespace System::Windows::Forms;
  11. using namespace System::Data;
  12. using namespace System::Drawing;
  13.  
  14.  
  15. public ref class Form1 : public System::Windows::Forms::Form {
  16. public:
  17. Pointf* point;
  18. int i, j, k, countOfPair;
  19. Graphics^ graphic;
  20. Color^ color;
  21. Pen^ pen;
  22.  
  23. Form1(void) {
  24. InitializeComponent();
  25. i = 0;
  26. color = gcnew Color();
  27. pen = gcnew Pen(color->Red);
  28. countOfPair = 10;
  29. graphic = pictureBox1->CreateGraphics();
  30. point = new Pointf[countOfPair];
  31. }
  32. private:
  33. System::Windows::Forms::ComboBox^ comboBox1;
  34. System::Windows::Forms::PictureBox^ pictureBox1;
  35. System::ComponentModel::Container^ component;
  36. protected:
  37. ~Form1() {
  38. if (component) {
  39. delete component;
  40. }
  41. }
  42.  
  43.  
  44. #pragma region Windows Form Designer generated code
  45. /// <summary>
  46. /// Требуемый метод для поддержки конструктора — не изменяйте
  47. /// содержимое этого метода с помощью редактора кода.
  48. /// </summary>
  49. void InitializeComponent(void) {
  50. this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
  51. this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
  52. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();
  53. this->SuspendLayout();
  54. //
  55. // pictureBox1
  56. //
  57. this->pictureBox1->Location = System::Drawing::Point(12, 12);
  58. this->pictureBox1->Name = L"pictureBox1";
  59. this->pictureBox1->Size = System::Drawing::Size(179, 238);
  60. this->pictureBox1->TabIndex = 1;
  61. this->pictureBox1->TabStop = false;
  62. this->pictureBox1->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::pictureBox1_MouseDown);
  63. //
  64. // comboBox1
  65. //
  66. this->comboBox1->FormattingEnabled = true;
  67. this->comboBox1->Location = System::Drawing::Point(209, 12);
  68. this->comboBox1->Name = L"comboBox1";
  69. this->comboBox1->Size = System::Drawing::Size(63, 21);
  70. this->comboBox1->TabIndex = 2;
  71. this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox1_SelectedIndexChanged);
  72. //
  73. // Form1
  74. //
  75. this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  76. this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  77. this->ClientSize = System::Drawing::Size(284, 262);
  78. this->Controls->Add(this->comboBox1);
  79. this->Controls->Add(this->pictureBox1);
  80. this->Name = L"Form1";
  81. this->Text = L"Form1";
  82. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();
  83. this->ResumeLayout(false);
  84.  
  85. }
  86. #pragma endregion
  87. private:
  88. System::Void pictureBox1_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
  89. if (i < countOfPair * 2) {
  90. graphic->DrawEllipse(pen, e->X, e->Y, 3.0, 3.0);
  91. point[i].x = e->X;
  92. point[i].y = e->Y;
  93. if (i % 2 == 1) {
  94. graphic->DrawLine(pen, e->X, e->Y, point[i - 1].x, point[i - 1].y);
  95. }
  96. comboBox1->Items->Add(Convert::ToString(point[i].x) + " | " + Convert::ToString(point[i].y));
  97. i++;
  98. }
  99. }
  100.  
  101.  
  102. System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
  103. }
  104. };
  105. }
  106.  
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement