C++ Konvertierung nach Visual Basic

  • VB.NET
  • .NET (FX) 4.5–4.8

Es gibt 23 Antworten in diesem Thema. Der letzte Beitrag () ist von Facebamm.

    C++ Konvertierung nach Visual Basic

    Hallo,
    bin neu hier im Forum, habe aber nur Gutes und echt coole Hilfestellung finden können. Ich benötige dringend Hilfe, mache gerade eine Weiterbildung in Visual Basic. Wir haben eine Aufgabe in dem Kreis, Rechteck und Linie erst nach innen und danach nach aussen animiert werden sollen. Habe die folgende Laufzeit in C++ gefunden. Kann jemad diesen evtl. in VB konvertieren?? Danke.

    Spoiler anzeigen

    Quellcode

    1. namespace Forms_spielerei {
    2. using namespace System;
    3. using namespace System::ComponentModel;
    4. using namespace System::Collections;
    5. using namespace System::Windows::Forms;
    6. using namespace System::Data;
    7. using namespace System::Drawing;
    8. using namespace System::Drawing::Drawing2D;
    9. /// <summary>
    10. /// Zusammenfassung für MyForm
    11. /// </summary>
    12. public ref class MyForm : public System::Windows::Forms::Form
    13. {
    14. private:
    15. enum class Figur : int
    16. {
    17. Kreis,
    18. Rechteck,
    19. Linie
    20. };
    21. Figur figur;
    22. Int32 linienStaerke;
    23. Color linienFarbe;
    24. Color hintergrundFarbe;
    25. DashStyle linienStil;
    26. HatchStyle fuellStil;
    27. Int32 startGroesse;
    28. Int32 animationWiederholung;
    29. Int32 animationInterval;
    30. Boolean animationAktiv;
    31. Int32 animationLauf;
    32. Boolean animationMinus;
    33. Int32 animationGroesse;
    34. /*
    35. Die Vereinbarung muss als static erfolgen.
    36. Andernfalls kann man dem Array keine Werte zuweisen.
    37. */
    38. //für die Linienstile
    39. static array <DashStyle>^ auswahlLinienstile = {
    40. DashStyle::Solid,
    41. DashStyle::Dash,
    42. DashStyle::DashDot,
    43. DashStyle::DashDotDot,
    44. DashStyle::Dot};
    45. //für die Hintergrundmuster
    46. static array <HatchStyle> ^auswahlFuellstile = {
    47. HatchStyle::BackwardDiagonal,
    48. HatchStyle::Cross,
    49. HatchStyle::DottedGrid,
    50. HatchStyle::ForwardDiagonal,
    51. HatchStyle::Sphere,
    52. HatchStyle::Vertical,
    53. HatchStyle::Wave,
    54. HatchStyle::ZigZag };
    55. public:
    56. MyForm(void)
    57. {
    58. InitializeComponent();
    59. figur = Figur::Kreis;
    60. }
    61. protected:
    62. /// <summary>Verwendete Ressourcen bereinigen.</summary>
    63. ~MyForm()
    64. {
    65. if (components)
    66. {
    67. delete components;
    68. }
    69. }
    70. #pragma region Designer Variables
    71. private: System::Windows::Forms::Panel^ anzeigePanel;
    72. private: System::Windows::Forms::GroupBox^ groupBox2;
    73. private: System::Windows::Forms::GroupBox^ groupBox1;
    74. private: System::Windows::Forms::Label^ label3;
    75. private: System::Windows::Forms::Label^ label2;
    76. private: System::Windows::Forms::ListBox^ listBoxLinieStil;
    77. private: System::Windows::Forms::Label^ label1;
    78. private: System::Windows::Forms::NumericUpDown^ numericUpDownLinieStaerke;
    79. private: System::Windows::Forms::RadioButton^ radioButtonHintergrundMuster;
    80. private: System::Windows::Forms::RadioButton^ radioButtonHintergrundFarbe;
    81. private: System::Windows::Forms::RadioButton^ radioButtonHintergrundOhne;
    82. private: System::Windows::Forms::ListBox^ listBoxHintergrundMuster;
    83. private: System::Windows::Forms::Label^ label5;
    84. private: System::Windows::Forms::Label^ label4;
    85. private: System::Windows::Forms::GroupBox^ groupBox3;
    86. private: System::Windows::Forms::RadioButton^ radioButtonLinie;
    87. private: System::Windows::Forms::RadioButton^ radioButtonKreis;
    88. private: System::Windows::Forms::RadioButton^ radioButtonRechteck;
    89. private: System::Windows::Forms::TrackBar^ groesseTrackbar;
    90. private: System::Windows::Forms::Button^ buttonStart;
    91. private: System::Windows::Forms::Button^ buttonLoeschen;
    92. private: System::Windows::Forms::Button^ buttonBeenden;
    93. private: System::Windows::Forms::Button^ buttonLinieFarbe;
    94. private: System::Windows::Forms::Panel^ panelLinieFarbeVorschau;
    95. private: System::Windows::Forms::ColorDialog^ colorDialog1;
    96. private: System::Windows::Forms::Button^ buttonHintergrundFarbe;
    97. private: System::Windows::Forms::Panel^ panelHintergrundFarbeVorschau;
    98. private: System::Windows::Forms::Label^ label6;
    99. private: System::Windows::Forms::Label^ label7;
    100. private: System::Windows::Forms::Button^ buttonAnimation;
    101. private: System::Windows::Forms::NumericUpDown^ numericUpDownWiederholungen;
    102. private: System::Windows::Forms::NumericUpDown^ numericUpDownDauer;
    103. private: System::Windows::Forms::Timer^ animationTimer;
    104. /// <summary>Erforderliche Designervariable.</summary>
    105. private: System::ComponentModel::IContainer^ components;
    106. #pragma endregion
    107. private:
    108. #pragma region Windows Form Designer generated code
    109. /// <summary>
    110. /// Erforderliche Methode für die Designerunterstützung.
    111. /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
    112. /// </summary>
    113. void InitializeComponent(void)
    114. {
    115. this->components = (gcnew System::ComponentModel::Container());
    116. this->anzeigePanel = (gcnew System::Windows::Forms::Panel());
    117. this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
    118. this->buttonHintergrundFarbe = (gcnew System::Windows::Forms::Button());
    119. this->panelHintergrundFarbeVorschau = (gcnew System::Windows::Forms::Panel());
    120. this->listBoxHintergrundMuster = (gcnew System::Windows::Forms::ListBox());
    121. this->label5 = (gcnew System::Windows::Forms::Label());
    122. this->label4 = (gcnew System::Windows::Forms::Label());
    123. this->radioButtonHintergrundMuster = (gcnew System::Windows::Forms::RadioButton());
    124. this->radioButtonHintergrundFarbe = (gcnew System::Windows::Forms::RadioButton());
    125. this->radioButtonHintergrundOhne = (gcnew System::Windows::Forms::RadioButton());
    126. this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
    127. this->buttonLinieFarbe = (gcnew System::Windows::Forms::Button());
    128. this->panelLinieFarbeVorschau = (gcnew System::Windows::Forms::Panel());
    129. this->label3 = (gcnew System::Windows::Forms::Label());
    130. this->listBoxLinieStil = (gcnew System::Windows::Forms::ListBox());
    131. this->numericUpDownLinieStaerke = (gcnew System::Windows::Forms::NumericUpDown());
    132. this->label2 = (gcnew System::Windows::Forms::Label());
    133. this->label1 = (gcnew System::Windows::Forms::Label());
    134. this->groupBox3 = (gcnew System::Windows::Forms::GroupBox());
    135. this->radioButtonLinie = (gcnew System::Windows::Forms::RadioButton());
    136. this->radioButtonKreis = (gcnew System::Windows::Forms::RadioButton());
    137. this->radioButtonRechteck = (gcnew System::Windows::Forms::RadioButton());
    138. this->groesseTrackbar = (gcnew System::Windows::Forms::TrackBar());
    139. this->buttonStart = (gcnew System::Windows::Forms::Button());
    140. this->buttonLoeschen = (gcnew System::Windows::Forms::Button());
    141. this->buttonBeenden = (gcnew System::Windows::Forms::Button());
    142. this->colorDialog1 = (gcnew System::Windows::Forms::ColorDialog());
    143. this->label6 = (gcnew System::Windows::Forms::Label());
    144. this->label7 = (gcnew System::Windows::Forms::Label());
    145. this->buttonAnimation = (gcnew System::Windows::Forms::Button());
    146. this->numericUpDownWiederholungen = (gcnew System::Windows::Forms::NumericUpDown());
    147. this->numericUpDownDauer = (gcnew System::Windows::Forms::NumericUpDown());
    148. this->animationTimer = (gcnew System::Windows::Forms::Timer(this->components));
    149. this->groupBox2->SuspendLayout();
    150. this->groupBox1->SuspendLayout();
    151. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDownLinieStaerke))->BeginInit();
    152. this->groupBox3->SuspendLayout();
    153. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->groesseTrackbar))->BeginInit();
    154. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDownWiederholungen))->BeginInit();
    155. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDownDauer))->BeginInit();
    156. this->SuspendLayout();
    157. //
    158. // anzeigePanel
    159. //
    160. this->anzeigePanel->BackColor = System::Drawing::Color::White;
    161. this->anzeigePanel->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
    162. this->anzeigePanel->Location = System::Drawing::Point(16, 15);
    163. this->anzeigePanel->Margin = System::Windows::Forms::Padding(4);
    164. this->anzeigePanel->Name = L"anzeigePanel";
    165. this->anzeigePanel->Size = System::Drawing::Size(399, 369);
    166. this->anzeigePanel->TabIndex = 0;
    167. this->anzeigePanel->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &MyForm::anzeigePanel_Paint);
    168. //
    169. // groupBox2
    170. //
    171. this->groupBox2->Controls->Add(this->buttonHintergrundFarbe);
    172. this->groupBox2->Controls->Add(this->panelHintergrundFarbeVorschau);
    173. this->groupBox2->Controls->Add(this->listBoxHintergrundMuster);
    174. this->groupBox2->Controls->Add(this->label5);
    175. this->groupBox2->Controls->Add(this->label4);
    176. this->groupBox2->Controls->Add(this->radioButtonHintergrundMuster);
    177. this->groupBox2->Controls->Add(this->radioButtonHintergrundFarbe);
    178. this->groupBox2->Controls->Add(this->radioButtonHintergrundOhne);
    179. this->groupBox2->Location = System::Drawing::Point(436, 158);
    180. this->groupBox2->Margin = System::Windows::Forms::Padding(4);
    181. this->groupBox2->Name = L"groupBox2";
    182. this->groupBox2->Padding = System::Windows::Forms::Padding(4);
    183. this->groupBox2->Size = System::Drawing::Size(267, 133);
    184. this->groupBox2->TabIndex = 2;
    185. this->groupBox2->TabStop = false;
    186. this->groupBox2->Text = L"Hintergrund";
    187. //
    188. // buttonHintergrundFarbe
    189. //
    190. this->buttonHintergrundFarbe->Location = System::Drawing::Point(139, 52);
    191. this->buttonHintergrundFarbe->Margin = System::Windows::Forms::Padding(4);
    192. this->buttonHintergrundFarbe->Name = L"buttonHintergrundFarbe";
    193. this->buttonHintergrundFarbe->Size = System::Drawing::Size(40, 28);
    194. this->buttonHintergrundFarbe->TabIndex = 7;
    195. this->buttonHintergrundFarbe->Text = L"...";
    196. this->buttonHintergrundFarbe->UseVisualStyleBackColor = true;
    197. this->buttonHintergrundFarbe->Click += gcnew System::EventHandler(this, &MyForm::buttonHintergrundFarbe_Click);
    198. //
    199. // panelHintergrundFarbeVorschau
    200. //
    201. this->panelHintergrundFarbeVorschau->BackColor = System::Drawing::Color::White;
    202. this->panelHintergrundFarbeVorschau->Location = System::Drawing::Point(83, 49);
    203. this->panelHintergrundFarbeVorschau->Margin = System::Windows::Forms::Padding(4);
    204. this->panelHintergrundFarbeVorschau->Name = L"panelHintergrundFarbeVorschau";
    205. this->panelHintergrundFarbeVorschau->Size = System::Drawing::Size(36, 30);
    206. this->panelHintergrundFarbeVorschau->TabIndex = 8;
    207. this->panelHintergrundFarbeVorschau->DoubleClick += gcnew System::EventHandler(this, &MyForm::panelHintergrundFarbeVorschau_DoubleClick);
    208. //
    209. // listBoxHintergrundMuster
    210. //
    211. this->listBoxHintergrundMuster->DrawMode = System::Windows::Forms::DrawMode::OwnerDrawFixed;
    212. this->listBoxHintergrundMuster->FormattingEnabled = true;
    213. this->listBoxHintergrundMuster->Location = System::Drawing::Point(77, 85);
    214. this->listBoxHintergrundMuster->Margin = System::Windows::Forms::Padding(4);
    215. this->listBoxHintergrundMuster->Name = L"listBoxHintergrundMuster";
    216. this->listBoxHintergrundMuster->Size = System::Drawing::Size(160, 30);
    217. this->listBoxHintergrundMuster->TabIndex = 4;
    218. this->listBoxHintergrundMuster->DrawItem += gcnew System::Windows::Forms::DrawItemEventHandler(this, &MyForm::listBoxHintergrundMuster_DrawItem);
    219. this->listBoxHintergrundMuster->SelectedIndexChanged += gcnew System::EventHandler(this, &MyForm::listBoxHintergrundMuster_SelectedIndexChanged);
    220. //
    221. // label5
    222. //
    223. this->label5->Location = System::Drawing::Point(8, 85);
    224. this->label5->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
    225. this->label5->Name = L"label5";
    226. this->label5->Size = System::Drawing::Size(55, 26);
    227. this->label5->TabIndex = 5;
    228. this->label5->Text = L"Stil:";
    229. //
    230. // label4
    231. //
    232. this->label4->Location = System::Drawing::Point(8, 52);
    233. this->label4->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
    234. this->label4->Name = L"label4";
    235. this->label4->Size = System::Drawing::Size(55, 26);
    236. this->label4->TabIndex = 4;
    237. this->label4->Text = L"Farbe:";
    238. //
    239. // radioButtonHintergrundMuster
    240. //
    241. this->radioButtonHintergrundMuster->AutoSize = true;
    242. this->radioButtonHintergrundMuster->Location = System::Drawing::Point(165, 23);
    243. this->radioButtonHintergrundMuster->Margin = System::Windows::Forms::Padding(4);
    244. this->radioButtonHintergrundMuster->Name = L"radioButtonHintergrundMuster";
    245. this->radioButtonHintergrundMuster->Size = System::Drawing::Size(72, 21);
    246. this->radioButtonHintergrundMuster->TabIndex = 2;
    247. this->radioButtonHintergrundMuster->TabStop = true;
    248. this->radioButtonHintergrundMuster->Text = L"Muster";
    249. this->radioButtonHintergrundMuster->UseVisualStyleBackColor = true;
    250. this->radioButtonHintergrundMuster->CheckedChanged += gcnew System::EventHandler(this, &MyForm::hintergrund_CheckedChanged);
    251. //
    252. // radioButtonHintergrundFarbe
    253. //
    254. this->radioButtonHintergrundFarbe->AutoSize = true;
    255. this->radioButtonHintergrundFarbe->Location = System::Drawing::Point(89, 23);
    256. this->radioButtonHintergrundFarbe->Margin = System::Windows::Forms::Padding(4);
    257. this->radioButtonHintergrundFarbe->Name = L"radioButtonHintergrundFarbe";
    258. this->radioButtonHintergrundFarbe->Size = System::Drawing::Size(66, 21);
    259. this->radioButtonHintergrundFarbe->TabIndex = 1;
    260. this->radioButtonHintergrundFarbe->TabStop = true;
    261. this->radioButtonHintergrundFarbe->Text = L"Farbe";
    262. this->radioButtonHintergrundFarbe->UseVisualStyleBackColor = true;
    263. this->radioButtonHintergrundFarbe->CheckedChanged += gcnew System::EventHandler(this, &MyForm::hintergrund_CheckedChanged);
    264. //
    265. // radioButtonHintergrundOhne
    266. //
    267. this->radioButtonHintergrundOhne->AutoSize = true;
    268. this->radioButtonHintergrundOhne->Checked = true;
    269. this->radioButtonHintergrundOhne->Location = System::Drawing::Point(12, 23);
    270. this->radioButtonHintergrundOhne->Margin = System::Windows::Forms::Padding(4);
    271. this->radioButtonHintergrundOhne->Name = L"radioButtonHintergrundOhne";
    272. this->radioButtonHintergrundOhne->Size = System::Drawing::Size(61, 21);
    273. this->radioButtonHintergrundOhne->TabIndex = 0;
    274. this->radioButtonHintergrundOhne->TabStop = true;
    275. this->radioButtonHintergrundOhne->Text = L"ohne";
    276. this->radioButtonHintergrundOhne->UseVisualStyleBackColor = true;
    277. this->radioButtonHintergrundOhne->CheckedChanged += gcnew System::EventHandler(this, &MyForm::hintergrund_CheckedChanged);
    278. //
    279. // groupBox1
    280. //
    281. this->groupBox1->Controls->Add(this->buttonLinieFarbe);
    282. this->groupBox1->Controls->Add(this->panelLinieFarbeVorschau);
    283. this->groupBox1->Controls->Add(this->label3);
    284. this->groupBox1->Controls->Add(this->listBoxLinieStil);
    285. this->groupBox1->Controls->Add(this->numericUpDownLinieStaerke);
    286. this->groupBox1->Controls->Add(this->label2);
    287. this->groupBox1->Controls->Add(this->label1);
    288. this->groupBox1->Location = System::Drawing::Point(436, 15);
    289. this->groupBox1->Margin = System::Windows::Forms::Padding(4);
    290. this->groupBox1->Name = L"groupBox1";
    291. this->groupBox1->Padding = System::Windows::Forms::Padding(4);
    292. this->groupBox1->Size = System::Drawing::Size(267, 135);
    293. this->groupBox1->TabIndex = 1;
    294. this->groupBox1->TabStop = false;
    295. this->groupBox1->Text = L"Linie";
    296. //
    297. // buttonLinieFarbe
    298. //
    299. this->buttonLinieFarbe->Location = System::Drawing::Point(139, 21);
    300. this->buttonLinieFarbe->Margin = System::Windows::Forms::Padding(4);
    301. this->buttonLinieFarbe->Name = L"buttonLinieFarbe";
    302. this->buttonLinieFarbe->Size = System::Drawing::Size(40, 28);
    303. this->buttonLinieFarbe->TabIndex = 0;
    304. this->buttonLinieFarbe->Text = L"...";
    305. this->buttonLinieFarbe->UseVisualStyleBackColor = true;
    306. this->buttonLinieFarbe->Click += gcnew System::EventHandler(this, &MyForm::buttonLinieFarbe_Click);
    307. //
    308. // panelLinieFarbeVorschau
    309. //
    310. this->panelLinieFarbeVorschau->BackColor = System::Drawing::Color::Black;
    311. this->panelLinieFarbeVorschau->Location = System::Drawing::Point(83, 18);
    312. this->panelLinieFarbeVorschau->Margin = System::Windows::Forms::Padding(4);
    313. this->panelLinieFarbeVorschau->Name = L"panelLinieFarbeVorschau";
    314. this->panelLinieFarbeVorschau->Size = System::Drawing::Size(36, 30);
    315. this->panelLinieFarbeVorschau->TabIndex = 6;
    316. this->panelLinieFarbeVorschau->DoubleClick += gcnew System::EventHandler(this, &MyForm::panelLinieFarbeVorschau_DoubleClick);
    317. //
    318. // label3
    319. //
    320. this->label3->Location = System::Drawing::Point(8, 100);
    321. this->label3->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
    322. this->label3->Name = L"label3";
    323. this->label3->Size = System::Drawing::Size(55, 26);
    324. this->label3->TabIndex = 5;
    325. this->label3->Text = L"Stärke:";
    326. //
    327. // listBoxLinieStil
    328. //
    329. this->listBoxLinieStil->DrawMode = System::Windows::Forms::DrawMode::OwnerDrawFixed;
    330. this->listBoxLinieStil->FormattingEnabled = true;
    331. this->listBoxLinieStil->Location = System::Drawing::Point(77, 57);
    332. this->listBoxLinieStil->Margin = System::Windows::Forms::Padding(4);
    333. this->listBoxLinieStil->Name = L"listBoxLinieStil";
    334. this->listBoxLinieStil->Size = System::Drawing::Size(160, 30);
    335. this->listBoxLinieStil->TabIndex = 4;
    336. this->listBoxLinieStil->DrawItem += gcnew System::Windows::Forms::DrawItemEventHandler(this, &MyForm::listBoxLinieStil_DrawItem);
    337. this->listBoxLinieStil->SelectedIndexChanged += gcnew System::EventHandler(this, &MyForm::listBoxLinieStil_SelectedIndexChanged);
    338. //
    339. // numericUpDownLinieStaerke
    340. //
    341. this->numericUpDownLinieStaerke->Location = System::Drawing::Point(77, 101);
    342. this->numericUpDownLinieStaerke->Margin = System::Windows::Forms::Padding(4);
    343. this->numericUpDownLinieStaerke->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 20, 0, 0, 0 });
    344. this->numericUpDownLinieStaerke->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
    345. this->numericUpDownLinieStaerke->Name = L"numericUpDownLinieStaerke";
    346. this->numericUpDownLinieStaerke->Size = System::Drawing::Size(161, 22);
    347. this->numericUpDownLinieStaerke->TabIndex = 5;
    348. this->numericUpDownLinieStaerke->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
    349. this->numericUpDownLinieStaerke->ValueChanged += gcnew System::EventHandler(this, &MyForm::numericUpDownLinieStaerke_ValueChanged);
    350. //
    351. // label2
    352. //
    353. this->label2->Location = System::Drawing::Point(8, 57);
    354. this->label2->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
    355. this->label2->Name = L"label2";
    356. this->label2->Size = System::Drawing::Size(32, 26);
    357. this->label2->TabIndex = 4;
    358. this->label2->Text = L"Stil:";
    359. //
    360. // label1
    361. //
    362. this->label1->Location = System::Drawing::Point(8, 23);
    363. this->label1->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
    364. this->label1->Name = L"label1";
    365. this->label1->Size = System::Drawing::Size(49, 26);
    366. this->label1->TabIndex = 3;
    367. this->label1->Text = L"Farbe:";
    368. //
    369. // groupBox3
    370. //
    371. this->groupBox3->Controls->Add(this->radioButtonLinie);
    372. this->groupBox3->Controls->Add(this->radioButtonKreis);
    373. this->groupBox3->Controls->Add(this->radioButtonRechteck);
    374. this->groupBox3->Location = System::Drawing::Point(436, 298);
    375. this->groupBox3->Margin = System::Windows::Forms::Padding(4);
    376. this->groupBox3->Name = L"groupBox3";
    377. this->groupBox3->Padding = System::Windows::Forms::Padding(4);
    378. this->groupBox3->Size = System::Drawing::Size(267, 60);
    379. this->groupBox3->TabIndex = 3;
    380. this->groupBox3->TabStop = false;
    381. this->groupBox3->Text = L"Figur";
    382. //
    383. // radioButtonLinie
    384. //
    385. this->radioButtonLinie->AutoSize = true;
    386. this->radioButtonLinie->Location = System::Drawing::Point(180, 23);
    387. this->radioButtonLinie->Margin = System::Windows::Forms::Padding(4);
    388. this->radioButtonLinie->Name = L"radioButtonLinie";
    389. this->radioButtonLinie->Size = System::Drawing::Size(59, 21);
    390. this->radioButtonLinie->TabIndex = 6;
    391. this->radioButtonLinie->TabStop = true;
    392. this->radioButtonLinie->Text = L"Linie";
    393. this->radioButtonLinie->UseVisualStyleBackColor = true;
    394. this->radioButtonLinie->CheckedChanged += gcnew System::EventHandler(this, &MyForm::anzeigeFigur_CheckedChanged);
    395. //
    396. // radioButtonKreis
    397. //
    398. this->radioButtonKreis->AutoSize = true;
    399. this->radioButtonKreis->Checked = true;
    400. this->radioButtonKreis->Location = System::Drawing::Point(12, 23);
    401. this->radioButtonKreis->Margin = System::Windows::Forms::Padding(4);
    402. this->radioButtonKreis->Name = L"radioButtonKreis";
    403. this->radioButtonKreis->Size = System::Drawing::Size(61, 21);
    404. this->radioButtonKreis->TabIndex = 4;
    405. this->radioButtonKreis->TabStop = true;
    406. this->radioButtonKreis->Text = L"Kreis";
    407. this->radioButtonKreis->UseVisualStyleBackColor = true;
    408. this->radioButtonKreis->CheckedChanged += gcnew System::EventHandler(this, &MyForm::anzeigeFigur_CheckedChanged);
    409. //
    410. // radioButtonRechteck
    411. //
    412. this->radioButtonRechteck->AutoSize = true;
    413. this->radioButtonRechteck->Location = System::Drawing::Point(83, 23);
    414. this->radioButtonRechteck->Margin = System::Windows::Forms::Padding(4);
    415. this->radioButtonRechteck->Name = L"radioButtonRechteck";
    416. this->radioButtonRechteck->Size = System::Drawing::Size(88, 21);
    417. this->radioButtonRechteck->TabIndex = 5;
    418. this->radioButtonRechteck->TabStop = true;
    419. this->radioButtonRechteck->Text = L"Rechteck";
    420. this->radioButtonRechteck->UseVisualStyleBackColor = true;
    421. this->radioButtonRechteck->CheckedChanged += gcnew System::EventHandler(this, &MyForm::anzeigeFigur_CheckedChanged);
    422. //
    423. // groesseTrackbar
    424. //
    425. this->groesseTrackbar->LargeChange = 1;
    426. this->groesseTrackbar->Location = System::Drawing::Point(436, 366);
    427. this->groesseTrackbar->Margin = System::Windows::Forms::Padding(4);
    428. this->groesseTrackbar->Maximum = 3;
    429. this->groesseTrackbar->Minimum = 1;
    430. this->groesseTrackbar->Name = L"groesseTrackbar";
    431. this->groesseTrackbar->Size = System::Drawing::Size(267, 56);
    432. this->groesseTrackbar->TabIndex = 4;
    433. this->groesseTrackbar->Value = 2;
    434. this->groesseTrackbar->Scroll += gcnew System::EventHandler(this, &MyForm::groesseTrackbar_Scroll);
    435. //
    436. // buttonStart
    437. //
    438. this->buttonStart->Location = System::Drawing::Point(436, 426);
    439. this->buttonStart->Margin = System::Windows::Forms::Padding(4);
    440. this->buttonStart->Name = L"buttonStart";
    441. this->buttonStart->Size = System::Drawing::Size(100, 28);
    442. this->buttonStart->TabIndex = 5;
    443. this->buttonStart->Text = L"Los geht\'s";
    444. this->buttonStart->UseVisualStyleBackColor = true;
    445. this->buttonStart->Click += gcnew System::EventHandler(this, &MyForm::buttonStart_Click);
    446. //
    447. // buttonLoeschen
    448. //
    449. this->buttonLoeschen->Location = System::Drawing::Point(544, 426);
    450. this->buttonLoeschen->Margin = System::Windows::Forms::Padding(4);
    451. this->buttonLoeschen->Name = L"buttonLoeschen";
    452. this->buttonLoeschen->Size = System::Drawing::Size(100, 28);
    453. this->buttonLoeschen->TabIndex = 6;
    454. this->buttonLoeschen->Text = L"Löschen";
    455. this->buttonLoeschen->UseVisualStyleBackColor = true;
    456. this->buttonLoeschen->Click += gcnew System::EventHandler(this, &MyForm::buttonLoeschen_Click);
    457. //
    458. // buttonBeenden
    459. //
    460. this->buttonBeenden->Location = System::Drawing::Point(652, 426);
    461. this->buttonBeenden->Margin = System::Windows::Forms::Padding(4);
    462. this->buttonBeenden->Name = L"buttonBeenden";
    463. this->buttonBeenden->Size = System::Drawing::Size(100, 28);
    464. this->buttonBeenden->TabIndex = 7;
    465. this->buttonBeenden->Text = L"Beenden";
    466. this->buttonBeenden->UseVisualStyleBackColor = true;
    467. this->buttonBeenden->Click += gcnew System::EventHandler(this, &MyForm::buttonBeenden_Click);
    468. //
    469. // label6
    470. //
    471. this->label6->Location = System::Drawing::Point(12, 402);
    472. this->label6->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
    473. this->label6->Name = L"label6";
    474. this->label6->Size = System::Drawing::Size(117, 25);
    475. this->label6->TabIndex = 8;
    476. this->label6->Text = L"Wiederholungen:";
    477. //
    478. // label7
    479. //
    480. this->label7->Location = System::Drawing::Point(12, 434);
    481. this->label7->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
    482. this->label7->Name = L"label7";
    483. this->label7->Size = System::Drawing::Size(117, 25);
    484. this->label7->TabIndex = 9;
    485. this->label7->Text = L"Dauer:";
    486. //
    487. // buttonAnimation
    488. //
    489. this->buttonAnimation->Location = System::Drawing::Point(227, 426);
    490. this->buttonAnimation->Margin = System::Windows::Forms::Padding(4);
    491. this->buttonAnimation->Name = L"buttonAnimation";
    492. this->buttonAnimation->Size = System::Drawing::Size(100, 28);
    493. this->buttonAnimation->TabIndex = 10;
    494. this->buttonAnimation->Text = L"Animation";
    495. this->buttonAnimation->UseVisualStyleBackColor = true;
    496. this->buttonAnimation->Click += gcnew System::EventHandler(this, &MyForm::buttonAnimation_Click);
    497. //
    498. // numericUpDownWiederholungen
    499. //
    500. this->numericUpDownWiederholungen->Location = System::Drawing::Point(137, 402);
    501. this->numericUpDownWiederholungen->Margin = System::Windows::Forms::Padding(4);
    502. this->numericUpDownWiederholungen->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 10, 0, 0, 0 });
    503. this->numericUpDownWiederholungen->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
    504. this->numericUpDownWiederholungen->Name = L"numericUpDownWiederholungen";
    505. this->numericUpDownWiederholungen->Size = System::Drawing::Size(63, 22);
    506. this->numericUpDownWiederholungen->TabIndex = 11;
    507. this->numericUpDownWiederholungen->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
    508. this->numericUpDownWiederholungen->ValueChanged += gcnew System::EventHandler(this, &MyForm::numericUpDownWiederholungen_ValueChanged);
    509. //
    510. // numericUpDownDauer
    511. //
    512. this->numericUpDownDauer->Location = System::Drawing::Point(137, 434);
    513. this->numericUpDownDauer->Margin = System::Windows::Forms::Padding(4);
    514. this->numericUpDownDauer->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 15, 0, 0, 0 });
    515. this->numericUpDownDauer->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
    516. this->numericUpDownDauer->Name = L"numericUpDownDauer";
    517. this->numericUpDownDauer->Size = System::Drawing::Size(63, 22);
    518. this->numericUpDownDauer->TabIndex = 12;
    519. this->numericUpDownDauer->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
    520. this->numericUpDownDauer->ValueChanged += gcnew System::EventHandler(this, &MyForm::numericUpDownDauer_ValueChanged);
    521. //
    522. // animationTimer
    523. //
    524. this->animationTimer->Tick += gcnew System::EventHandler(this, &MyForm::animationTimer_Tick);
    525. //
    526. // MyForm
    527. //
    528. this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
    529. this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    530. this->ClientSize = System::Drawing::Size(779, 469);
    531. this->Controls->Add(this->numericUpDownDauer);
    532. this->Controls->Add(this->numericUpDownWiederholungen);
    533. this->Controls->Add(this->buttonAnimation);
    534. this->Controls->Add(this->label7);
    535. this->Controls->Add(this->label6);
    536. this->Controls->Add(this->buttonBeenden);
    537. this->Controls->Add(this->buttonLoeschen);
    538. this->Controls->Add(this->buttonStart);
    539. this->Controls->Add(this->groesseTrackbar);
    540. this->Controls->Add(this->groupBox3);
    541. this->Controls->Add(this->groupBox2);
    542. this->Controls->Add(this->groupBox1);
    543. this->Controls->Add(this->anzeigePanel);
    544. this->Margin = System::Windows::Forms::Padding(4);
    545. this->MaximizeBox = false;
    546. this->MinimizeBox = false;
    547. this->Name = L"MyForm";
    548. this->Text = L"Eine Spielerei";
    549. this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
    550. this->groupBox2->ResumeLayout(false);
    551. this->groupBox2->PerformLayout();
    552. this->groupBox1->ResumeLayout(false);
    553. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDownLinieStaerke))->EndInit();
    554. this->groupBox3->ResumeLayout(false);
    555. this->groupBox3->PerformLayout();
    556. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->groesseTrackbar))->EndInit();
    557. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDownWiederholungen))->EndInit();
    558. (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDownDauer))->EndInit();
    559. this->ResumeLayout(false);
    560. this->PerformLayout();
    561. }
    562. #pragma endregion
    563. private: System::Void buttonBeenden_Click(System::Object^ sender, System::EventArgs^ e)
    564. {
    565. Close();
    566. }
    567. private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e)
    568. {
    569. startGroesse = 100;
    570. linienStaerke = 1;
    571. linienFarbe = Color::Black;
    572. hintergrundFarbe = Color::White;
    573. radioButtonKreis->Checked = true;
    574. //die Einträge für die Linienstile erzeugen
    575. for each (Drawing2D::DashStyle element in auswahlLinienstile)
    576. listBoxLinieStil->Items->Add("");
    577. listBoxLinieStil->SelectedIndex = 0;
    578. //und für die Hintergrundmuster
    579. for each (Drawing2D::HatchStyle element in auswahlFuellstile)
    580. listBoxHintergrundMuster->Items->Add("");
    581. listBoxHintergrundMuster->SelectedIndex = -1;
    582. }
    583. private: System::Void buttonLinieFarbe_Click(System::Object^ sender, System::EventArgs^ e)
    584. {
    585. colorDialog1->Color = panelLinieFarbeVorschau->BackColor;
    586. if (colorDialog1->ShowDialog() == Windows::Forms::DialogResult::OK)
    587. {
    588. panelLinieFarbeVorschau->BackColor = colorDialog1->Color;
    589. linienFarbe = colorDialog1->Color;
    590. InvalidateAnzeigePanel();
    591. }
    592. }
    593. private: System::Void panelLinieFarbeVorschau_DoubleClick(System::Object^ sender, System::EventArgs^ e)
    594. {
    595. buttonLinieFarbe_Click(sender, e);
    596. }
    597. private: System::Void buttonHintergrundFarbe_Click(System::Object^ sender, System::EventArgs^ e)
    598. {
    599. colorDialog1->Color = panelHintergrundFarbeVorschau->BackColor;
    600. if (colorDialog1->ShowDialog() == Windows::Forms::DialogResult::OK)
    601. {
    602. panelHintergrundFarbeVorschau->BackColor = colorDialog1->Color;
    603. hintergrundFarbe = colorDialog1->Color;
    604. if (radioButtonHintergrundOhne->Checked)
    605. {
    606. radioButtonHintergrundFarbe->Checked = true;
    607. }
    608. InvalidateAnzeigePanel();
    609. }
    610. }
    611. private: System::Void panelHintergrundFarbeVorschau_DoubleClick(System::Object^ sender, System::EventArgs^ e)
    612. {
    613. buttonHintergrundFarbe_Click(sender, e);
    614. }
    615. private: System::Void listBoxLinieStil_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
    616. {
    617. if (listBoxLinieStil->SelectedIndex >= 0)
    618. {
    619. linienStil = auswahlLinienstile[listBoxLinieStil->SelectedIndex];
    620. }
    621. else
    622. {
    623. linienStil = DashStyle::Solid;
    624. }
    625. InvalidateAnzeigePanel();
    626. }
    627. private: System::Void listBoxLinieStil_DrawItem(System::Object^ sender, System::Windows::Forms::DrawItemEventArgs^ e)
    628. {
    629. Int32 y = (e->Bounds.Top + e->Bounds.Bottom) / 2;
    630. e->DrawBackground();
    631. Pen ^boxStift = gcnew Pen(Color::Black);
    632. boxStift->DashStyle = auswahlLinienstile[e->Index];
    633. e->Graphics->DrawLine(boxStift, e->Bounds.Left + 1, y, e->Bounds.Right - 1, y);
    634. delete boxStift;
    635. }
    636. private: System::Void numericUpDownLinieStaerke_ValueChanged(System::Object^ sender, System::EventArgs^ e)
    637. {
    638. linienStaerke = (Int32)numericUpDownLinieStaerke->Value;
    639. InvalidateAnzeigePanel();
    640. }
    641. private: System::Void listBoxHintergrundMuster_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
    642. {
    643. if (listBoxHintergrundMuster->SelectedIndex >= 0)
    644. {
    645. fuellStil = auswahlFuellstile[listBoxHintergrundMuster->SelectedIndex];
    646. this->radioButtonHintergrundMuster->Checked = true;
    647. }
    648. else
    649. {
    650. this->radioButtonHintergrundOhne->Checked = true;
    651. fuellStil = auswahlFuellstile[0];
    652. }
    653. InvalidateAnzeigePanel();
    654. }
    655. private: System::Void listBoxHintergrundMuster_DrawItem(System::Object^ sender, System::Windows::Forms::DrawItemEventArgs^ e)
    656. {
    657. e->DrawBackground();
    658. Drawing2D::HatchBrush ^boxPinsel = gcnew Drawing2D::HatchBrush(auswahlFuellstile[e->Index], Color::Black, Color::White);
    659. e->Graphics->FillRectangle(boxPinsel, e->Bounds.Left + 1, e->Bounds.Top + 1, e->Bounds.Width - 1, e->Bounds.Height - 1);
    660. delete boxPinsel;
    661. }
    662. private: System::Void hintergrund_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
    663. {
    664. InvalidateAnzeigePanel();
    665. }
    666. private: System::Void anzeigeFigur_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
    667. {
    668. if (radioButtonLinie->Checked)
    669. {
    670. figur = Figur::Linie;
    671. }
    672. else if (radioButtonRechteck->Checked)
    673. {
    674. figur = Figur::Rechteck;
    675. }
    676. else
    677. {
    678. figur = Figur::Kreis;
    679. }
    680. InvalidateAnzeigePanel();
    681. }
    682. private: System::Void groesseTrackbar_Scroll(System::Object^ sender, System::EventArgs^ e)
    683. {
    684. //die Größe der Figur ermitteln
    685. switch (groesseTrackbar->Value)
    686. {
    687. case 1:
    688. startGroesse = 125;
    689. break;
    690. case 2:
    691. startGroesse = 100;
    692. break;
    693. case 3:
    694. default:
    695. startGroesse = 75;
    696. break;
    697. }
    698. InvalidateAnzeigePanel();
    699. }
    700. private: System::Void numericUpDownDauer_ValueChanged(System::Object^ sender, System::EventArgs^ e)
    701. {
    702. animationInterval = (Int32)numericUpDownDauer->Value * 100;
    703. }
    704. private: System::Void numericUpDownWiederholungen_ValueChanged(System::Object^ sender, System::EventArgs^ e)
    705. {
    706. animationWiederholung = (Int32)numericUpDownWiederholungen->Value;
    707. }
    708. private: System::Void buttonLoeschen_Click(System::Object^ sender, System::EventArgs^ e)
    709. {
    710. //die Zeichenfläche löschen
    711. Graphics^ g = this->anzeigePanel->CreateGraphics();
    712. g->Clear(anzeigePanel->BackColor);
    713. delete g;
    714. }
    715. private: System::Void buttonStart_Click(System::Object^ sender, System::EventArgs^ e)
    716. {
    717. }
    718. private: System::Void buttonAnimation_Click(System::Object^ sender, System::EventArgs^ e)
    719. {
    720. animationInterval = (Int32)numericUpDownDauer->Value * 100;
    721. animationWiederholung = (Int32)numericUpDownWiederholungen->Value;
    722. animationAktiv = !animationAktiv;
    723. animationTimer->Interval = animationInterval;
    724. animationTimer->Enabled = animationAktiv;
    725. animationLauf = animationWiederholung;
    726. animationMinus = false;
    727. animationGroesse = startGroesse;
    728. this->anzeigePanel->Invalidate();
    729. }
    730. private: System::Void animationTimer_Tick(System::Object^ sender, System::EventArgs^ e)
    731. {
    732. Int32 minGroesse = startGroesse;
    733. Int32 maxGroesse = Math::Min(this->anzeigePanel->ClientSize.Width, this->anzeigePanel->ClientSize.Height);
    734. if (figur == Figur::Rechteck)
    735. {
    736. minGroesse = 0;
    737. maxGroesse /= 2;
    738. }
    739. if (animationMinus)
    740. {
    741. animationGroesse--;
    742. if (animationGroesse <= minGroesse)
    743. {
    744. animationMinus = false;
    745. //Neuer Durchlauf?
    746. animationLauf--;
    747. if (animationLauf <= 0)
    748. {
    749. animationAktiv = false;
    750. animationTimer->Enabled = false;
    751. }
    752. }
    753. }
    754. else
    755. {
    756. animationGroesse++;
    757. if (animationGroesse >= maxGroesse)
    758. {
    759. animationMinus = true;
    760. }
    761. }
    762. System::Diagnostics::Debug::WriteLine("Animation: {0} / {1}", animationGroesse, animationMinus);
    763. this->anzeigePanel->Invalidate();
    764. }
    765. private: System::Void InvalidateAnzeigePanel()
    766. {
    767. if (!animationAktiv)
    768. {
    769. this->anzeigePanel->Invalidate();
    770. }
    771. }
    772. private: System::Void anzeigePanel_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e)
    773. {
    774. Graphics^ zeichenflaeche = e->Graphics;
    775. zeichenflaeche->SmoothingMode = SmoothingMode::AntiAlias;
    776. Pen^ stift = gcnew Pen(linienFarbe);
    777. SolidBrush^ pinsel = gcnew SolidBrush(hintergrundFarbe);
    778. stift->Width = linienStaerke;
    779. stift->DashStyle = linienStil;
    780. // Zeichenrechteck bestimmen, Vorschau fix / Animation fliessend
    781. Int32 offset = startGroesse;
    782. if (animationAktiv)
    783. {
    784. offset = animationGroesse;
    785. }
    786. Rectangle zeichenRectangle = Rectangle::Inflate(anzeigePanel->ClientRectangle, -offset, -offset);
    787. System::Diagnostics::Debug::WriteLine("Größe: {0}", zeichenRectangle);
    788. // Figur zeichnen
    789. switch (figur)
    790. {
    791. case Figur::Kreis:
    792. default:
    793. if (radioButtonHintergrundFarbe->Checked)
    794. {
    795. zeichenflaeche->FillEllipse(pinsel, zeichenRectangle);
    796. }
    797. else if (radioButtonHintergrundMuster->Checked)
    798. {
    799. Drawing2D::HatchBrush ^musterPinsel = gcnew Drawing2D::HatchBrush(fuellStil, linienFarbe, hintergrundFarbe);
    800. zeichenflaeche->FillEllipse(musterPinsel, zeichenRectangle);
    801. delete musterPinsel;
    802. }
    803. zeichenflaeche->DrawEllipse(stift, zeichenRectangle);
    804. break;
    805. case Figur::Rechteck:
    806. if (radioButtonHintergrundFarbe->Checked)
    807. {
    808. zeichenflaeche->FillRectangle(pinsel, zeichenRectangle);
    809. }
    810. else if (radioButtonHintergrundMuster->Checked)
    811. {
    812. Drawing2D::HatchBrush ^musterPinsel = gcnew Drawing2D::HatchBrush(fuellStil, linienFarbe, hintergrundFarbe);
    813. zeichenflaeche->FillRectangle(musterPinsel, zeichenRectangle);
    814. delete musterPinsel;
    815. }
    816. zeichenflaeche->DrawRectangle(stift, zeichenRectangle);
    817. break;
    818. case Figur::Linie:
    819. Int32 center = (zeichenRectangle.Top + zeichenRectangle.Bottom - linienStaerke) / 2;
    820. zeichenflaeche->DrawLine(stift,
    821. Point(zeichenRectangle.Left, center),
    822. Point(zeichenRectangle.Right, center));
    823. break;
    824. }
    825. //Stift und Pinsel löschen
    826. delete stift;
    827. delete pinsel;
    828. }
    829. };
    830. }


    Codetags und Spoiler eingefügt. ~Trade
    Bilder
    • screenshot.jpg

      91,27 kB, 732×515, 87 mal angesehen

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Trade“ ()

    @BigBrain Willkommen im Forum. :thumbup:
    Sinnvoll ist es, diesen CLI-Code zunächst nach C# zu übersetzen und dann im nächsten Schritt nach VB.NET.
    Der erste Schritt (C++ => C#) geht intuitiv, der zweite über einen Automaten.
    Foem

    C#-Quellcode

    1. using System;
    2. using System.Drawing;
    3. using System.Drawing.Drawing2D;
    4. using System.Windows.Forms;
    5. namespace WindowsFormsApplication1
    6. {
    7. public partial class Form1 : Form
    8. {
    9. enum Figur : int
    10. {
    11. Kreis,
    12. Rechteck,
    13. Linie
    14. }
    15. Figur figur;
    16. Int32 linienStaerke;
    17. Color linienFarbe;
    18. Color hintergrundFarbe;
    19. DashStyle linienStil;
    20. HatchStyle fuellStil;
    21. Int32 startGroesse;
    22. Int32 animationWiederholung;
    23. Int32 animationInterval;
    24. Boolean animationAktiv;
    25. Int32 animationLauf;
    26. Boolean animationMinus;
    27. Int32 animationGroesse;
    28. /*
    29. Die Vereinbarung muss als static erfolgen.
    30. Andernfalls kann man dem Array keine Werte zuweisen.
    31. */
    32. //für die Linienstile
    33. static DashStyle[] auswahlLinienstile = {
    34. DashStyle.Solid,
    35. DashStyle.Dash,
    36. DashStyle.DashDot,
    37. DashStyle.DashDotDot,
    38. DashStyle.Dot};
    39. //für die Hintergrundmuster
    40. static HatchStyle[] auswahlFuellstile = {
    41. HatchStyle.BackwardDiagonal,
    42. HatchStyle.Cross,
    43. HatchStyle.DottedGrid,
    44. HatchStyle.ForwardDiagonal,
    45. HatchStyle.Sphere,
    46. HatchStyle.Vertical,
    47. HatchStyle.Wave,
    48. HatchStyle.ZigZag };
    49. public Form1()
    50. {
    51. InitializeComponent();
    52. figur = Figur.Kreis;
    53. }
    54. private void buttonBeenden_Click(System.Object sender, System.EventArgs e)
    55. {
    56. Close();
    57. }
    58. private void MyForm_Load(System.Object sender, System.EventArgs e)
    59. {
    60. startGroesse = 100;
    61. linienStaerke = 1;
    62. linienFarbe = Color.Black;
    63. hintergrundFarbe = Color.White;
    64. radioButtonKreis.Checked = true;
    65. //die Einträge für die Linienstile erzeugen
    66. foreach (DashStyle element in auswahlLinienstile)
    67. listBoxLinieStil.Items.Add("");
    68. listBoxLinieStil.SelectedIndex = 0;
    69. //und für die Hintergrundmuster
    70. foreach (HatchStyle element in auswahlFuellstile)
    71. listBoxHintergrundMuster.Items.Add("");
    72. listBoxHintergrundMuster.SelectedIndex = -1;
    73. }
    74. private void buttonLinieFarbe_Click(System.Object sender, System.EventArgs e)
    75. {
    76. colorDialog1.Color = panelLinieFarbeVorschau.BackColor;
    77. if (colorDialog1.ShowDialog() == DialogResult.OK)
    78. {
    79. panelLinieFarbeVorschau.BackColor = colorDialog1.Color;
    80. linienFarbe = colorDialog1.Color;
    81. InvalidateAnzeigePanel();
    82. }
    83. }
    84. private void panelLinieFarbeVorschau_DoubleClick(System.Object sender, System.EventArgs e)
    85. {
    86. buttonLinieFarbe_Click(sender, e);
    87. }
    88. private void buttonHintergrundFarbe_Click(System.Object sender, System.EventArgs e)
    89. {
    90. colorDialog1.Color = panelHintergrundFarbeVorschau.BackColor;
    91. if (colorDialog1.ShowDialog() == DialogResult.OK)
    92. {
    93. panelHintergrundFarbeVorschau.BackColor = colorDialog1.Color;
    94. hintergrundFarbe = colorDialog1.Color;
    95. if (radioButtonHintergrundOhne.Checked)
    96. {
    97. radioButtonHintergrundFarbe.Checked = true;
    98. }
    99. InvalidateAnzeigePanel();
    100. }
    101. }
    102. private void panelHintergrundFarbeVorschau_DoubleClick(System.Object sender, System.EventArgs e)
    103. {
    104. buttonHintergrundFarbe_Click(sender, e);
    105. }
    106. private void listBoxLinieStil_SelectedIndexChanged(System.Object sender, System.EventArgs e)
    107. {
    108. if (listBoxLinieStil.SelectedIndex >= 0)
    109. {
    110. linienStil = auswahlLinienstile[listBoxLinieStil.SelectedIndex];
    111. }
    112. else
    113. {
    114. linienStil = DashStyle.Solid;
    115. }
    116. InvalidateAnzeigePanel();
    117. }
    118. private void listBoxLinieStil_DrawItem(System.Object sender, DrawItemEventArgs e)
    119. {
    120. Int32 y = (e.Bounds.Top + e.Bounds.Bottom) / 2;
    121. e.DrawBackground();
    122. Pen boxStift = new Pen(Color.Black);
    123. boxStift.DashStyle = auswahlLinienstile[e.Index];
    124. e.Graphics.DrawLine(boxStift, e.Bounds.Left + 1, y, e.Bounds.Right - 1, y);
    125. boxStift.Dispose();
    126. }
    127. private void numericUpDownLinieStaerke_ValueChanged(System.Object sender, System.EventArgs e)
    128. {
    129. linienStaerke = (Int32)numericUpDownLinieStaerke.Value;
    130. InvalidateAnzeigePanel();
    131. }
    132. private void listBoxHintergrundMuster_SelectedIndexChanged(System.Object sender, System.EventArgs e)
    133. {
    134. if (listBoxHintergrundMuster.SelectedIndex >= 0)
    135. {
    136. fuellStil = auswahlFuellstile[listBoxHintergrundMuster.SelectedIndex];
    137. this.radioButtonHintergrundMuster.Checked = true;
    138. }
    139. else
    140. {
    141. this.radioButtonHintergrundOhne.Checked = true;
    142. fuellStil = auswahlFuellstile[0];
    143. }
    144. InvalidateAnzeigePanel();
    145. }
    146. private void listBoxHintergrundMuster_DrawItem(System.Object sender, DrawItemEventArgs e)
    147. {
    148. e.DrawBackground();
    149. HatchBrush boxPinsel = new HatchBrush(auswahlFuellstile[e.Index], Color.Black, Color.White);
    150. e.Graphics.FillRectangle(boxPinsel, e.Bounds.Left + 1, e.Bounds.Top + 1, e.Bounds.Width - 1, e.Bounds.Height - 1);
    151. boxPinsel.Dispose();
    152. }
    153. private void hintergrund_CheckedChanged(System.Object sender, System.EventArgs e)
    154. {
    155. InvalidateAnzeigePanel();
    156. }
    157. private void anzeigeFigur_CheckedChanged(System.Object sender, System.EventArgs e)
    158. {
    159. if (radioButtonLinie.Checked)
    160. {
    161. figur = Figur.Linie;
    162. }
    163. else if (radioButtonRechteck.Checked)
    164. {
    165. figur = Figur.Rechteck;
    166. }
    167. else
    168. {
    169. figur = Figur.Kreis;
    170. }
    171. InvalidateAnzeigePanel();
    172. }
    173. private void groesseTrackbar_Scroll(System.Object sender, System.EventArgs e)
    174. {
    175. //die Größe der Figur ermitteln
    176. switch (groesseTrackbar.Value)
    177. {
    178. case 1:
    179. startGroesse = 125;
    180. break;
    181. case 2:
    182. startGroesse = 100;
    183. break;
    184. case 3:
    185. default:
    186. startGroesse = 75;
    187. break;
    188. }
    189. InvalidateAnzeigePanel();
    190. }
    191. private void numericUpDownDauer_ValueChanged(System.Object sender, System.EventArgs e)
    192. {
    193. animationInterval = (Int32)numericUpDownDauer.Value * 100;
    194. }
    195. private void numericUpDownWiederholungen_ValueChanged(System.Object sender, System.EventArgs e)
    196. {
    197. animationWiederholung = (Int32)numericUpDownWiederholungen.Value;
    198. }
    199. private void buttonLoeschen_Click(System.Object sender, System.EventArgs e)
    200. {
    201. //die Zeichenfläche löschen
    202. Graphics g = this.anzeigePanel.CreateGraphics();
    203. g.Clear(anzeigePanel.BackColor);
    204. g.Dispose();
    205. }
    206. private void buttonStart_Click(System.Object sender, System.EventArgs e)
    207. {
    208. }
    209. private void buttonAnimation_Click(System.Object sender, System.EventArgs e)
    210. {
    211. animationInterval = (Int32)numericUpDownDauer.Value * 100;
    212. animationWiederholung = (Int32)numericUpDownWiederholungen.Value;
    213. animationAktiv = !animationAktiv;
    214. animationTimer.Interval = animationInterval;
    215. animationTimer.Enabled = animationAktiv;
    216. animationLauf = animationWiederholung;
    217. animationMinus = false;
    218. animationGroesse = startGroesse;
    219. this.anzeigePanel.Invalidate();
    220. }
    221. private void animationTimer_Tick(System.Object sender, System.EventArgs e)
    222. {
    223. Int32 minGroesse = startGroesse;
    224. Int32 maxGroesse = Math.Min(this.anzeigePanel.ClientSize.Width, this.anzeigePanel.ClientSize.Height);
    225. if (figur == Figur.Rechteck)
    226. {
    227. minGroesse = 0;
    228. maxGroesse /= 2;
    229. }
    230. if (animationMinus)
    231. {
    232. animationGroesse--;
    233. if (animationGroesse <= minGroesse)
    234. {
    235. animationMinus = false;
    236. //Neuer Durchlauf?
    237. animationLauf--;
    238. if (animationLauf <= 0)
    239. {
    240. animationAktiv = false;
    241. animationTimer.Enabled = false;
    242. }
    243. }
    244. }
    245. else
    246. {
    247. animationGroesse++;
    248. if (animationGroesse >= maxGroesse)
    249. {
    250. animationMinus = true;
    251. }
    252. }
    253. System.Diagnostics.Debug.WriteLine("Animation: {0} / {1}", animationGroesse, animationMinus);
    254. this.anzeigePanel.Invalidate();
    255. }
    256. private void InvalidateAnzeigePanel()
    257. {
    258. if (!animationAktiv)
    259. {
    260. this.anzeigePanel.Invalidate();
    261. }
    262. }
    263. private void anzeigePanel_Paint(System.Object sender, PaintEventArgs e)
    264. {
    265. Graphics zeichenflaeche = e.Graphics;
    266. zeichenflaeche.SmoothingMode = SmoothingMode.AntiAlias;
    267. Pen stift = new Pen(linienFarbe);
    268. SolidBrush pinsel = new SolidBrush(hintergrundFarbe);
    269. stift.Width = linienStaerke;
    270. stift.DashStyle = linienStil;
    271. // Zeichenrechteck bestimmen, Vorschau fix / Animation fliessend
    272. Int32 offset = startGroesse;
    273. if (animationAktiv)
    274. {
    275. offset = animationGroesse;
    276. }
    277. Rectangle zeichenRectangle = Rectangle.Inflate(anzeigePanel.ClientRectangle, -offset, -offset);
    278. System.Diagnostics.Debug.WriteLine("Größe: {0}", zeichenRectangle);
    279. // Figur zeichnen
    280. switch (figur)
    281. {
    282. case Figur.Kreis:
    283. default:
    284. if (radioButtonHintergrundFarbe.Checked)
    285. {
    286. zeichenflaeche.FillEllipse(pinsel, zeichenRectangle);
    287. }
    288. else if (radioButtonHintergrundMuster.Checked)
    289. {
    290. HatchBrush musterPinsel = new HatchBrush(fuellStil, linienFarbe, hintergrundFarbe);
    291. zeichenflaeche.FillEllipse(musterPinsel, zeichenRectangle);
    292. musterPinsel.Dispose();
    293. }
    294. zeichenflaeche.DrawEllipse(stift, zeichenRectangle);
    295. break;
    296. case Figur.Rechteck:
    297. if (radioButtonHintergrundFarbe.Checked)
    298. {
    299. zeichenflaeche.FillRectangle(pinsel, zeichenRectangle);
    300. }
    301. else if (radioButtonHintergrundMuster.Checked)
    302. {
    303. HatchBrush musterPinsel = new HatchBrush(fuellStil, linienFarbe, hintergrundFarbe);
    304. zeichenflaeche.FillRectangle(musterPinsel, zeichenRectangle);
    305. musterPinsel.Dispose();
    306. }
    307. zeichenflaeche.DrawRectangle(stift, zeichenRectangle);
    308. break;
    309. case Figur.Linie:
    310. Int32 center = (zeichenRectangle.Top + zeichenRectangle.Bottom - linienStaerke) / 2;
    311. zeichenflaeche.DrawLine(stift,
    312. new Point(zeichenRectangle.Left, center),
    313. new Point(zeichenRectangle.Right, center));
    314. break;
    315. }
    316. //Stift und Pinsel löschen
    317. stift.Dispose();
    318. pinsel.Dispose();
    319. }
    320. }
    321. }
    Designer

    Quellcode

    1. namespace WindowsFormsApplication1
    2. {
    3. partial class Form1
    4. {
    5. /// <summary>
    6. /// Erforderliche Designervariable.
    7. /// </summary>
    8. private System.ComponentModel.IContainer components = null;
    9. /// <summary>
    10. /// Verwendete Ressourcen bereinigen.
    11. /// </summary>
    12. /// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
    13. protected override void Dispose(bool disposing)
    14. {
    15. if (disposing && (components != null))
    16. {
    17. components.Dispose();
    18. }
    19. base.Dispose(disposing);
    20. }
    21. #region Vom Windows Form-Designer generierter Code
    22. /// <summary>
    23. /// Erforderliche Methode für die Designerunterstützung.
    24. /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
    25. /// </summary>
    26. private void InitializeComponent()
    27. {
    28. this.components = new System.ComponentModel.Container();
    29. this.anzeigePanel = new System.Windows.Forms.Panel();
    30. this.groupBox2 = new System.Windows.Forms.GroupBox();
    31. this.buttonHintergrundFarbe = new System.Windows.Forms.Button();
    32. this.panelHintergrundFarbeVorschau = new System.Windows.Forms.Panel();
    33. this.listBoxHintergrundMuster = new System.Windows.Forms.ListBox();
    34. this.label5 = new System.Windows.Forms.Label();
    35. this.label4 = new System.Windows.Forms.Label();
    36. this.radioButtonHintergrundMuster = new System.Windows.Forms.RadioButton();
    37. this.radioButtonHintergrundFarbe = new System.Windows.Forms.RadioButton();
    38. this.radioButtonHintergrundOhne = new System.Windows.Forms.RadioButton();
    39. this.groupBox1 = new System.Windows.Forms.GroupBox();
    40. this.buttonLinieFarbe = new System.Windows.Forms.Button();
    41. this.panelLinieFarbeVorschau = new System.Windows.Forms.Panel();
    42. this.label3 = new System.Windows.Forms.Label();
    43. this.listBoxLinieStil = new System.Windows.Forms.ListBox();
    44. this.numericUpDownLinieStaerke = new System.Windows.Forms.NumericUpDown();
    45. this.label2 = new System.Windows.Forms.Label();
    46. this.label1 = new System.Windows.Forms.Label();
    47. this.groupBox3 = new System.Windows.Forms.GroupBox();
    48. this.radioButtonLinie = new System.Windows.Forms.RadioButton();
    49. this.radioButtonKreis = new System.Windows.Forms.RadioButton();
    50. this.radioButtonRechteck = new System.Windows.Forms.RadioButton();
    51. this.groesseTrackbar = new System.Windows.Forms.TrackBar();
    52. this.buttonStart = new System.Windows.Forms.Button();
    53. this.buttonLoeschen = new System.Windows.Forms.Button();
    54. this.buttonBeenden = new System.Windows.Forms.Button();
    55. this.colorDialog1 = new System.Windows.Forms.ColorDialog();
    56. this.label6 = new System.Windows.Forms.Label();
    57. this.label7 = new System.Windows.Forms.Label();
    58. this.buttonAnimation = new System.Windows.Forms.Button();
    59. this.numericUpDownWiederholungen = new System.Windows.Forms.NumericUpDown();
    60. this.numericUpDownDauer = new System.Windows.Forms.NumericUpDown();
    61. this.animationTimer = new System.Windows.Forms.Timer(this.components);
    62. this.groupBox2.SuspendLayout();
    63. this.groupBox1.SuspendLayout();
    64. ((System.ComponentModel.ISupportInitialize)(this.numericUpDownLinieStaerke)).BeginInit();
    65. this.groupBox3.SuspendLayout();
    66. ((System.ComponentModel.ISupportInitialize)(this.groesseTrackbar)).BeginInit();
    67. ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWiederholungen)).BeginInit();
    68. ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDauer)).BeginInit();
    69. this.SuspendLayout();
    70. //
    71. // anzeigePanel
    72. //
    73. this.anzeigePanel.BackColor = System.Drawing.Color.White;
    74. this.anzeigePanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    75. this.anzeigePanel.Location = new System.Drawing.Point(12, 12);
    76. this.anzeigePanel.Name = "anzeigePanel";
    77. this.anzeigePanel.Size = new System.Drawing.Size(300, 300);
    78. this.anzeigePanel.TabIndex = 0;
    79. this.anzeigePanel.Paint += new System.Windows.Forms.PaintEventHandler(this.anzeigePanel_Paint);
    80. //
    81. // groupBox2
    82. //
    83. this.groupBox2.Controls.Add(this.buttonHintergrundFarbe);
    84. this.groupBox2.Controls.Add(this.panelHintergrundFarbeVorschau);
    85. this.groupBox2.Controls.Add(this.listBoxHintergrundMuster);
    86. this.groupBox2.Controls.Add(this.label5);
    87. this.groupBox2.Controls.Add(this.label4);
    88. this.groupBox2.Controls.Add(this.radioButtonHintergrundMuster);
    89. this.groupBox2.Controls.Add(this.radioButtonHintergrundFarbe);
    90. this.groupBox2.Controls.Add(this.radioButtonHintergrundOhne);
    91. this.groupBox2.Location = new System.Drawing.Point(327, 128);
    92. this.groupBox2.Name = "groupBox2";
    93. this.groupBox2.Size = new System.Drawing.Size(200, 108);
    94. this.groupBox2.TabIndex = 2;
    95. this.groupBox2.TabStop = false;
    96. this.groupBox2.Text = "Hintergrund";
    97. //
    98. // buttonHintergrundFarbe
    99. //
    100. this.buttonHintergrundFarbe.Location = new System.Drawing.Point(104, 42);
    101. this.buttonHintergrundFarbe.Name = "buttonHintergrundFarbe";
    102. this.buttonHintergrundFarbe.Size = new System.Drawing.Size(30, 23);
    103. this.buttonHintergrundFarbe.TabIndex = 7;
    104. this.buttonHintergrundFarbe.Text = "...";
    105. this.buttonHintergrundFarbe.UseVisualStyleBackColor = true;
    106. this.buttonHintergrundFarbe.Click += new System.EventHandler(this.buttonHintergrundFarbe_Click);
    107. //
    108. // panelHintergrundFarbeVorschau
    109. //
    110. this.panelHintergrundFarbeVorschau.BackColor = System.Drawing.Color.White;
    111. this.panelHintergrundFarbeVorschau.Location = new System.Drawing.Point(62, 40);
    112. this.panelHintergrundFarbeVorschau.Name = "panelHintergrundFarbeVorschau";
    113. this.panelHintergrundFarbeVorschau.Size = new System.Drawing.Size(27, 24);
    114. this.panelHintergrundFarbeVorschau.TabIndex = 8;
    115. this.panelHintergrundFarbeVorschau.DoubleClick += new System.EventHandler(this.panelHintergrundFarbeVorschau_DoubleClick);
    116. //
    117. // listBoxHintergrundMuster
    118. //
    119. this.listBoxHintergrundMuster.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
    120. this.listBoxHintergrundMuster.FormattingEnabled = true;
    121. this.listBoxHintergrundMuster.Location = new System.Drawing.Point(58, 69);
    122. this.listBoxHintergrundMuster.Name = "listBoxHintergrundMuster";
    123. this.listBoxHintergrundMuster.Size = new System.Drawing.Size(121, 17);
    124. this.listBoxHintergrundMuster.TabIndex = 4;
    125. this.listBoxHintergrundMuster.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.listBoxHintergrundMuster_DrawItem);
    126. this.listBoxHintergrundMuster.SelectedIndexChanged += new System.EventHandler(this.listBoxHintergrundMuster_SelectedIndexChanged);
    127. //
    128. // label5
    129. //
    130. this.label5.Location = new System.Drawing.Point(6, 69);
    131. this.label5.Name = "label5";
    132. this.label5.Size = new System.Drawing.Size(41, 21);
    133. this.label5.TabIndex = 5;
    134. this.label5.Text = "Stil:";
    135. //
    136. // label4
    137. //
    138. this.label4.Location = new System.Drawing.Point(6, 42);
    139. this.label4.Name = "label4";
    140. this.label4.Size = new System.Drawing.Size(41, 21);
    141. this.label4.TabIndex = 4;
    142. this.label4.Text = "Farbe:";
    143. //
    144. // radioButtonHintergrundMuster
    145. //
    146. this.radioButtonHintergrundMuster.AutoSize = true;
    147. this.radioButtonHintergrundMuster.Location = new System.Drawing.Point(124, 19);
    148. this.radioButtonHintergrundMuster.Name = "radioButtonHintergrundMuster";
    149. this.radioButtonHintergrundMuster.Size = new System.Drawing.Size(57, 17);
    150. this.radioButtonHintergrundMuster.TabIndex = 2;
    151. this.radioButtonHintergrundMuster.TabStop = true;
    152. this.radioButtonHintergrundMuster.Text = "Muster";
    153. this.radioButtonHintergrundMuster.UseVisualStyleBackColor = true;
    154. this.radioButtonHintergrundMuster.CheckedChanged += new System.EventHandler(this.hintergrund_CheckedChanged);
    155. //
    156. // radioButtonHintergrundFarbe
    157. //
    158. this.radioButtonHintergrundFarbe.AutoSize = true;
    159. this.radioButtonHintergrundFarbe.Location = new System.Drawing.Point(67, 19);
    160. this.radioButtonHintergrundFarbe.Name = "radioButtonHintergrundFarbe";
    161. this.radioButtonHintergrundFarbe.Size = new System.Drawing.Size(52, 17);
    162. this.radioButtonHintergrundFarbe.TabIndex = 1;
    163. this.radioButtonHintergrundFarbe.TabStop = true;
    164. this.radioButtonHintergrundFarbe.Text = "Farbe";
    165. this.radioButtonHintergrundFarbe.UseVisualStyleBackColor = true;
    166. this.radioButtonHintergrundFarbe.CheckedChanged += new System.EventHandler(this.hintergrund_CheckedChanged);
    167. //
    168. // radioButtonHintergrundOhne
    169. //
    170. this.radioButtonHintergrundOhne.AutoSize = true;
    171. this.radioButtonHintergrundOhne.Checked = true;
    172. this.radioButtonHintergrundOhne.Location = new System.Drawing.Point(9, 19);
    173. this.radioButtonHintergrundOhne.Name = "radioButtonHintergrundOhne";
    174. this.radioButtonHintergrundOhne.Size = new System.Drawing.Size(49, 17);
    175. this.radioButtonHintergrundOhne.TabIndex = 0;
    176. this.radioButtonHintergrundOhne.TabStop = true;
    177. this.radioButtonHintergrundOhne.Text = "ohne";
    178. this.radioButtonHintergrundOhne.UseVisualStyleBackColor = true;
    179. this.radioButtonHintergrundOhne.CheckedChanged += new System.EventHandler(this.hintergrund_CheckedChanged);
    180. //
    181. // groupBox1
    182. //
    183. this.groupBox1.Controls.Add(this.buttonLinieFarbe);
    184. this.groupBox1.Controls.Add(this.panelLinieFarbeVorschau);
    185. this.groupBox1.Controls.Add(this.label3);
    186. this.groupBox1.Controls.Add(this.listBoxLinieStil);
    187. this.groupBox1.Controls.Add(this.numericUpDownLinieStaerke);
    188. this.groupBox1.Controls.Add(this.label2);
    189. this.groupBox1.Controls.Add(this.label1);
    190. this.groupBox1.Location = new System.Drawing.Point(327, 12);
    191. this.groupBox1.Name = "groupBox1";
    192. this.groupBox1.Size = new System.Drawing.Size(200, 110);
    193. this.groupBox1.TabIndex = 1;
    194. this.groupBox1.TabStop = false;
    195. this.groupBox1.Text = "Linie";
    196. //
    197. // buttonLinieFarbe
    198. //
    199. this.buttonLinieFarbe.Location = new System.Drawing.Point(104, 17);
    200. this.buttonLinieFarbe.Name = "buttonLinieFarbe";
    201. this.buttonLinieFarbe.Size = new System.Drawing.Size(30, 23);
    202. this.buttonLinieFarbe.TabIndex = 0;
    203. this.buttonLinieFarbe.Text = "...";
    204. this.buttonLinieFarbe.UseVisualStyleBackColor = true;
    205. this.buttonLinieFarbe.Click += new System.EventHandler(this.buttonLinieFarbe_Click);
    206. //
    207. // panelLinieFarbeVorschau
    208. //
    209. this.panelLinieFarbeVorschau.BackColor = System.Drawing.Color.Black;
    210. this.panelLinieFarbeVorschau.Location = new System.Drawing.Point(62, 15);
    211. this.panelLinieFarbeVorschau.Name = "panelLinieFarbeVorschau";
    212. this.panelLinieFarbeVorschau.Size = new System.Drawing.Size(27, 24);
    213. this.panelLinieFarbeVorschau.TabIndex = 6;
    214. this.panelLinieFarbeVorschau.DoubleClick += new System.EventHandler(this.panelLinieFarbeVorschau_DoubleClick);
    215. //
    216. // label3
    217. //
    218. this.label3.Location = new System.Drawing.Point(6, 81);
    219. this.label3.Name = "label3";
    220. this.label3.Size = new System.Drawing.Size(41, 21);
    221. this.label3.TabIndex = 5;
    222. this.label3.Text = "Stärke:";
    223. //
    224. // listBoxLinieStil
    225. //
    226. this.listBoxLinieStil.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
    227. this.listBoxLinieStil.FormattingEnabled = true;
    228. this.listBoxLinieStil.Location = new System.Drawing.Point(58, 46);
    229. this.listBoxLinieStil.Name = "listBoxLinieStil";
    230. this.listBoxLinieStil.Size = new System.Drawing.Size(121, 17);
    231. this.listBoxLinieStil.TabIndex = 4;
    232. this.listBoxLinieStil.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.listBoxLinieStil_DrawItem);
    233. this.listBoxLinieStil.SelectedIndexChanged += new System.EventHandler(this.listBoxLinieStil_SelectedIndexChanged);
    234. //
    235. // numericUpDownLinieStaerke
    236. //
    237. this.numericUpDownLinieStaerke.Location = new System.Drawing.Point(58, 82);
    238. this.numericUpDownLinieStaerke.Maximum = new decimal(new int[] {
    239. 20,
    240. 0,
    241. 0,
    242. 0});
    243. this.numericUpDownLinieStaerke.Minimum = new decimal(new int[] {
    244. 1,
    245. 0,
    246. 0,
    247. 0});
    248. this.numericUpDownLinieStaerke.Name = "numericUpDownLinieStaerke";
    249. this.numericUpDownLinieStaerke.Size = new System.Drawing.Size(121, 20);
    250. this.numericUpDownLinieStaerke.TabIndex = 5;
    251. this.numericUpDownLinieStaerke.Value = new decimal(new int[] {
    252. 1,
    253. 0,
    254. 0,
    255. 0});
    256. this.numericUpDownLinieStaerke.ValueChanged += new System.EventHandler(this.numericUpDownLinieStaerke_ValueChanged);
    257. //
    258. // label2
    259. //
    260. this.label2.Location = new System.Drawing.Point(6, 46);
    261. this.label2.Name = "label2";
    262. this.label2.Size = new System.Drawing.Size(24, 21);
    263. this.label2.TabIndex = 4;
    264. this.label2.Text = "Stil:";
    265. //
    266. // label1
    267. //
    268. this.label1.Location = new System.Drawing.Point(6, 19);
    269. this.label1.Name = "label1";
    270. this.label1.Size = new System.Drawing.Size(37, 21);
    271. this.label1.TabIndex = 3;
    272. this.label1.Text = "Farbe:";
    273. //
    274. // groupBox3
    275. //
    276. this.groupBox3.Controls.Add(this.radioButtonLinie);
    277. this.groupBox3.Controls.Add(this.radioButtonKreis);
    278. this.groupBox3.Controls.Add(this.radioButtonRechteck);
    279. this.groupBox3.Location = new System.Drawing.Point(327, 242);
    280. this.groupBox3.Name = "groupBox3";
    281. this.groupBox3.Size = new System.Drawing.Size(200, 49);
    282. this.groupBox3.TabIndex = 3;
    283. this.groupBox3.TabStop = false;
    284. this.groupBox3.Text = "Figur";
    285. //
    286. // radioButtonLinie
    287. //
    288. this.radioButtonLinie.AutoSize = true;
    289. this.radioButtonLinie.Location = new System.Drawing.Point(135, 19);
    290. this.radioButtonLinie.Name = "radioButtonLinie";
    291. this.radioButtonLinie.Size = new System.Drawing.Size(47, 17);
    292. this.radioButtonLinie.TabIndex = 6;
    293. this.radioButtonLinie.TabStop = true;
    294. this.radioButtonLinie.Text = "Linie";
    295. this.radioButtonLinie.UseVisualStyleBackColor = true;
    296. this.radioButtonLinie.CheckedChanged += new System.EventHandler(this.anzeigeFigur_CheckedChanged);
    297. //
    298. // radioButtonKreis
    299. //
    300. this.radioButtonKreis.AutoSize = true;
    301. this.radioButtonKreis.Checked = true;
    302. this.radioButtonKreis.Location = new System.Drawing.Point(9, 19);
    303. this.radioButtonKreis.Name = "radioButtonKreis";
    304. this.radioButtonKreis.Size = new System.Drawing.Size(48, 17);
    305. this.radioButtonKreis.TabIndex = 4;
    306. this.radioButtonKreis.TabStop = true;
    307. this.radioButtonKreis.Text = "Kreis";
    308. this.radioButtonKreis.UseVisualStyleBackColor = true;
    309. this.radioButtonKreis.CheckedChanged += new System.EventHandler(this.anzeigeFigur_CheckedChanged);
    310. //
    311. // radioButtonRechteck
    312. //
    313. this.radioButtonRechteck.AutoSize = true;
    314. this.radioButtonRechteck.Location = new System.Drawing.Point(62, 19);
    315. this.radioButtonRechteck.Name = "radioButtonRechteck";
    316. this.radioButtonRechteck.Size = new System.Drawing.Size(72, 17);
    317. this.radioButtonRechteck.TabIndex = 5;
    318. this.radioButtonRechteck.TabStop = true;
    319. this.radioButtonRechteck.Text = "Rechteck";
    320. this.radioButtonRechteck.UseVisualStyleBackColor = true;
    321. this.radioButtonRechteck.CheckedChanged += new System.EventHandler(this.anzeigeFigur_CheckedChanged);
    322. //
    323. // groesseTrackbar
    324. //
    325. this.groesseTrackbar.LargeChange = 1;
    326. this.groesseTrackbar.Location = new System.Drawing.Point(327, 297);
    327. this.groesseTrackbar.Maximum = 3;
    328. this.groesseTrackbar.Minimum = 1;
    329. this.groesseTrackbar.Name = "groesseTrackbar";
    330. this.groesseTrackbar.Size = new System.Drawing.Size(200, 45);
    331. this.groesseTrackbar.TabIndex = 4;
    332. this.groesseTrackbar.Value = 2;
    333. this.groesseTrackbar.Scroll += new System.EventHandler(this.groesseTrackbar_Scroll);
    334. //
    335. // buttonStart
    336. //
    337. this.buttonStart.Location = new System.Drawing.Point(327, 346);
    338. this.buttonStart.Name = "buttonStart";
    339. this.buttonStart.Size = new System.Drawing.Size(75, 23);
    340. this.buttonStart.TabIndex = 5;
    341. this.buttonStart.Text = "Los geht\'s";
    342. this.buttonStart.UseVisualStyleBackColor = true;
    343. this.buttonStart.Click += new System.EventHandler(this.buttonStart_Click);
    344. //
    345. // buttonLoeschen
    346. //
    347. this.buttonLoeschen.Location = new System.Drawing.Point(408, 346);
    348. this.buttonLoeschen.Name = "buttonLoeschen";
    349. this.buttonLoeschen.Size = new System.Drawing.Size(75, 23);
    350. this.buttonLoeschen.TabIndex = 6;
    351. this.buttonLoeschen.Text = "Löschen";
    352. this.buttonLoeschen.UseVisualStyleBackColor = true;
    353. this.buttonLoeschen.Click += new System.EventHandler(this.buttonLoeschen_Click);
    354. //
    355. // buttonBeenden
    356. //
    357. this.buttonBeenden.Location = new System.Drawing.Point(489, 346);
    358. this.buttonBeenden.Name = "buttonBeenden";
    359. this.buttonBeenden.Size = new System.Drawing.Size(75, 23);
    360. this.buttonBeenden.TabIndex = 7;
    361. this.buttonBeenden.Text = "Beenden";
    362. this.buttonBeenden.UseVisualStyleBackColor = true;
    363. this.buttonBeenden.Click += new System.EventHandler(this.buttonBeenden_Click);
    364. //
    365. // label6
    366. //
    367. this.label6.Location = new System.Drawing.Point(9, 327);
    368. this.label6.Name = "label6";
    369. this.label6.Size = new System.Drawing.Size(88, 20);
    370. this.label6.TabIndex = 8;
    371. this.label6.Text = "Wiederholungen:";
    372. //
    373. // label7
    374. //
    375. this.label7.Location = new System.Drawing.Point(9, 353);
    376. this.label7.Name = "label7";
    377. this.label7.Size = new System.Drawing.Size(88, 20);
    378. this.label7.TabIndex = 9;
    379. this.label7.Text = "Dauer:";
    380. //
    381. // buttonAnimation
    382. //
    383. this.buttonAnimation.Location = new System.Drawing.Point(170, 346);
    384. this.buttonAnimation.Name = "buttonAnimation";
    385. this.buttonAnimation.Size = new System.Drawing.Size(75, 23);
    386. this.buttonAnimation.TabIndex = 10;
    387. this.buttonAnimation.Text = "Animation";
    388. this.buttonAnimation.UseVisualStyleBackColor = true;
    389. this.buttonAnimation.Click += new System.EventHandler(this.buttonAnimation_Click);
    390. //
    391. // numericUpDownWiederholungen
    392. //
    393. this.numericUpDownWiederholungen.Location = new System.Drawing.Point(103, 327);
    394. this.numericUpDownWiederholungen.Maximum = new decimal(new int[] {
    395. 10,
    396. 0,
    397. 0,
    398. 0});
    399. this.numericUpDownWiederholungen.Minimum = new decimal(new int[] {
    400. 1,
    401. 0,
    402. 0,
    403. 0});
    404. this.numericUpDownWiederholungen.Name = "numericUpDownWiederholungen";
    405. this.numericUpDownWiederholungen.Size = new System.Drawing.Size(47, 20);
    406. this.numericUpDownWiederholungen.TabIndex = 11;
    407. this.numericUpDownWiederholungen.Value = new decimal(new int[] {
    408. 1,
    409. 0,
    410. 0,
    411. 0});
    412. this.numericUpDownWiederholungen.ValueChanged += new System.EventHandler(this.numericUpDownWiederholungen_ValueChanged);
    413. //
    414. // numericUpDownDauer
    415. //
    416. this.numericUpDownDauer.Location = new System.Drawing.Point(103, 353);
    417. this.numericUpDownDauer.Maximum = new decimal(new int[] {
    418. 15,
    419. 0,
    420. 0,
    421. 0});
    422. this.numericUpDownDauer.Minimum = new decimal(new int[] {
    423. 1,
    424. 0,
    425. 0,
    426. 0});
    427. this.numericUpDownDauer.Name = "numericUpDownDauer";
    428. this.numericUpDownDauer.Size = new System.Drawing.Size(47, 20);
    429. this.numericUpDownDauer.TabIndex = 12;
    430. this.numericUpDownDauer.Value = new decimal(new int[] {
    431. 1,
    432. 0,
    433. 0,
    434. 0});
    435. this.numericUpDownDauer.ValueChanged += new System.EventHandler(this.numericUpDownDauer_ValueChanged);
    436. //
    437. // animationTimer
    438. //
    439. this.animationTimer.Tick += new System.EventHandler(this.animationTimer_Tick);
    440. //
    441. // Form1
    442. //
    443. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    444. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    445. this.ClientSize = new System.Drawing.Size(584, 381);
    446. this.Controls.Add(this.numericUpDownDauer);
    447. this.Controls.Add(this.numericUpDownWiederholungen);
    448. this.Controls.Add(this.buttonAnimation);
    449. this.Controls.Add(this.label7);
    450. this.Controls.Add(this.label6);
    451. this.Controls.Add(this.buttonBeenden);
    452. this.Controls.Add(this.buttonLoeschen);
    453. this.Controls.Add(this.buttonStart);
    454. this.Controls.Add(this.groesseTrackbar);
    455. this.Controls.Add(this.groupBox3);
    456. this.Controls.Add(this.groupBox2);
    457. this.Controls.Add(this.groupBox1);
    458. this.Controls.Add(this.anzeigePanel);
    459. this.MaximizeBox = false;
    460. this.MinimizeBox = false;
    461. this.Name = "Form1";
    462. this.Text = "Eine Spielerei";
    463. this.Load += new System.EventHandler(this.MyForm_Load);
    464. this.groupBox2.ResumeLayout(false);
    465. this.groupBox2.PerformLayout();
    466. this.groupBox1.ResumeLayout(false);
    467. ((System.ComponentModel.ISupportInitialize)(this.numericUpDownLinieStaerke)).EndInit();
    468. this.groupBox3.ResumeLayout(false);
    469. this.groupBox3.PerformLayout();
    470. ((System.ComponentModel.ISupportInitialize)(this.groesseTrackbar)).EndInit();
    471. ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWiederholungen)).EndInit();
    472. ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDauer)).EndInit();
    473. this.ResumeLayout(false);
    474. this.PerformLayout();
    475. }
    476. #endregion
    477. private System.Windows.Forms.Panel anzeigePanel;
    478. private System.Windows.Forms.GroupBox groupBox2;
    479. private System.Windows.Forms.GroupBox groupBox1;
    480. private System.Windows.Forms.Label label3;
    481. private System.Windows.Forms.Label label2;
    482. private System.Windows.Forms.ListBox listBoxLinieStil;
    483. private System.Windows.Forms.Label label1;
    484. private System.Windows.Forms.NumericUpDown numericUpDownLinieStaerke;
    485. private System.Windows.Forms.RadioButton radioButtonHintergrundMuster;
    486. private System.Windows.Forms.RadioButton radioButtonHintergrundFarbe;
    487. private System.Windows.Forms.RadioButton radioButtonHintergrundOhne;
    488. private System.Windows.Forms.ListBox listBoxHintergrundMuster;
    489. private System.Windows.Forms.Label label5;
    490. private System.Windows.Forms.Label label4;
    491. private System.Windows.Forms.GroupBox groupBox3;
    492. private System.Windows.Forms.RadioButton radioButtonLinie;
    493. private System.Windows.Forms.RadioButton radioButtonKreis;
    494. private System.Windows.Forms.RadioButton radioButtonRechteck;
    495. private System.Windows.Forms.TrackBar groesseTrackbar;
    496. private System.Windows.Forms.Button buttonStart;
    497. private System.Windows.Forms.Button buttonLoeschen;
    498. private System.Windows.Forms.Button buttonBeenden;
    499. private System.Windows.Forms.Button buttonLinieFarbe;
    500. private System.Windows.Forms.Panel panelLinieFarbeVorschau;
    501. private System.Windows.Forms.ColorDialog colorDialog1;
    502. private System.Windows.Forms.Button buttonHintergrundFarbe;
    503. private System.Windows.Forms.Panel panelHintergrundFarbeVorschau;
    504. private System.Windows.Forms.Label label6;
    505. private System.Windows.Forms.Label label7;
    506. private System.Windows.Forms.Button buttonAnimation;
    507. private System.Windows.Forms.NumericUpDown numericUpDownWiederholungen;
    508. private System.Windows.Forms.NumericUpDown numericUpDownDauer;
    509. private System.Windows.Forms.Timer animationTimer;
    510. }
    511. }

    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „RodFromGermany“ ()

    @BigBrain Die GUI bzw. den Designer-Code kannst Du konvertieren, indem Du in der C#-Form alle Controls markierst und in eine leere VB-Form einfügst.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Hallo RodFromGermany,

    ich dachte ich habe einen guten Online-Konverter gefunden, doch demnach ist nicht so gewesen... ich habe via CodeTranslator den VB-Code in die Laufzeit eingebunden, aber ich bekomme weiterhin Fehler, undzwar mit "Figur"...den Designer hatte ich bereits händisch eingestellt, aber hier auch danke für dein Tipp...Nun, so sieht aktuell mein Code aus...Danke vorab für deine Hilfe ;)


    Spoiler anzeigen

    VB.NET-Quellcode

    1. Imports System
    2. Imports
    3. System.Drawing
    4. Imports System.Drawing.Drawing2D
    5. Imports
    6. System.Windows.Forms
    7. Namespace WindowsFormsApplication1
    8. Public Class Form1
    9. Inherits Form
    10. Enum Figur
    11. Kreis
    12. Rechteck
    13. Linie
    14. End Enum
    15. Private linienStaerke As Int32
    16. Private linienFarbe As Color
    17. Private hintergrundFarbe As
    18. Color
    19. Private linienStil As DashStyle
    20. Private fuellStil As HatchStyle
    21. Private startGroesse As Int32
    22. Private animationWiederholung
    23. As Int32
    24. Private animationInterval As
    25. Int32
    26. Private animationAktiv As
    27. Boolean
    28. Private animationLauf As Int32
    29. Private animationMinus As
    30. Boolean
    31. Private animationGroesse As
    32. Int32
    33. 'für die Linienstile
    34. Private Shared ReadOnly
    35. auswahlLinienstile() As DashStyle
    36. Private Shared ReadOnly Dash()
    37. As DashStyle
    38. Private Shared DashDot() As
    39. DashStyle
    40. Private Shared DashDotDot() As
    41. DashStyle
    42. Private Shared Dot() As
    43. DashStyle
    44. 'für die Hintergrundmuster
    45. Private Shared ReadOnly
    46. auswahlFuellstile() As HatchStyle
    47. 'Private Shared
    48. HatchStyle.Cross() As HatchStyle
    49. Private Shared DottedGrid() As
    50. HatchStyle
    51. Private Shared
    52. ForwardDiagonal() As HatchStyle
    53. Private Shared Sphere() As
    54. HatchStyle
    55. Private Shared Vertical() As
    56. HatchStyle
    57. Private Shared Wave() As
    58. HatchStyle
    59. Private Shared ZigZag() As
    60. HatchStyle
    61. Public Sub New()
    62. MyBase.New
    63. Dim figur As Figur
    64. InitializeComponent()
    65. figur = Figur.Kreis
    66. End Sub
    67. Private Sub
    68. buttonBeenden_Click(ByVal sender As Object, ByVal e As
    69. System.EventArgs)
    70. Close()
    71. End Sub
    72. Private Sub MyForm_Load(ByVal
    73. sender As Object, ByVal e As System.EventArgs)
    74. Me.startGroesse = 100
    75. Me.linienStaerke = 1
    76. Me.linienFarbe = Color.Black
    77. Me.hintergrundFarbe =
    78. Color.White
    79. radioButtonKreis.Checked = True
    80. 'die Einträge für die Linienstile erzeugen
    81. For
    82. Each element As DashStyle In auswahlLinienstile
    83. listBoxLinieStil.Items.Add("")
    84. Next
    85. listBoxLinieStil.SelectedIndex = 0
    86. 'und für die
    87. Hintergrundmuster
    88. For Each element As HatchStyle In
    89. auswahlFuellstile
    90. listBoxHintergrundMuster.Items.Add("")
    91. Next
    92. listBoxHintergrundMuster.SelectedIndex = -1
    93. End
    94. Sub
    95. Private Sub
    96. buttonLinieFarbe_Click(ByVal sender As Object, ByVal e As
    97. System.EventArgs)
    98. colorDialog1.Color =
    99. panelLinieFarbeVorschau.BackColor
    100. If
    101. (colorDialog1.ShowDialog = DialogResult.OK) Then
    102. panelLinieFarbeVorschau.BackColor = colorDialog1.Color
    103. Me.linienFarbe = colorDialog1.Color
    104. Me.InvalidateAnzeigePanel()
    105. End If
    106. End Sub
    107. Private Sub
    108. panelLinieFarbeVorschau_DoubleClick(ByVal sender As Object, ByVal e
    109. As System.EventArgs)
    110. Me.buttonLinieFarbe_Click(sender,
    111. e)
    112. End Sub
    113. Private Sub
    114. buttonHintergrundFarbe_Click(ByVal sender As Object, ByVal e As
    115. System.EventArgs)
    116. colorDialog1.Color =
    117. panelHintergrundFarbeVorschau.BackColor
    118. If
    119. (colorDialog1.ShowDialog = DialogResult.OK) Then
    120. panelHintergrundFarbeVorschau.BackColor = colorDialog1.Color
    121. Me.hintergrundFarbe = colorDialog1.Color
    122. If radioButtonHintergrundOhne.Checked Then
    123. radioButtonHintergrundFarbe.Checked = True
    124. End If
    125. Me.InvalidateAnzeigePanel()
    126. End If
    127. End Sub
    128. Private Sub
    129. panelHintergrundFarbeVorschau_DoubleClick(ByVal sender As Object,
    130. ByVal e As System.EventArgs)
    131. Me.buttonHintergrundFarbe_Click(sender, e)
    132. End Sub
    133. Private Sub
    134. listBoxLinieStil_SelectedIndexChanged(ByVal sender As Object, ByVal e
    135. As System.EventArgs)
    136. If
    137. (listBoxLinieStil.SelectedIndex >= 0) Then
    138. Me.linienStil = auswahlLinienstile(listBoxLinieStil.SelectedIndex)
    139. Else
    140. Me.linienStil = DashStyle.Solid
    141. End If
    142. Me.InvalidateAnzeigePanel()
    143. End Sub
    144. Private Sub
    145. listBoxLinieStil_DrawItem(ByVal sender As Object, ByVal e As
    146. DrawItemEventArgs)
    147. Dim y As Int32 =
    148. CInt(((e.Bounds.Top + e.Bounds.Bottom) / 2))
    149. e.DrawBackground()
    150. Dim boxStift As Pen = New
    151. Pen(Color.Black)
    152. boxStift.DashStyle =
    153. auswahlLinienstile(e.Index)
    154. e.Graphics.DrawLine(boxStift, (e.Bounds.Left + 1), y, (e.Bounds.Right
    155. - 1), y)
    156. boxStift.Dispose()
    157. End Sub
    158. Private Sub
    159. numericUpDownLinieStaerke_ValueChanged(ByVal sender As Object, ByVal
    160. e As System.EventArgs)
    161. Me.linienStaerke =
    162. CType(numericUpDownLinieStaerke.Value, Int32)
    163. Me.InvalidateAnzeigePanel()
    164. End Sub
    165. Private Sub
    166. listBoxHintergrundMuster_SelectedIndexChanged(ByVal sender As Object,
    167. ByVal e As System.EventArgs)
    168. If
    169. (listBoxHintergrundMuster.SelectedIndex >= 0) Then
    170. Me.fuellStil =
    171. auswahlFuellstile(listBoxHintergrundMuster.SelectedIndex)
    172. Me.radioButtonHintergrundMuster.Checked = True
    173. Else
    174. Me.radioButtonHintergrundOhne.Checked = True
    175. Me.fuellStil = auswahlFuellstile(0)
    176. End
    177. If
    178. Me.InvalidateAnzeigePanel()
    179. End Sub
    180. Private Sub
    181. listBoxHintergrundMuster_DrawItem(ByVal sender As Object, ByVal e As
    182. DrawItemEventArgs)
    183. e.DrawBackground()
    184. Dim boxPinsel As HatchBrush = New
    185. HatchBrush(auswahlFuellstile(e.Index), Color.Black, Color.White)
    186. e.Graphics.FillRectangle(boxPinsel, (e.Bounds.Left + 1),
    187. (e.Bounds.Top + 1), (e.Bounds.Width - 1), (e.Bounds.Height - 1))
    188. boxPinsel.Dispose()
    189. End Sub
    190. Private Sub
    191. hintergrund_CheckedChanged(ByVal sender As Object, ByVal e As
    192. System.EventArgs)
    193. Me.InvalidateAnzeigePanel()
    194. End Sub
    195. Private Sub
    196. Figur_CheckedChanged(ByVal sender As Object, ByVal e As
    197. System.EventArgs)
    198. If radioButtonLinie.Checked Then
    199. Figur = Figur.Linie
    200. ElseIf
    201. radioButtonRechteck.Checked Then
    202. Figur =
    203. Figur.Rechteck
    204. Else
    205. Figur =
    206. Figur.Kreis
    207. End If
    208. Me.InvalidateAnzeigePanel()
    209. End Sub
    210. Private Sub
    211. groesseTrackbar_Scroll(ByVal sender As Object, ByVal e As
    212. System.EventArgs)
    213. 'die Größe der Figur ermitteln
    214. Select Case (groesseTrackbar.Value)
    215. Case 1
    216. Me.startGroesse = 125
    217. Case 2
    218. Me.startGroesse = 100
    219. Case 3
    220. Case Else
    221. Me.startGroesse = 75
    222. End Select
    223. Me.InvalidateAnzeigePanel()
    224. End Sub
    225. Private Sub
    226. numericUpDownDauer_ValueChanged(ByVal sender As Object, ByVal e As
    227. System.EventArgs)
    228. Me.animationInterval =
    229. (CType(numericUpDownDauer.Value, Int32) * 100)
    230. End Sub
    231. Private Sub
    232. numericUpDownWiederholungen_ValueChanged(ByVal sender As Object,
    233. ByVal e As System.EventArgs)
    234. Me.animationWiederholung
    235. = CType(numericUpDownWiederholungen.Value, Int32)
    236. End Sub
    237. Private Sub
    238. buttonLoeschen_Click(ByVal sender As Object, ByVal e As
    239. System.EventArgs)
    240. 'die Zeichenfläche löschen
    241. Dim g As Graphics = Me.anzeigePanel.CreateGraphics
    242. g.Clear(anzeigePanel.BackColor)
    243. g.Dispose()
    244. End Sub
    245. Private Sub
    246. buttonStart_Click(ByVal sender As Object, ByVal e As
    247. System.EventArgs)
    248. End Sub
    249. Private Sub
    250. buttonAnimation_Click(ByVal sender As Object, ByVal e As
    251. System.EventArgs)
    252. Me.animationInterval =
    253. (CType(numericUpDownDauer.Value, Int32) * 100)
    254. Me.animationWiederholung = CType(numericUpDownWiederholungen.Value,
    255. Int32)
    256. Me.animationAktiv = Not Me.animationAktiv
    257. animationTimer.Interval = Me.animationInterval
    258. animationTimer.Enabled = Me.animationAktiv
    259. Me.animationLauf = Me.animationWiederholung
    260. Me.animationMinus = False
    261. Me.animationGroesse =
    262. Me.startGroesse
    263. Me.anzeigePanel.Invalidate()
    264. End Sub
    265. Private Sub
    266. animationTimer_Tick(ByVal sender As Object, ByVal e As
    267. System.EventArgs)
    268. Dim minGroesse As Int32 =
    269. Me.startGroesse
    270. Dim maxGroesse As Int32 =
    271. Math.Min(Me.anzeigePanel.ClientSize.Width,
    272. Me.anzeigePanel.ClientSize.Height)
    273. If Figur = Rechteck
    274. Then
    275. minGroesse = 0
    276. maxGroesse = 2
    277. End If
    278. If Me.animationMinus Then
    279. Me.animationGroesse = (Me.animationGroesse - 1)
    280. If (Me.animationGroesse <= minGroesse) Then
    281. Me.animationMinus = False
    282. 'Neuer
    283. Durchlauf?
    284. Me.animationLauf =
    285. (Me.animationLauf - 1)
    286. If (Me.animationLauf <=
    287. 0) Then
    288. Me.animationAktiv = False
    289. animationTimer.Enabled = False
    290. End If
    291. End If
    292. Else
    293. Me.animationGroesse = (Me.animationGroesse + 1)
    294. If
    295. (Me.animationGroesse >= maxGroesse) Then
    296. Me.animationMinus = True
    297. End If
    298. End If
    299. System.Diagnostics.Debug.WriteLine("Animation: {0} / {1}",
    300. Me.animationGroesse, Me.animationMinus)
    301. Me.anzeigePanel.Invalidate()
    302. End Sub
    303. Private Sub
    304. InvalidateAnzeigePanel()
    305. If Not Me.animationAktiv
    306. Then
    307. Me.anzeigePanel.Invalidate()
    308. End If
    309. End Sub
    310. Private Sub
    311. anzeigePanel_Paint(ByVal sender As Object, ByVal e As
    312. PaintEventArgs)
    313. Dim zeichenflaeche As Graphics =
    314. e.Graphics
    315. zeichenflaeche.SmoothingMode =
    316. SmoothingMode.AntiAlias
    317. Dim stift As Pen = New
    318. Pen(Me.linienFarbe)
    319. Dim pinsel As SolidBrush = New
    320. SolidBrush(Me.hintergrundFarbe)
    321. stift.Width =
    322. Me.linienStaerke
    323. stift.DashStyle = Me.linienStil
    324. ' Zeichenrechteck bestimmen, Vorschau fix / Animation
    325. fliessend
    326. Dim offset As Int32 = Me.startGroesse
    327. If Me.animationAktiv Then
    328. offset =
    329. Me.animationGroesse
    330. End If
    331. Dim zeichenRectangle As
    332. Rectangle = Rectangle.Inflate(anzeigePanel.ClientRectangle, (offset *
    333. -1), (offset * -1))
    334. System.Diagnostics.Debug.WriteLine("Größe: {0}",
    335. zeichenRectangle)
    336. ' Figur zeichnen
    337. Select Case Figur
    338. Case Figur.Kreis
    339. Case Else
    340. If
    341. radioButtonHintergrundFarbe.Checked Then
    342. zeichenflaeche.FillEllipse(pinsel, zeichenRectangle)
    343. ElseIf radioButtonHintergrundMuster.Checked Then
    344. Dim musterPinsel As HatchBrush = New
    345. HatchBrush(Me.fuellStil, Me.linienFarbe, Me.hintergrundFarbe)
    346. zeichenflaeche.FillEllipse(musterPinsel,
    347. zeichenRectangle)
    348. musterPinsel.Dispose()
    349. End If
    350. zeichenflaeche.DrawEllipse(stift, zeichenRectangle)
    351. If (Me.Figur = Figur.Rechteck) Then
    352. If radioButtonHintergrundFarbe.Checked Then
    353. zeichenflaeche.FillRectangle(pinsel, zeichenRectangle)
    354. ElseIf radioButtonHintergrundMuster.Checked Then
    355. Dim musterPinsel As HatchBrush = New
    356. HatchBrush(Me.fuellStil, Me.linienFarbe, Me.hintergrundFarbe)
    357. zeichenflaeche.FillRectangle(musterPinsel,
    358. zeichenRectangle)
    359. musterPinsel.Dispose()
    360. End If
    361. zeichenflaeche.DrawRectangle(stift, zeichenRectangle)
    362. ElseIf (Me.Figur = Figur.Linie) Then
    363. Dim center As Int32 = ((zeichenRectangle.Top _
    364. +
    365. (zeichenRectangle.Bottom - Me.linienStaerke)) _
    366. /
    367. 2)
    368. zeichenflaeche.DrawLine(stift, New
    369. Point(zeichenRectangle.Left, center), New
    370. Point(zeichenRectangle.Right, center))
    371. End If
    372. End Select
    373. 'Stift und Pinsel löschen
    374. stift.Dispose()
    375. pinsel.Dispose()
    376. End Sub


    *Spoiler und VB-BBCode eingefügt*

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Marcus Gräfe“ ()

    @BigBrain Etwas tricky:
    Spoiler anzeigen

    VB.NET-Quellcode

    1. Imports System
    2. Imports System.Drawing
    3. Imports System.Drawing.Drawing2D
    4. Imports System.Windows.Forms
    5. Public Class Form1
    6. Enum Figur
    7. Kreis
    8. Rechteck
    9. Linie
    10. End Enum
    11. Private _figur As Figur
    12. Private linienStaerke As Int32
    13. Private linienFarbe As Color
    14. Private hintergrundFarbe As Color
    15. Private linienStil As DashStyle
    16. Private fuellStil As HatchStyle
    17. Private startGroesse As Int32
    18. Private animationWiederholung As Int32
    19. Private animationInterval As Int32
    20. Private animationAktiv As Boolean
    21. Private animationLauf As Int32
    22. Private animationMinus As Boolean
    23. Private animationGroesse As Int32
    24. 'für die Linienstile
    25. Private Shared ReadOnly auswahlLinienstile() As DashStyle = {
    26. DashStyle.Solid,
    27. DashStyle.Dash,
    28. DashStyle.DashDot,
    29. DashStyle.DashDotDot,
    30. DashStyle.Dot}
    31. Private Shared ReadOnly Dash() As DashStyle
    32. Private Shared DashDot() As DashStyle
    33. Private Shared DashDotDot() As DashStyle
    34. Private Shared Dot() As DashStyle
    35. 'für die Hintergrundmuster
    36. Private Shared ReadOnly auswahlFuellstile() As HatchStyle = {
    37. HatchStyle.BackwardDiagonal,
    38. HatchStyle.Cross,
    39. HatchStyle.DottedGrid,
    40. HatchStyle.ForwardDiagonal,
    41. HatchStyle.Sphere,
    42. HatchStyle.Vertical,
    43. HatchStyle.Wave,
    44. HatchStyle.ZigZag}
    45. 'Private Shared HatchStyle.Cross() As HatchStyle
    46. Private Shared DottedGrid() As HatchStyle
    47. Private Shared ForwardDiagonal() As HatchStyle
    48. Private Shared Sphere() As HatchStyle
    49. Private Shared Vertical() As HatchStyle
    50. Private Shared Wave() As HatchStyle
    51. Private Shared ZigZag() As HatchStyle
    52. Public Sub New()
    53. InitializeComponent()
    54. _figur = Figur.Kreis
    55. End Sub
    56. Private Sub buttonBeenden_Click(sender As Object, e As EventArgs) Handles buttonBeenden.Click
    57. Me.Close()
    58. End Sub
    59. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    60. Me.startGroesse = 100
    61. Me.linienStaerke = 1
    62. Me.linienFarbe = Color.Black
    63. Me.hintergrundFarbe = Color.White
    64. radioButtonKreis.Checked = True
    65. 'die Einträge für die Linienstile erzeugen
    66. For Each element As DashStyle In auswahlLinienstile
    67. listBoxLinieStil.Items.Add("")
    68. Next
    69. listBoxLinieStil.SelectedIndex = 0
    70. 'und für die Hintergrundmuster
    71. For Each element As HatchStyle In auswahlFuellstile
    72. listBoxHintergrundMuster.Items.Add("")
    73. Next
    74. listBoxHintergrundMuster.SelectedIndex = -1
    75. End Sub
    76. Private Sub buttonLinieFarbe_Click(sender As Object, e As EventArgs) Handles buttonLinieFarbe.Click
    77. colorDialog1.Color = panelLinieFarbeVorschau.BackColor
    78. If (colorDialog1.ShowDialog = DialogResult.OK) Then
    79. panelLinieFarbeVorschau.BackColor = colorDialog1.Color
    80. Me.linienFarbe = colorDialog1.Color
    81. Me.InvalidateAnzeigePanel()
    82. End If
    83. End Sub
    84. Private Sub buttonHintergrundFarbe_Click(sender As Object, e As EventArgs) Handles buttonHintergrundFarbe.Click
    85. colorDialog1.Color = panelHintergrundFarbeVorschau.BackColor
    86. If (colorDialog1.ShowDialog = DialogResult.OK) Then
    87. panelHintergrundFarbeVorschau.BackColor = colorDialog1.Color
    88. Me.hintergrundFarbe = colorDialog1.Color
    89. If radioButtonHintergrundOhne.Checked Then
    90. radioButtonHintergrundFarbe.Checked = True
    91. End If
    92. Me.InvalidateAnzeigePanel()
    93. End If
    94. End Sub
    95. Private Sub InvalidateAnzeigePanel()
    96. If Not Me.animationAktiv Then
    97. Me.anzeigePanel.Invalidate()
    98. End If
    99. End Sub
    100. Private Sub panelLinieFarbeVorschau_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles panelLinieFarbeVorschau.DoubleClick
    101. Me.buttonLinieFarbe_Click(sender, e)
    102. End Sub
    103. Private Sub panelHintergrundFarbeVorschau_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles panelHintergrundFarbeVorschau.DoubleClick
    104. Me.buttonHintergrundFarbe_Click(sender, e)
    105. End Sub
    106. Private Sub listBoxLinieStil_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles listBoxLinieStil.SelectedIndexChanged
    107. If (listBoxLinieStil.SelectedIndex >= 0) Then
    108. Me.linienStil = auswahlLinienstile(listBoxLinieStil.SelectedIndex)
    109. Else
    110. Me.linienStil = DashStyle.Solid
    111. End If
    112. Me.InvalidateAnzeigePanel()
    113. End Sub
    114. Private Sub listBoxLinieStil_DrawItem(ByVal sender As Object, ByVal e As DrawItemEventArgs) Handles listBoxLinieStil.DrawItem
    115. Dim y As Int32 = CInt(((e.Bounds.Top + e.Bounds.Bottom) / 2))
    116. e.DrawBackground()
    117. Dim boxStift As Pen = New Pen(Color.Black)
    118. boxStift.DashStyle = auswahlLinienstile(e.Index)
    119. e.Graphics.DrawLine(boxStift, (e.Bounds.Left + 1), y, (e.Bounds.Right - 1), y)
    120. boxStift.Dispose()
    121. End Sub
    122. Private Sub numericUpDownLinieStaerke_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles numericUpDownLinieStaerke.ValueChanged
    123. Me.linienStaerke = CType(numericUpDownLinieStaerke.Value, Int32)
    124. Me.InvalidateAnzeigePanel()
    125. End Sub
    126. Private Sub listBoxHintergrundMuster_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles listBoxHintergrundMuster.SelectedIndexChanged
    127. If (listBoxHintergrundMuster.SelectedIndex >= 0) Then
    128. Me.fuellStil = auswahlFuellstile(listBoxHintergrundMuster.SelectedIndex)
    129. Me.radioButtonHintergrundMuster.Checked = True
    130. Else
    131. Me.radioButtonHintergrundOhne.Checked = True
    132. Me.fuellStil = auswahlFuellstile(0)
    133. End If
    134. Me.InvalidateAnzeigePanel()
    135. End Sub
    136. Private Sub listBoxHintergrundMuster_DrawItem(ByVal sender As Object, ByVal e As DrawItemEventArgs)
    137. e.DrawBackground()
    138. Dim boxPinsel As HatchBrush = New HatchBrush(auswahlFuellstile(e.Index), Color.Black, Color.White)
    139. e.Graphics.FillRectangle(boxPinsel, (e.Bounds.Left + 1), (e.Bounds.Top + 1), (e.Bounds.Width - 1), (e.Bounds.Height - 1))
    140. boxPinsel.Dispose()
    141. End Sub
    142. Private Sub hintergrund_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles radioButtonHintergrundFarbe.CheckedChanged, radioButtonHintergrundMuster.CheckedChanged, radioButtonHintergrundOhne.CheckedChanged
    143. Me.InvalidateAnzeigePanel()
    144. End Sub
    145. Private Sub Figur_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles radioButtonKreis.CheckedChanged, radioButtonLinie.CheckedChanged, radioButtonRechteck.CheckedChanged
    146. If radioButtonLinie.Checked Then
    147. _figur = Figur.Linie
    148. ElseIf radioButtonRechteck.Checked Then
    149. _figur = Figur.Rechteck
    150. Else
    151. _figur = Figur.Kreis
    152. End If
    153. Me.InvalidateAnzeigePanel()
    154. End Sub
    155. Private Sub groesseTrackbar_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles groesseTrackbar.Scroll
    156. 'die Größe der Figur ermitteln
    157. Select Case (groesseTrackbar.Value)
    158. Case 1
    159. Me.startGroesse = 125
    160. Case 2
    161. Me.startGroesse = 100
    162. Case 3
    163. Case Else
    164. Me.startGroesse = 75
    165. End Select
    166. Me.InvalidateAnzeigePanel()
    167. End Sub
    168. Private Sub numericUpDownDauer_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles numericUpDownDauer.ValueChanged
    169. Me.animationInterval = (CType(numericUpDownDauer.Value, Int32) * 100)
    170. End Sub
    171. Private Sub numericUpDownWiederholungen_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles numericUpDownWiederholungen.ValueChanged
    172. Me.animationWiederholung = CType(numericUpDownWiederholungen.Value, Int32)
    173. End Sub
    174. Private Sub buttonLoeschen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles buttonLoeschen.Click
    175. 'die Zeichenfläche löschen
    176. Dim g As Graphics = Me.anzeigePanel.CreateGraphics
    177. g.Clear(anzeigePanel.BackColor)
    178. g.Dispose()
    179. End Sub
    180. Private Sub buttonStart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles buttonStart.Click
    181. buttonAnimation.PerformClick()
    182. End Sub
    183. Private Sub buttonAnimation_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles buttonAnimation.Click
    184. Me.animationInterval = (CType(numericUpDownDauer.Value, Int32) * 100)
    185. Me.animationWiederholung = CType(numericUpDownWiederholungen.Value, Int32)
    186. Me.animationAktiv = Not Me.animationAktiv
    187. animationTimer.Interval = Me.animationInterval
    188. animationTimer.Enabled = Me.animationAktiv
    189. Me.animationLauf = Me.animationWiederholung
    190. Me.animationMinus = False
    191. Me.animationGroesse = Me.startGroesse
    192. Me.anzeigePanel.Invalidate()
    193. End Sub
    194. Private Sub animationTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles animationTimer.Tick
    195. Dim minGroesse As Int32 = Me.startGroesse
    196. Dim maxGroesse As Int32 = Math.Min(Me.anzeigePanel.ClientSize.Width,
    197. Me.anzeigePanel.ClientSize.Height)
    198. If _figur = Figur.Rechteck Then
    199. minGroesse = 0
    200. maxGroesse = 2
    201. End If
    202. If Me.animationMinus Then
    203. Me.animationGroesse = (Me.animationGroesse - 1)
    204. If (Me.animationGroesse <= minGroesse) Then
    205. Me.animationMinus = False
    206. 'Neuer Durchlauf?
    207. Me.animationLauf = (Me.animationLauf - 1)
    208. If (Me.animationLauf <= 0) Then
    209. Me.animationAktiv = False
    210. animationTimer.Enabled = False
    211. End If
    212. End If
    213. Else
    214. Me.animationGroesse = (Me.animationGroesse + 1)
    215. If (Me.animationGroesse >= maxGroesse) Then
    216. Me.animationMinus = True
    217. End If
    218. End If
    219. System.Diagnostics.Debug.WriteLine("Animation: {0} / {1}",
    220. Me.animationGroesse, Me.animationMinus)
    221. Me.anzeigePanel.Invalidate()
    222. End Sub
    223. Private Sub anzeigePanel_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles anzeigePanel.Paint
    224. Dim zeichenflaeche As Graphics = e.Graphics
    225. zeichenflaeche.SmoothingMode = SmoothingMode.AntiAlias
    226. Dim stift As Pen = New Pen(Me.linienFarbe)
    227. Dim pinsel As SolidBrush = New SolidBrush(Me.hintergrundFarbe)
    228. stift.Width = Me.linienStaerke
    229. stift.DashStyle = Me.linienStil
    230. ' Zeichenrechteck bestimmen, Vorschau fix / Animation fliessend
    231. Dim offset As Int32 = Me.startGroesse
    232. If Me.animationAktiv Then
    233. offset = Me.animationGroesse
    234. End If
    235. Dim zeichenRectangle As Rectangle = Rectangle.Inflate(anzeigePanel.ClientRectangle, (offset * -1), (offset * -1))
    236. System.Diagnostics.Debug.WriteLine("Größe: {0}", zeichenRectangle)
    237. ' Figur zeichnen
    238. Select Case _figur
    239. Case Figur.Kreis
    240. 'Case Else
    241. If radioButtonHintergrundFarbe.Checked Then
    242. zeichenflaeche.FillEllipse(pinsel, zeichenRectangle)
    243. ElseIf radioButtonHintergrundMuster.Checked Then
    244. Dim musterPinsel As HatchBrush = New HatchBrush(Me.fuellStil, Me.linienFarbe, Me.hintergrundFarbe)
    245. zeichenflaeche.FillEllipse(musterPinsel, zeichenRectangle)
    246. musterPinsel.Dispose()
    247. End If
    248. zeichenflaeche.DrawEllipse(stift, zeichenRectangle)
    249. Case Figur.Rechteck
    250. If radioButtonHintergrundFarbe.Checked Then
    251. zeichenflaeche.FillRectangle(pinsel, zeichenRectangle)
    252. ElseIf radioButtonHintergrundMuster.Checked Then
    253. Dim musterPinsel As HatchBrush = New HatchBrush(Me.fuellStil, Me.linienFarbe, Me.hintergrundFarbe)
    254. zeichenflaeche.FillRectangle(musterPinsel, zeichenRectangle)
    255. musterPinsel.Dispose()
    256. End If
    257. zeichenflaeche.DrawRectangle(stift, zeichenRectangle)
    258. Case Figur.Linie
    259. Dim center As Int32 = ((zeichenRectangle.Top + (zeichenRectangle.Bottom - Me.linienStaerke)) \ 2)
    260. zeichenflaeche.DrawLine(stift, New Point(zeichenRectangle.Left, center), New Point(zeichenRectangle.Right, center))
    261. End Select
    262. 'Stift und Pinsel löschen
    263. stift.Dispose()
    264. pinsel.Dispose()
    265. End Sub
    266. End Class
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Herzlichen Glückwünsch dass du wieder keine Code- und Spoiler Tags benutzt.

    Nur mal so, erhält @RodFromGermany eigentlich deine Note in der Weiterbildung?
    Du suchst dir zu eine Aufgabe C++ Code den dem nicht versteht, lässt dir den hier in korrektes VB.net über setzen und hast dann Was in der Weiterbildung gelernt?
    Die deutsche Sprache ist Freeware, du kannst sie benutzen, ohne dafür zu bezahlen. Sie ist aber nicht Open Source, also darfst du sie nicht verändern, wie es dir gerade passt.
    ...Klasse !!! bis auf das Rechteck funzt der Code... den versuche ich dann mal zu richten, ansonsten melde ich mich... du bist echt SUPER..ich denke hier habe ich einen Freak kennengelernt :) :)
    Mein Studium ist gerettet!
    Ach, die Linie soll vertikal sein, hier muss ich doch nur die Koordinaten ändern oder??? Danke..

    Grüße

    @MrTrebron
    ...es ist kein Meister vom Himmel gefallen, auch du/Sie warst/waren mal Anfänger...im Übrigen, ich muss mich ja nicht rechtfertigen aber ich hatte diesen Code fasst in VB hinbekommen, jedoch fehlt halt mir immer noch die Erfahrung. Aber dennoch VIELEN DANK an solche Teilnehmer die Anfänger so Wilkommen heißen!

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „BigBrain“ ()

    BigBrain schrieb:

    Ach, die Linie soll vertikal sein
    Das schaffst Du aber bittallein.
    Im Original war sie auch waagerecht.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Tja, es heißt aber auch Übung macht den Meister. Nicht Copy & Paste.

    Deinen VB.net Code hast du nicht gelistet, nicht mal einen Pseudo-Code in dem Du uns Deine Idee zeigt.

    Ich sehe nur "Habe ich gefunden, kann ich aber nicht über setzen.
    Die deutsche Sprache ist Freeware, du kannst sie benutzen, ohne dafür zu bezahlen. Sie ist aber nicht Open Source, also darfst du sie nicht verändern, wie es dir gerade passt.
    @RodFromGermany
    Hallo,
    ich bins wieder, ich benötige deine Hilfe bei der Linie. Ich habe alles mögliche versucht, aber die sch... vertikale Linie bekomme ich nicht hin!.Ich bin am verzweifeln:

    Die folgenden Codes habe ich versucht...

    VB.NET-Quellcode

    1. Case Figur.Linie
    2. 'Dim center As Integer = ((zeichenRectangle.Top + (zeichenRectangle.Bottom - Me.linienStaerke)) \ 2)
    3. 'zeichenflaeche.DrawLine(stift, New Point(zeichenRectangle.Left, center), New Point(zeichenRectangle.Right, center))
    4. 'Dim mid As New PointF
    5. 'e.Graphics.DrawLine(stift, mid, New Point(zeichenRectangle.Left + (zeichenRectangle.Width / 2), zeichenRectangle.Top + zeichenRectangle.Height))
    6. 'e.Graphics.DrawLine(stift, mid, New Point(zeichenRectangle.Left + (zeichenRectangle.Width / 2), zeichenRectangle.Top))
    7. 'zeichnet von oben links nach unten rechts
    8. 'e.Graphics.DrawLine(stift, zeichenRectangle.Width / 2, zeichenRectangle.Width / 2, zeichenRectangle.Top)
    9. 'e.Graphics.DrawLine(stift, mid, New Point(zeichenRectangle.Left, zeichenRectangle.Top + (zeichenRectangle.Height / 2)))
    10. 'zeichnet ein X
    11. e.Graphics.DrawLine(stift, zeichenRectangle.Left, zeichenRectangle.Top, zeichenRectangle.Right, zeichenRectangle.Bottom)
    12. 'e.Graphics.DrawLine(stift, zeichenRectangle.Left, zeichenRectangle.Bottom, zeichenRectangle.Right, zeichenRectangle.Top)
    13. 'Das ist der String den wir im Übungsheft hatten...
    14. 'Dim xMax As Integer = zeichenRectangle.Right - 1
    15. 'Dim yMax As Integer = zeichenRectangle.Bottom - 1
    16. 'Dim xPos As Integer = 0, yPos As Integer = 0
    17. 'While yPos < yMax
    18. 'While xPos < xMax
    19. 'e.Graphics.DrawLine(stift, xPos, 0, xPos, yPos)
    20. 'xPos = xPos + 10
    21. 'End While
    22. 'End While


    Irgendwo ist der Wurm drin. Danke dir schon vorab.

    Code-Tag repariert. ~Thunderbolt

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Thunderbolt“ ()

    @BigBrain Kannst Du mal Deinen Code so formatieren, dass wir Code von Nicht-Code unterscheiden können?
    Der [ vbnet ]CODE MUSS HIER STEHEN[ /vbnet ]. {ohne Leerzeichen}
    Editiere Deine Post.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    @BigBrain Würdest Du Dir so einen Code ansehen, wie Deinen eben geposteten?
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!

    RodFromGermany schrieb:

    Editiere Deine Post.

    Nicht noch einen missglücken post erstellen, sondern editieren !

    BigBrain schrieb:

    Lösungsvorschlag
    Ich habe Dir ein komplettes Programm von CLI über C# nach VB.NET übersetzt, offensichtlich hat Dir das nicht geholfen ;( .
    Du müsstest lediglich eine einzige Zeile des Codes modifizieren und feddich.
    Leider bist Du weder in der Lage, diese Zeile zu identifizieren,
    noch kannst Du Quellcode als solchen markieren, obwohl Du das in Post #1 und in Post #5 schon mal richtig gemacht hast.
    In Ermangelung von Eigeninitiative verbunden mit Beratungsresistenz bin ich dann mal draußen.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!