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
Codetags und Spoiler eingefügt. ~Trade
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.
Quellcode
- namespace Forms_spielerei {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- using namespace System::Drawing::Drawing2D;
- /// <summary>
- /// Zusammenfassung für MyForm
- /// </summary>
- public ref class MyForm : public System::Windows::Forms::Form
- {
- private:
- enum class Figur : int
- {
- Kreis,
- Rechteck,
- Linie
- };
- Figur figur;
- Int32 linienStaerke;
- Color linienFarbe;
- Color hintergrundFarbe;
- DashStyle linienStil;
- HatchStyle fuellStil;
- Int32 startGroesse;
- Int32 animationWiederholung;
- Int32 animationInterval;
- Boolean animationAktiv;
- Int32 animationLauf;
- Boolean animationMinus;
- Int32 animationGroesse;
- /*
- Die Vereinbarung muss als static erfolgen.
- Andernfalls kann man dem Array keine Werte zuweisen.
- */
- //für die Linienstile
- static array <DashStyle>^ auswahlLinienstile = {
- DashStyle::Solid,
- DashStyle::Dash,
- DashStyle::DashDot,
- DashStyle::DashDotDot,
- DashStyle::Dot};
- //für die Hintergrundmuster
- static array <HatchStyle> ^auswahlFuellstile = {
- HatchStyle::BackwardDiagonal,
- HatchStyle::Cross,
- HatchStyle::DottedGrid,
- HatchStyle::ForwardDiagonal,
- HatchStyle::Sphere,
- HatchStyle::Vertical,
- HatchStyle::Wave,
- HatchStyle::ZigZag };
- public:
- MyForm(void)
- {
- InitializeComponent();
- figur = Figur::Kreis;
- }
- protected:
- /// <summary>Verwendete Ressourcen bereinigen.</summary>
- ~MyForm()
- {
- if (components)
- {
- delete components;
- }
- }
- #pragma region Designer Variables
- private: System::Windows::Forms::Panel^ anzeigePanel;
- private: System::Windows::Forms::GroupBox^ groupBox2;
- private: System::Windows::Forms::GroupBox^ groupBox1;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::ListBox^ listBoxLinieStil;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::NumericUpDown^ numericUpDownLinieStaerke;
- private: System::Windows::Forms::RadioButton^ radioButtonHintergrundMuster;
- private: System::Windows::Forms::RadioButton^ radioButtonHintergrundFarbe;
- private: System::Windows::Forms::RadioButton^ radioButtonHintergrundOhne;
- private: System::Windows::Forms::ListBox^ listBoxHintergrundMuster;
- private: System::Windows::Forms::Label^ label5;
- private: System::Windows::Forms::Label^ label4;
- private: System::Windows::Forms::GroupBox^ groupBox3;
- private: System::Windows::Forms::RadioButton^ radioButtonLinie;
- private: System::Windows::Forms::RadioButton^ radioButtonKreis;
- private: System::Windows::Forms::RadioButton^ radioButtonRechteck;
- private: System::Windows::Forms::TrackBar^ groesseTrackbar;
- private: System::Windows::Forms::Button^ buttonStart;
- private: System::Windows::Forms::Button^ buttonLoeschen;
- private: System::Windows::Forms::Button^ buttonBeenden;
- private: System::Windows::Forms::Button^ buttonLinieFarbe;
- private: System::Windows::Forms::Panel^ panelLinieFarbeVorschau;
- private: System::Windows::Forms::ColorDialog^ colorDialog1;
- private: System::Windows::Forms::Button^ buttonHintergrundFarbe;
- private: System::Windows::Forms::Panel^ panelHintergrundFarbeVorschau;
- private: System::Windows::Forms::Label^ label6;
- private: System::Windows::Forms::Label^ label7;
- private: System::Windows::Forms::Button^ buttonAnimation;
- private: System::Windows::Forms::NumericUpDown^ numericUpDownWiederholungen;
- private: System::Windows::Forms::NumericUpDown^ numericUpDownDauer;
- private: System::Windows::Forms::Timer^ animationTimer;
- /// <summary>Erforderliche Designervariable.</summary>
- private: System::ComponentModel::IContainer^ components;
- #pragma endregion
- private:
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Erforderliche Methode für die Designerunterstützung.
- /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
- /// </summary>
- void InitializeComponent(void)
- {
- this->components = (gcnew System::ComponentModel::Container());
- this->anzeigePanel = (gcnew System::Windows::Forms::Panel());
- this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
- this->buttonHintergrundFarbe = (gcnew System::Windows::Forms::Button());
- this->panelHintergrundFarbeVorschau = (gcnew System::Windows::Forms::Panel());
- this->listBoxHintergrundMuster = (gcnew System::Windows::Forms::ListBox());
- this->label5 = (gcnew System::Windows::Forms::Label());
- this->label4 = (gcnew System::Windows::Forms::Label());
- this->radioButtonHintergrundMuster = (gcnew System::Windows::Forms::RadioButton());
- this->radioButtonHintergrundFarbe = (gcnew System::Windows::Forms::RadioButton());
- this->radioButtonHintergrundOhne = (gcnew System::Windows::Forms::RadioButton());
- this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
- this->buttonLinieFarbe = (gcnew System::Windows::Forms::Button());
- this->panelLinieFarbeVorschau = (gcnew System::Windows::Forms::Panel());
- this->label3 = (gcnew System::Windows::Forms::Label());
- this->listBoxLinieStil = (gcnew System::Windows::Forms::ListBox());
- this->numericUpDownLinieStaerke = (gcnew System::Windows::Forms::NumericUpDown());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->groupBox3 = (gcnew System::Windows::Forms::GroupBox());
- this->radioButtonLinie = (gcnew System::Windows::Forms::RadioButton());
- this->radioButtonKreis = (gcnew System::Windows::Forms::RadioButton());
- this->radioButtonRechteck = (gcnew System::Windows::Forms::RadioButton());
- this->groesseTrackbar = (gcnew System::Windows::Forms::TrackBar());
- this->buttonStart = (gcnew System::Windows::Forms::Button());
- this->buttonLoeschen = (gcnew System::Windows::Forms::Button());
- this->buttonBeenden = (gcnew System::Windows::Forms::Button());
- this->colorDialog1 = (gcnew System::Windows::Forms::ColorDialog());
- this->label6 = (gcnew System::Windows::Forms::Label());
- this->label7 = (gcnew System::Windows::Forms::Label());
- this->buttonAnimation = (gcnew System::Windows::Forms::Button());
- this->numericUpDownWiederholungen = (gcnew System::Windows::Forms::NumericUpDown());
- this->numericUpDownDauer = (gcnew System::Windows::Forms::NumericUpDown());
- this->animationTimer = (gcnew System::Windows::Forms::Timer(this->components));
- this->groupBox2->SuspendLayout();
- this->groupBox1->SuspendLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDownLinieStaerke))->BeginInit();
- this->groupBox3->SuspendLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->groesseTrackbar))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDownWiederholungen))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDownDauer))->BeginInit();
- this->SuspendLayout();
- //
- // anzeigePanel
- //
- this->anzeigePanel->BackColor = System::Drawing::Color::White;
- this->anzeigePanel->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
- this->anzeigePanel->Location = System::Drawing::Point(16, 15);
- this->anzeigePanel->Margin = System::Windows::Forms::Padding(4);
- this->anzeigePanel->Name = L"anzeigePanel";
- this->anzeigePanel->Size = System::Drawing::Size(399, 369);
- this->anzeigePanel->TabIndex = 0;
- this->anzeigePanel->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &MyForm::anzeigePanel_Paint);
- //
- // groupBox2
- //
- this->groupBox2->Controls->Add(this->buttonHintergrundFarbe);
- this->groupBox2->Controls->Add(this->panelHintergrundFarbeVorschau);
- this->groupBox2->Controls->Add(this->listBoxHintergrundMuster);
- this->groupBox2->Controls->Add(this->label5);
- this->groupBox2->Controls->Add(this->label4);
- this->groupBox2->Controls->Add(this->radioButtonHintergrundMuster);
- this->groupBox2->Controls->Add(this->radioButtonHintergrundFarbe);
- this->groupBox2->Controls->Add(this->radioButtonHintergrundOhne);
- this->groupBox2->Location = System::Drawing::Point(436, 158);
- this->groupBox2->Margin = System::Windows::Forms::Padding(4);
- this->groupBox2->Name = L"groupBox2";
- this->groupBox2->Padding = System::Windows::Forms::Padding(4);
- this->groupBox2->Size = System::Drawing::Size(267, 133);
- this->groupBox2->TabIndex = 2;
- this->groupBox2->TabStop = false;
- this->groupBox2->Text = L"Hintergrund";
- //
- // buttonHintergrundFarbe
- //
- this->buttonHintergrundFarbe->Location = System::Drawing::Point(139, 52);
- this->buttonHintergrundFarbe->Margin = System::Windows::Forms::Padding(4);
- this->buttonHintergrundFarbe->Name = L"buttonHintergrundFarbe";
- this->buttonHintergrundFarbe->Size = System::Drawing::Size(40, 28);
- this->buttonHintergrundFarbe->TabIndex = 7;
- this->buttonHintergrundFarbe->Text = L"...";
- this->buttonHintergrundFarbe->UseVisualStyleBackColor = true;
- this->buttonHintergrundFarbe->Click += gcnew System::EventHandler(this, &MyForm::buttonHintergrundFarbe_Click);
- //
- // panelHintergrundFarbeVorschau
- //
- this->panelHintergrundFarbeVorschau->BackColor = System::Drawing::Color::White;
- this->panelHintergrundFarbeVorschau->Location = System::Drawing::Point(83, 49);
- this->panelHintergrundFarbeVorschau->Margin = System::Windows::Forms::Padding(4);
- this->panelHintergrundFarbeVorschau->Name = L"panelHintergrundFarbeVorschau";
- this->panelHintergrundFarbeVorschau->Size = System::Drawing::Size(36, 30);
- this->panelHintergrundFarbeVorschau->TabIndex = 8;
- this->panelHintergrundFarbeVorschau->DoubleClick += gcnew System::EventHandler(this, &MyForm::panelHintergrundFarbeVorschau_DoubleClick);
- //
- // listBoxHintergrundMuster
- //
- this->listBoxHintergrundMuster->DrawMode = System::Windows::Forms::DrawMode::OwnerDrawFixed;
- this->listBoxHintergrundMuster->FormattingEnabled = true;
- this->listBoxHintergrundMuster->Location = System::Drawing::Point(77, 85);
- this->listBoxHintergrundMuster->Margin = System::Windows::Forms::Padding(4);
- this->listBoxHintergrundMuster->Name = L"listBoxHintergrundMuster";
- this->listBoxHintergrundMuster->Size = System::Drawing::Size(160, 30);
- this->listBoxHintergrundMuster->TabIndex = 4;
- this->listBoxHintergrundMuster->DrawItem += gcnew System::Windows::Forms::DrawItemEventHandler(this, &MyForm::listBoxHintergrundMuster_DrawItem);
- this->listBoxHintergrundMuster->SelectedIndexChanged += gcnew System::EventHandler(this, &MyForm::listBoxHintergrundMuster_SelectedIndexChanged);
- //
- // label5
- //
- this->label5->Location = System::Drawing::Point(8, 85);
- this->label5->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label5->Name = L"label5";
- this->label5->Size = System::Drawing::Size(55, 26);
- this->label5->TabIndex = 5;
- this->label5->Text = L"Stil:";
- //
- // label4
- //
- this->label4->Location = System::Drawing::Point(8, 52);
- this->label4->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label4->Name = L"label4";
- this->label4->Size = System::Drawing::Size(55, 26);
- this->label4->TabIndex = 4;
- this->label4->Text = L"Farbe:";
- //
- // radioButtonHintergrundMuster
- //
- this->radioButtonHintergrundMuster->AutoSize = true;
- this->radioButtonHintergrundMuster->Location = System::Drawing::Point(165, 23);
- this->radioButtonHintergrundMuster->Margin = System::Windows::Forms::Padding(4);
- this->radioButtonHintergrundMuster->Name = L"radioButtonHintergrundMuster";
- this->radioButtonHintergrundMuster->Size = System::Drawing::Size(72, 21);
- this->radioButtonHintergrundMuster->TabIndex = 2;
- this->radioButtonHintergrundMuster->TabStop = true;
- this->radioButtonHintergrundMuster->Text = L"Muster";
- this->radioButtonHintergrundMuster->UseVisualStyleBackColor = true;
- this->radioButtonHintergrundMuster->CheckedChanged += gcnew System::EventHandler(this, &MyForm::hintergrund_CheckedChanged);
- //
- // radioButtonHintergrundFarbe
- //
- this->radioButtonHintergrundFarbe->AutoSize = true;
- this->radioButtonHintergrundFarbe->Location = System::Drawing::Point(89, 23);
- this->radioButtonHintergrundFarbe->Margin = System::Windows::Forms::Padding(4);
- this->radioButtonHintergrundFarbe->Name = L"radioButtonHintergrundFarbe";
- this->radioButtonHintergrundFarbe->Size = System::Drawing::Size(66, 21);
- this->radioButtonHintergrundFarbe->TabIndex = 1;
- this->radioButtonHintergrundFarbe->TabStop = true;
- this->radioButtonHintergrundFarbe->Text = L"Farbe";
- this->radioButtonHintergrundFarbe->UseVisualStyleBackColor = true;
- this->radioButtonHintergrundFarbe->CheckedChanged += gcnew System::EventHandler(this, &MyForm::hintergrund_CheckedChanged);
- //
- // radioButtonHintergrundOhne
- //
- this->radioButtonHintergrundOhne->AutoSize = true;
- this->radioButtonHintergrundOhne->Checked = true;
- this->radioButtonHintergrundOhne->Location = System::Drawing::Point(12, 23);
- this->radioButtonHintergrundOhne->Margin = System::Windows::Forms::Padding(4);
- this->radioButtonHintergrundOhne->Name = L"radioButtonHintergrundOhne";
- this->radioButtonHintergrundOhne->Size = System::Drawing::Size(61, 21);
- this->radioButtonHintergrundOhne->TabIndex = 0;
- this->radioButtonHintergrundOhne->TabStop = true;
- this->radioButtonHintergrundOhne->Text = L"ohne";
- this->radioButtonHintergrundOhne->UseVisualStyleBackColor = true;
- this->radioButtonHintergrundOhne->CheckedChanged += gcnew System::EventHandler(this, &MyForm::hintergrund_CheckedChanged);
- //
- // groupBox1
- //
- this->groupBox1->Controls->Add(this->buttonLinieFarbe);
- this->groupBox1->Controls->Add(this->panelLinieFarbeVorschau);
- this->groupBox1->Controls->Add(this->label3);
- this->groupBox1->Controls->Add(this->listBoxLinieStil);
- this->groupBox1->Controls->Add(this->numericUpDownLinieStaerke);
- this->groupBox1->Controls->Add(this->label2);
- this->groupBox1->Controls->Add(this->label1);
- this->groupBox1->Location = System::Drawing::Point(436, 15);
- this->groupBox1->Margin = System::Windows::Forms::Padding(4);
- this->groupBox1->Name = L"groupBox1";
- this->groupBox1->Padding = System::Windows::Forms::Padding(4);
- this->groupBox1->Size = System::Drawing::Size(267, 135);
- this->groupBox1->TabIndex = 1;
- this->groupBox1->TabStop = false;
- this->groupBox1->Text = L"Linie";
- //
- // buttonLinieFarbe
- //
- this->buttonLinieFarbe->Location = System::Drawing::Point(139, 21);
- this->buttonLinieFarbe->Margin = System::Windows::Forms::Padding(4);
- this->buttonLinieFarbe->Name = L"buttonLinieFarbe";
- this->buttonLinieFarbe->Size = System::Drawing::Size(40, 28);
- this->buttonLinieFarbe->TabIndex = 0;
- this->buttonLinieFarbe->Text = L"...";
- this->buttonLinieFarbe->UseVisualStyleBackColor = true;
- this->buttonLinieFarbe->Click += gcnew System::EventHandler(this, &MyForm::buttonLinieFarbe_Click);
- //
- // panelLinieFarbeVorschau
- //
- this->panelLinieFarbeVorschau->BackColor = System::Drawing::Color::Black;
- this->panelLinieFarbeVorschau->Location = System::Drawing::Point(83, 18);
- this->panelLinieFarbeVorschau->Margin = System::Windows::Forms::Padding(4);
- this->panelLinieFarbeVorschau->Name = L"panelLinieFarbeVorschau";
- this->panelLinieFarbeVorschau->Size = System::Drawing::Size(36, 30);
- this->panelLinieFarbeVorschau->TabIndex = 6;
- this->panelLinieFarbeVorschau->DoubleClick += gcnew System::EventHandler(this, &MyForm::panelLinieFarbeVorschau_DoubleClick);
- //
- // label3
- //
- this->label3->Location = System::Drawing::Point(8, 100);
- this->label3->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(55, 26);
- this->label3->TabIndex = 5;
- this->label3->Text = L"Stärke:";
- //
- // listBoxLinieStil
- //
- this->listBoxLinieStil->DrawMode = System::Windows::Forms::DrawMode::OwnerDrawFixed;
- this->listBoxLinieStil->FormattingEnabled = true;
- this->listBoxLinieStil->Location = System::Drawing::Point(77, 57);
- this->listBoxLinieStil->Margin = System::Windows::Forms::Padding(4);
- this->listBoxLinieStil->Name = L"listBoxLinieStil";
- this->listBoxLinieStil->Size = System::Drawing::Size(160, 30);
- this->listBoxLinieStil->TabIndex = 4;
- this->listBoxLinieStil->DrawItem += gcnew System::Windows::Forms::DrawItemEventHandler(this, &MyForm::listBoxLinieStil_DrawItem);
- this->listBoxLinieStil->SelectedIndexChanged += gcnew System::EventHandler(this, &MyForm::listBoxLinieStil_SelectedIndexChanged);
- //
- // numericUpDownLinieStaerke
- //
- this->numericUpDownLinieStaerke->Location = System::Drawing::Point(77, 101);
- this->numericUpDownLinieStaerke->Margin = System::Windows::Forms::Padding(4);
- this->numericUpDownLinieStaerke->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 20, 0, 0, 0 });
- this->numericUpDownLinieStaerke->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
- this->numericUpDownLinieStaerke->Name = L"numericUpDownLinieStaerke";
- this->numericUpDownLinieStaerke->Size = System::Drawing::Size(161, 22);
- this->numericUpDownLinieStaerke->TabIndex = 5;
- this->numericUpDownLinieStaerke->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
- this->numericUpDownLinieStaerke->ValueChanged += gcnew System::EventHandler(this, &MyForm::numericUpDownLinieStaerke_ValueChanged);
- //
- // label2
- //
- this->label2->Location = System::Drawing::Point(8, 57);
- this->label2->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(32, 26);
- this->label2->TabIndex = 4;
- this->label2->Text = L"Stil:";
- //
- // label1
- //
- this->label1->Location = System::Drawing::Point(8, 23);
- this->label1->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(49, 26);
- this->label1->TabIndex = 3;
- this->label1->Text = L"Farbe:";
- //
- // groupBox3
- //
- this->groupBox3->Controls->Add(this->radioButtonLinie);
- this->groupBox3->Controls->Add(this->radioButtonKreis);
- this->groupBox3->Controls->Add(this->radioButtonRechteck);
- this->groupBox3->Location = System::Drawing::Point(436, 298);
- this->groupBox3->Margin = System::Windows::Forms::Padding(4);
- this->groupBox3->Name = L"groupBox3";
- this->groupBox3->Padding = System::Windows::Forms::Padding(4);
- this->groupBox3->Size = System::Drawing::Size(267, 60);
- this->groupBox3->TabIndex = 3;
- this->groupBox3->TabStop = false;
- this->groupBox3->Text = L"Figur";
- //
- // radioButtonLinie
- //
- this->radioButtonLinie->AutoSize = true;
- this->radioButtonLinie->Location = System::Drawing::Point(180, 23);
- this->radioButtonLinie->Margin = System::Windows::Forms::Padding(4);
- this->radioButtonLinie->Name = L"radioButtonLinie";
- this->radioButtonLinie->Size = System::Drawing::Size(59, 21);
- this->radioButtonLinie->TabIndex = 6;
- this->radioButtonLinie->TabStop = true;
- this->radioButtonLinie->Text = L"Linie";
- this->radioButtonLinie->UseVisualStyleBackColor = true;
- this->radioButtonLinie->CheckedChanged += gcnew System::EventHandler(this, &MyForm::anzeigeFigur_CheckedChanged);
- //
- // radioButtonKreis
- //
- this->radioButtonKreis->AutoSize = true;
- this->radioButtonKreis->Checked = true;
- this->radioButtonKreis->Location = System::Drawing::Point(12, 23);
- this->radioButtonKreis->Margin = System::Windows::Forms::Padding(4);
- this->radioButtonKreis->Name = L"radioButtonKreis";
- this->radioButtonKreis->Size = System::Drawing::Size(61, 21);
- this->radioButtonKreis->TabIndex = 4;
- this->radioButtonKreis->TabStop = true;
- this->radioButtonKreis->Text = L"Kreis";
- this->radioButtonKreis->UseVisualStyleBackColor = true;
- this->radioButtonKreis->CheckedChanged += gcnew System::EventHandler(this, &MyForm::anzeigeFigur_CheckedChanged);
- //
- // radioButtonRechteck
- //
- this->radioButtonRechteck->AutoSize = true;
- this->radioButtonRechteck->Location = System::Drawing::Point(83, 23);
- this->radioButtonRechteck->Margin = System::Windows::Forms::Padding(4);
- this->radioButtonRechteck->Name = L"radioButtonRechteck";
- this->radioButtonRechteck->Size = System::Drawing::Size(88, 21);
- this->radioButtonRechteck->TabIndex = 5;
- this->radioButtonRechteck->TabStop = true;
- this->radioButtonRechteck->Text = L"Rechteck";
- this->radioButtonRechteck->UseVisualStyleBackColor = true;
- this->radioButtonRechteck->CheckedChanged += gcnew System::EventHandler(this, &MyForm::anzeigeFigur_CheckedChanged);
- //
- // groesseTrackbar
- //
- this->groesseTrackbar->LargeChange = 1;
- this->groesseTrackbar->Location = System::Drawing::Point(436, 366);
- this->groesseTrackbar->Margin = System::Windows::Forms::Padding(4);
- this->groesseTrackbar->Maximum = 3;
- this->groesseTrackbar->Minimum = 1;
- this->groesseTrackbar->Name = L"groesseTrackbar";
- this->groesseTrackbar->Size = System::Drawing::Size(267, 56);
- this->groesseTrackbar->TabIndex = 4;
- this->groesseTrackbar->Value = 2;
- this->groesseTrackbar->Scroll += gcnew System::EventHandler(this, &MyForm::groesseTrackbar_Scroll);
- //
- // buttonStart
- //
- this->buttonStart->Location = System::Drawing::Point(436, 426);
- this->buttonStart->Margin = System::Windows::Forms::Padding(4);
- this->buttonStart->Name = L"buttonStart";
- this->buttonStart->Size = System::Drawing::Size(100, 28);
- this->buttonStart->TabIndex = 5;
- this->buttonStart->Text = L"Los geht\'s";
- this->buttonStart->UseVisualStyleBackColor = true;
- this->buttonStart->Click += gcnew System::EventHandler(this, &MyForm::buttonStart_Click);
- //
- // buttonLoeschen
- //
- this->buttonLoeschen->Location = System::Drawing::Point(544, 426);
- this->buttonLoeschen->Margin = System::Windows::Forms::Padding(4);
- this->buttonLoeschen->Name = L"buttonLoeschen";
- this->buttonLoeschen->Size = System::Drawing::Size(100, 28);
- this->buttonLoeschen->TabIndex = 6;
- this->buttonLoeschen->Text = L"Löschen";
- this->buttonLoeschen->UseVisualStyleBackColor = true;
- this->buttonLoeschen->Click += gcnew System::EventHandler(this, &MyForm::buttonLoeschen_Click);
- //
- // buttonBeenden
- //
- this->buttonBeenden->Location = System::Drawing::Point(652, 426);
- this->buttonBeenden->Margin = System::Windows::Forms::Padding(4);
- this->buttonBeenden->Name = L"buttonBeenden";
- this->buttonBeenden->Size = System::Drawing::Size(100, 28);
- this->buttonBeenden->TabIndex = 7;
- this->buttonBeenden->Text = L"Beenden";
- this->buttonBeenden->UseVisualStyleBackColor = true;
- this->buttonBeenden->Click += gcnew System::EventHandler(this, &MyForm::buttonBeenden_Click);
- //
- // label6
- //
- this->label6->Location = System::Drawing::Point(12, 402);
- this->label6->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label6->Name = L"label6";
- this->label6->Size = System::Drawing::Size(117, 25);
- this->label6->TabIndex = 8;
- this->label6->Text = L"Wiederholungen:";
- //
- // label7
- //
- this->label7->Location = System::Drawing::Point(12, 434);
- this->label7->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label7->Name = L"label7";
- this->label7->Size = System::Drawing::Size(117, 25);
- this->label7->TabIndex = 9;
- this->label7->Text = L"Dauer:";
- //
- // buttonAnimation
- //
- this->buttonAnimation->Location = System::Drawing::Point(227, 426);
- this->buttonAnimation->Margin = System::Windows::Forms::Padding(4);
- this->buttonAnimation->Name = L"buttonAnimation";
- this->buttonAnimation->Size = System::Drawing::Size(100, 28);
- this->buttonAnimation->TabIndex = 10;
- this->buttonAnimation->Text = L"Animation";
- this->buttonAnimation->UseVisualStyleBackColor = true;
- this->buttonAnimation->Click += gcnew System::EventHandler(this, &MyForm::buttonAnimation_Click);
- //
- // numericUpDownWiederholungen
- //
- this->numericUpDownWiederholungen->Location = System::Drawing::Point(137, 402);
- this->numericUpDownWiederholungen->Margin = System::Windows::Forms::Padding(4);
- this->numericUpDownWiederholungen->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 10, 0, 0, 0 });
- this->numericUpDownWiederholungen->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
- this->numericUpDownWiederholungen->Name = L"numericUpDownWiederholungen";
- this->numericUpDownWiederholungen->Size = System::Drawing::Size(63, 22);
- this->numericUpDownWiederholungen->TabIndex = 11;
- this->numericUpDownWiederholungen->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
- this->numericUpDownWiederholungen->ValueChanged += gcnew System::EventHandler(this, &MyForm::numericUpDownWiederholungen_ValueChanged);
- //
- // numericUpDownDauer
- //
- this->numericUpDownDauer->Location = System::Drawing::Point(137, 434);
- this->numericUpDownDauer->Margin = System::Windows::Forms::Padding(4);
- this->numericUpDownDauer->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 15, 0, 0, 0 });
- this->numericUpDownDauer->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
- this->numericUpDownDauer->Name = L"numericUpDownDauer";
- this->numericUpDownDauer->Size = System::Drawing::Size(63, 22);
- this->numericUpDownDauer->TabIndex = 12;
- this->numericUpDownDauer->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 1, 0, 0, 0 });
- this->numericUpDownDauer->ValueChanged += gcnew System::EventHandler(this, &MyForm::numericUpDownDauer_ValueChanged);
- //
- // animationTimer
- //
- this->animationTimer->Tick += gcnew System::EventHandler(this, &MyForm::animationTimer_Tick);
- //
- // MyForm
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(779, 469);
- this->Controls->Add(this->numericUpDownDauer);
- this->Controls->Add(this->numericUpDownWiederholungen);
- this->Controls->Add(this->buttonAnimation);
- this->Controls->Add(this->label7);
- this->Controls->Add(this->label6);
- this->Controls->Add(this->buttonBeenden);
- this->Controls->Add(this->buttonLoeschen);
- this->Controls->Add(this->buttonStart);
- this->Controls->Add(this->groesseTrackbar);
- this->Controls->Add(this->groupBox3);
- this->Controls->Add(this->groupBox2);
- this->Controls->Add(this->groupBox1);
- this->Controls->Add(this->anzeigePanel);
- this->Margin = System::Windows::Forms::Padding(4);
- this->MaximizeBox = false;
- this->MinimizeBox = false;
- this->Name = L"MyForm";
- this->Text = L"Eine Spielerei";
- this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
- this->groupBox2->ResumeLayout(false);
- this->groupBox2->PerformLayout();
- this->groupBox1->ResumeLayout(false);
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDownLinieStaerke))->EndInit();
- this->groupBox3->ResumeLayout(false);
- this->groupBox3->PerformLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->groesseTrackbar))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDownWiederholungen))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->numericUpDownDauer))->EndInit();
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void buttonBeenden_Click(System::Object^ sender, System::EventArgs^ e)
- {
- Close();
- }
- private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e)
- {
- startGroesse = 100;
- linienStaerke = 1;
- linienFarbe = Color::Black;
- hintergrundFarbe = Color::White;
- radioButtonKreis->Checked = true;
- //die Einträge für die Linienstile erzeugen
- for each (Drawing2D::DashStyle element in auswahlLinienstile)
- listBoxLinieStil->Items->Add("");
- listBoxLinieStil->SelectedIndex = 0;
- //und für die Hintergrundmuster
- for each (Drawing2D::HatchStyle element in auswahlFuellstile)
- listBoxHintergrundMuster->Items->Add("");
- listBoxHintergrundMuster->SelectedIndex = -1;
- }
- private: System::Void buttonLinieFarbe_Click(System::Object^ sender, System::EventArgs^ e)
- {
- colorDialog1->Color = panelLinieFarbeVorschau->BackColor;
- if (colorDialog1->ShowDialog() == Windows::Forms::DialogResult::OK)
- {
- panelLinieFarbeVorschau->BackColor = colorDialog1->Color;
- linienFarbe = colorDialog1->Color;
- InvalidateAnzeigePanel();
- }
- }
- private: System::Void panelLinieFarbeVorschau_DoubleClick(System::Object^ sender, System::EventArgs^ e)
- {
- buttonLinieFarbe_Click(sender, e);
- }
- private: System::Void buttonHintergrundFarbe_Click(System::Object^ sender, System::EventArgs^ e)
- {
- colorDialog1->Color = panelHintergrundFarbeVorschau->BackColor;
- if (colorDialog1->ShowDialog() == Windows::Forms::DialogResult::OK)
- {
- panelHintergrundFarbeVorschau->BackColor = colorDialog1->Color;
- hintergrundFarbe = colorDialog1->Color;
- if (radioButtonHintergrundOhne->Checked)
- {
- radioButtonHintergrundFarbe->Checked = true;
- }
- InvalidateAnzeigePanel();
- }
- }
- private: System::Void panelHintergrundFarbeVorschau_DoubleClick(System::Object^ sender, System::EventArgs^ e)
- {
- buttonHintergrundFarbe_Click(sender, e);
- }
- private: System::Void listBoxLinieStil_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
- {
- if (listBoxLinieStil->SelectedIndex >= 0)
- {
- linienStil = auswahlLinienstile[listBoxLinieStil->SelectedIndex];
- }
- else
- {
- linienStil = DashStyle::Solid;
- }
- InvalidateAnzeigePanel();
- }
- private: System::Void listBoxLinieStil_DrawItem(System::Object^ sender, System::Windows::Forms::DrawItemEventArgs^ e)
- {
- Int32 y = (e->Bounds.Top + e->Bounds.Bottom) / 2;
- e->DrawBackground();
- Pen ^boxStift = gcnew Pen(Color::Black);
- boxStift->DashStyle = auswahlLinienstile[e->Index];
- e->Graphics->DrawLine(boxStift, e->Bounds.Left + 1, y, e->Bounds.Right - 1, y);
- delete boxStift;
- }
- private: System::Void numericUpDownLinieStaerke_ValueChanged(System::Object^ sender, System::EventArgs^ e)
- {
- linienStaerke = (Int32)numericUpDownLinieStaerke->Value;
- InvalidateAnzeigePanel();
- }
- private: System::Void listBoxHintergrundMuster_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
- {
- if (listBoxHintergrundMuster->SelectedIndex >= 0)
- {
- fuellStil = auswahlFuellstile[listBoxHintergrundMuster->SelectedIndex];
- this->radioButtonHintergrundMuster->Checked = true;
- }
- else
- {
- this->radioButtonHintergrundOhne->Checked = true;
- fuellStil = auswahlFuellstile[0];
- }
- InvalidateAnzeigePanel();
- }
- private: System::Void listBoxHintergrundMuster_DrawItem(System::Object^ sender, System::Windows::Forms::DrawItemEventArgs^ e)
- {
- e->DrawBackground();
- Drawing2D::HatchBrush ^boxPinsel = gcnew Drawing2D::HatchBrush(auswahlFuellstile[e->Index], Color::Black, Color::White);
- e->Graphics->FillRectangle(boxPinsel, e->Bounds.Left + 1, e->Bounds.Top + 1, e->Bounds.Width - 1, e->Bounds.Height - 1);
- delete boxPinsel;
- }
- private: System::Void hintergrund_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
- {
- InvalidateAnzeigePanel();
- }
- private: System::Void anzeigeFigur_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
- {
- if (radioButtonLinie->Checked)
- {
- figur = Figur::Linie;
- }
- else if (radioButtonRechteck->Checked)
- {
- figur = Figur::Rechteck;
- }
- else
- {
- figur = Figur::Kreis;
- }
- InvalidateAnzeigePanel();
- }
- private: System::Void groesseTrackbar_Scroll(System::Object^ sender, System::EventArgs^ e)
- {
- //die Größe der Figur ermitteln
- switch (groesseTrackbar->Value)
- {
- case 1:
- startGroesse = 125;
- break;
- case 2:
- startGroesse = 100;
- break;
- case 3:
- default:
- startGroesse = 75;
- break;
- }
- InvalidateAnzeigePanel();
- }
- private: System::Void numericUpDownDauer_ValueChanged(System::Object^ sender, System::EventArgs^ e)
- {
- animationInterval = (Int32)numericUpDownDauer->Value * 100;
- }
- private: System::Void numericUpDownWiederholungen_ValueChanged(System::Object^ sender, System::EventArgs^ e)
- {
- animationWiederholung = (Int32)numericUpDownWiederholungen->Value;
- }
- private: System::Void buttonLoeschen_Click(System::Object^ sender, System::EventArgs^ e)
- {
- //die Zeichenfläche löschen
- Graphics^ g = this->anzeigePanel->CreateGraphics();
- g->Clear(anzeigePanel->BackColor);
- delete g;
- }
- private: System::Void buttonStart_Click(System::Object^ sender, System::EventArgs^ e)
- {
- }
- private: System::Void buttonAnimation_Click(System::Object^ sender, System::EventArgs^ e)
- {
- animationInterval = (Int32)numericUpDownDauer->Value * 100;
- animationWiederholung = (Int32)numericUpDownWiederholungen->Value;
- animationAktiv = !animationAktiv;
- animationTimer->Interval = animationInterval;
- animationTimer->Enabled = animationAktiv;
- animationLauf = animationWiederholung;
- animationMinus = false;
- animationGroesse = startGroesse;
- this->anzeigePanel->Invalidate();
- }
- private: System::Void animationTimer_Tick(System::Object^ sender, System::EventArgs^ e)
- {
- Int32 minGroesse = startGroesse;
- Int32 maxGroesse = Math::Min(this->anzeigePanel->ClientSize.Width, this->anzeigePanel->ClientSize.Height);
- if (figur == Figur::Rechteck)
- {
- minGroesse = 0;
- maxGroesse /= 2;
- }
- if (animationMinus)
- {
- animationGroesse--;
- if (animationGroesse <= minGroesse)
- {
- animationMinus = false;
- //Neuer Durchlauf?
- animationLauf--;
- if (animationLauf <= 0)
- {
- animationAktiv = false;
- animationTimer->Enabled = false;
- }
- }
- }
- else
- {
- animationGroesse++;
- if (animationGroesse >= maxGroesse)
- {
- animationMinus = true;
- }
- }
- System::Diagnostics::Debug::WriteLine("Animation: {0} / {1}", animationGroesse, animationMinus);
- this->anzeigePanel->Invalidate();
- }
- private: System::Void InvalidateAnzeigePanel()
- {
- if (!animationAktiv)
- {
- this->anzeigePanel->Invalidate();
- }
- }
- private: System::Void anzeigePanel_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e)
- {
- Graphics^ zeichenflaeche = e->Graphics;
- zeichenflaeche->SmoothingMode = SmoothingMode::AntiAlias;
- Pen^ stift = gcnew Pen(linienFarbe);
- SolidBrush^ pinsel = gcnew SolidBrush(hintergrundFarbe);
- stift->Width = linienStaerke;
- stift->DashStyle = linienStil;
- // Zeichenrechteck bestimmen, Vorschau fix / Animation fliessend
- Int32 offset = startGroesse;
- if (animationAktiv)
- {
- offset = animationGroesse;
- }
- Rectangle zeichenRectangle = Rectangle::Inflate(anzeigePanel->ClientRectangle, -offset, -offset);
- System::Diagnostics::Debug::WriteLine("Größe: {0}", zeichenRectangle);
- // Figur zeichnen
- switch (figur)
- {
- case Figur::Kreis:
- default:
- if (radioButtonHintergrundFarbe->Checked)
- {
- zeichenflaeche->FillEllipse(pinsel, zeichenRectangle);
- }
- else if (radioButtonHintergrundMuster->Checked)
- {
- Drawing2D::HatchBrush ^musterPinsel = gcnew Drawing2D::HatchBrush(fuellStil, linienFarbe, hintergrundFarbe);
- zeichenflaeche->FillEllipse(musterPinsel, zeichenRectangle);
- delete musterPinsel;
- }
- zeichenflaeche->DrawEllipse(stift, zeichenRectangle);
- break;
- case Figur::Rechteck:
- if (radioButtonHintergrundFarbe->Checked)
- {
- zeichenflaeche->FillRectangle(pinsel, zeichenRectangle);
- }
- else if (radioButtonHintergrundMuster->Checked)
- {
- Drawing2D::HatchBrush ^musterPinsel = gcnew Drawing2D::HatchBrush(fuellStil, linienFarbe, hintergrundFarbe);
- zeichenflaeche->FillRectangle(musterPinsel, zeichenRectangle);
- delete musterPinsel;
- }
- zeichenflaeche->DrawRectangle(stift, zeichenRectangle);
- break;
- case Figur::Linie:
- Int32 center = (zeichenRectangle.Top + zeichenRectangle.Bottom - linienStaerke) / 2;
- zeichenflaeche->DrawLine(stift,
- Point(zeichenRectangle.Left, center),
- Point(zeichenRectangle.Right, center));
- break;
- }
- //Stift und Pinsel löschen
- delete stift;
- delete pinsel;
- }
- };
- }
Codetags und Spoiler eingefügt. ~Trade
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Trade“ ()