Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- namespace cpbs13_6 {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- /// <summary>
- /// Zusammenfassung für Form1
- /// </summary>
- public ref class Form1 : public System::Windows::Forms::Form
- {
- public:
- Form1(void)
- {
- InitializeComponent();
- //
- //TODO: Konstruktorcode hier hinzufügen.
- //
- }
- protected:
- /// <summary>
- /// Verwendete Ressourcen bereinigen.
- /// </summary>
- ~Form1()
- {
- if (components)
- {
- delete components;
- }
- }
- private:
- Graphics ^zeichenflaeche;
- Color linienFarbe;
- Color hintergrundFarbe;
- //für die Linienstile
- static array <Drawing2D::DashStyle> ^linienstil = {Drawing2D::DashStyle::Dash,
- Drawing2D::DashStyle::DashDot,
- Drawing2D::DashStyle::DashDotDot,
- Drawing2D::DashStyle::Dot,
- Drawing2D::DashStyle::Solid};
- //für die Hintergrundmuster
- static array <Drawing2D::HatchStyle> ^fuellstil = {Drawing2D::HatchStyle::BackwardDiagonal,
- Drawing2D::HatchStyle::Cross,
- Drawing2D::HatchStyle::DottedGrid,
- Drawing2D::HatchStyle::ForwardDiagonal,
- Drawing2D::HatchStyle::Sphere,
- Drawing2D::HatchStyle::Vertical,
- Drawing2D::HatchStyle::Wave,
- Drawing2D::HatchStyle::ZigZag};
- private: System::Windows::Forms::Panel^ panel1;
- private: System::Windows::Forms::GroupBox^ groupBox1;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::NumericUpDown^ numericUpDownLinieStaerke;
- private: System::Windows::Forms::ListBox^ listBoxLinieStil;
- private: System::Windows::Forms::GroupBox^ groupBox2;
- private: System::Windows::Forms::Label^ label5;
- private: System::Windows::Forms::Label^ label4;
- private: System::Windows::Forms::ListBox^ listBoxHintergrundMuster;
- private: System::Windows::Forms::RadioButton^ radioButtonHintergrundMuster;
- private: System::Windows::Forms::RadioButton^ radioButtonHintergrundFarbe;
- private: System::Windows::Forms::RadioButton^ radioButtonHintergrundOhne;
- private: System::Windows::Forms::GroupBox^ groupBox3;
- private: System::Windows::Forms::RadioButton^ radioButtonLinie;
- private: System::Windows::Forms::RadioButton^ radioButtonRechteck;
- private: System::Windows::Forms::RadioButton^ radioButtonKreis;
- private: System::Windows::Forms::Button^ buttonStart;
- private: System::Windows::Forms::Button^ buttonLoeschen;
- private: System::Windows::Forms::Button^ buttonBeenden;
- private: System::Windows::Forms::TrackBar^ trackBar1;
- private: System::Windows::Forms::Panel^ panelLinieFarbeVorschau;
- private: System::Windows::Forms::Button^ buttonLinieFarbe;
- private: System::Windows::Forms::ColorDialog^ colorDialog1;
- private: System::Windows::Forms::Panel^ panelHintergrundFarbeVorschau;
- private: System::Windows::Forms::Button^ buttonHintergrundFarbe;
- private:
- /// <summary>
- /// Erforderliche Designervariable.
- /// </summary>
- System::ComponentModel::Container ^components;
- #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->panel1 = (gcnew System::Windows::Forms::Panel());
- this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
- this->panelLinieFarbeVorschau = (gcnew System::Windows::Forms::Panel());
- this->buttonLinieFarbe = (gcnew System::Windows::Forms::Button());
- this->label3 = (gcnew System::Windows::Forms::Label());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->numericUpDownLinieStaerke = (gcnew System::Windows::Forms::NumericUpDown());
- this->listBoxLinieStil = (gcnew System::Windows::Forms::ListBox());
- this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
- this->panelHintergrundFarbeVorschau = (gcnew System::Windows::Forms::Panel());
- this->label5 = (gcnew System::Windows::Forms::Label());
- this->buttonHintergrundFarbe = (gcnew System::Windows::Forms::Button());
- this->label4 = (gcnew System::Windows::Forms::Label());
- this->listBoxHintergrundMuster = (gcnew System::Windows::Forms::ListBox());
- this->radioButtonHintergrundMuster = (gcnew System::Windows::Forms::RadioButton());
- this->radioButtonHintergrundFarbe = (gcnew System::Windows::Forms::RadioButton());
- this->radioButtonHintergrundOhne = (gcnew System::Windows::Forms::RadioButton());
- this->groupBox3 = (gcnew System::Windows::Forms::GroupBox());
- this->radioButtonLinie = (gcnew System::Windows::Forms::RadioButton());
- this->radioButtonRechteck = (gcnew System::Windows::Forms::RadioButton());
- this->radioButtonKreis = (gcnew System::Windows::Forms::RadioButton());
- this->buttonStart = (gcnew System::Windows::Forms::Button());
- this->buttonLoeschen = (gcnew System::Windows::Forms::Button());
- this->buttonBeenden = (gcnew System::Windows::Forms::Button());
- this->trackBar1 = (gcnew System::Windows::Forms::TrackBar());
- this->colorDialog1 = (gcnew System::Windows::Forms::ColorDialog());
- this->groupBox1->SuspendLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDownLinieStaerke))->BeginInit();
- this->groupBox2->SuspendLayout();
- this->groupBox3->SuspendLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar1))->BeginInit();
- this->SuspendLayout();
- //
- // panel1
- //
- this->panel1->BackColor = System::Drawing::Color::White;
- this->panel1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
- this->panel1->Location = System::Drawing::Point(12, 12);
- this->panel1->Name = L"panel1";
- this->panel1->Size = System::Drawing::Size(300, 300);
- this->panel1->TabIndex = 0;
- //
- // groupBox1
- //
- this->groupBox1->Controls->Add(this->panelLinieFarbeVorschau);
- this->groupBox1->Controls->Add(this->buttonLinieFarbe);
- this->groupBox1->Controls->Add(this->label3);
- this->groupBox1->Controls->Add(this->label2);
- this->groupBox1->Controls->Add(this->label1);
- this->groupBox1->Controls->Add(this->numericUpDownLinieStaerke);
- this->groupBox1->Controls->Add(this->listBoxLinieStil);
- this->groupBox1->Location = System::Drawing::Point(326, 12);
- this->groupBox1->Name = L"groupBox1";
- this->groupBox1->Size = System::Drawing::Size(200, 111);
- this->groupBox1->TabIndex = 0;
- this->groupBox1->TabStop = false;
- this->groupBox1->Text = L"Linie";
- //
- // panelLinieFarbeVorschau
- //
- this->panelLinieFarbeVorschau->BackColor = System::Drawing::Color::Black;
- this->panelLinieFarbeVorschau->Location = System::Drawing::Point(51, 19);
- this->panelLinieFarbeVorschau->Name = L"panelLinieFarbeVorschau";
- this->panelLinieFarbeVorschau->Size = System::Drawing::Size(24, 22);
- this->panelLinieFarbeVorschau->TabIndex = 7;
- //
- // buttonLinieFarbe
- //
- this->buttonLinieFarbe->Location = System::Drawing::Point(92, 19);
- this->buttonLinieFarbe->Name = L"buttonLinieFarbe";
- this->buttonLinieFarbe->Size = System::Drawing::Size(30, 23);
- this->buttonLinieFarbe->TabIndex = 6;
- this->buttonLinieFarbe->Text = L"...";
- this->buttonLinieFarbe->UseVisualStyleBackColor = true;
- this->buttonLinieFarbe->Click += gcnew System::EventHandler(this, &Form1::buttonLinieFarbe_Click);
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Location = System::Drawing::Point(6, 85);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(41, 13);
- this->label3->TabIndex = 5;
- this->label3->Text = L"Stärke:";
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Location = System::Drawing::Point(6, 47);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(24, 13);
- this->label2->TabIndex = 4;
- this->label2->Text = L"Stil:";
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Location = System::Drawing::Point(6, 19);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(37, 13);
- this->label1->TabIndex = 3;
- this->label1->Text = L"Farbe:";
- //
- // numericUpDownLinieStaerke
- //
- this->numericUpDownLinieStaerke->Location = System::Drawing::Point(47, 83);
- 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(120, 20);
- this->numericUpDownLinieStaerke->TabIndex = 2;
- this->numericUpDownLinieStaerke->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0});
- //
- // listBoxLinieStil
- //
- this->listBoxLinieStil->DrawMode = System::Windows::Forms::DrawMode::OwnerDrawFixed;
- this->listBoxLinieStil->FormattingEnabled = true;
- this->listBoxLinieStil->Location = System::Drawing::Point(46, 47);
- this->listBoxLinieStil->Name = L"listBoxLinieStil";
- this->listBoxLinieStil->Size = System::Drawing::Size(120, 30);
- this->listBoxLinieStil->TabIndex = 1;
- this->listBoxLinieStil->DrawItem += gcnew System::Windows::Forms::DrawItemEventHandler(this, &Form1::listBoxLinieStil_DrawItem);
- //
- // groupBox2
- //
- this->groupBox2->Controls->Add(this->panelHintergrundFarbeVorschau);
- this->groupBox2->Controls->Add(this->label5);
- this->groupBox2->Controls->Add(this->buttonHintergrundFarbe);
- this->groupBox2->Controls->Add(this->label4);
- this->groupBox2->Controls->Add(this->listBoxHintergrundMuster);
- this->groupBox2->Controls->Add(this->radioButtonHintergrundMuster);
- this->groupBox2->Controls->Add(this->radioButtonHintergrundFarbe);
- this->groupBox2->Controls->Add(this->radioButtonHintergrundOhne);
- this->groupBox2->Location = System::Drawing::Point(326, 129);
- this->groupBox2->Name = L"groupBox2";
- this->groupBox2->Size = System::Drawing::Size(200, 110);
- this->groupBox2->TabIndex = 1;
- this->groupBox2->TabStop = false;
- this->groupBox2->Text = L"Hintergrund";
- //
- // panelHintergrundFarbeVorschau
- //
- this->panelHintergrundFarbeVorschau->BackColor = System::Drawing::Color::Black;
- this->panelHintergrundFarbeVorschau->Location = System::Drawing::Point(51, 41);
- this->panelHintergrundFarbeVorschau->Name = L"panelHintergrundFarbeVorschau";
- this->panelHintergrundFarbeVorschau->Size = System::Drawing::Size(24, 22);
- this->panelHintergrundFarbeVorschau->TabIndex = 9;
- //
- // label5
- //
- this->label5->AutoSize = true;
- this->label5->Location = System::Drawing::Point(6, 69);
- this->label5->Name = L"label5";
- this->label5->Size = System::Drawing::Size(24, 13);
- this->label5->TabIndex = 7;
- this->label5->Text = L"Stil:";
- //
- // buttonHintergrundFarbe
- //
- this->buttonHintergrundFarbe->Location = System::Drawing::Point(92, 42);
- this->buttonHintergrundFarbe->Name = L"buttonHintergrundFarbe";
- this->buttonHintergrundFarbe->Size = System::Drawing::Size(30, 23);
- this->buttonHintergrundFarbe->TabIndex = 8;
- this->buttonHintergrundFarbe->Text = L"...";
- this->buttonHintergrundFarbe->UseVisualStyleBackColor = true;
- this->buttonHintergrundFarbe->Click += gcnew System::EventHandler(this, &Form1::buttonHintergrundFarbe_Click);
- //
- // label4
- //
- this->label4->AutoSize = true;
- this->label4->Location = System::Drawing::Point(6, 45);
- this->label4->Name = L"label4";
- this->label4->Size = System::Drawing::Size(37, 13);
- this->label4->TabIndex = 6;
- this->label4->Text = L"Farbe:";
- //
- // listBoxHintergrundMuster
- //
- this->listBoxHintergrundMuster->DrawMode = System::Windows::Forms::DrawMode::OwnerDrawFixed;
- this->listBoxHintergrundMuster->FormattingEnabled = true;
- this->listBoxHintergrundMuster->Location = System::Drawing::Point(47, 69);
- this->listBoxHintergrundMuster->Name = L"listBoxHintergrundMuster";
- this->listBoxHintergrundMuster->Size = System::Drawing::Size(120, 30);
- this->listBoxHintergrundMuster->TabIndex = 4;
- this->listBoxHintergrundMuster->DrawItem += gcnew System::Windows::Forms::DrawItemEventHandler(this, &Form1::listBoxHintergrundMuster_DrawItem);
- //
- // radioButtonHintergrundMuster
- //
- this->radioButtonHintergrundMuster->AutoSize = true;
- this->radioButtonHintergrundMuster->Location = System::Drawing::Point(137, 19);
- this->radioButtonHintergrundMuster->Name = L"radioButtonHintergrundMuster";
- this->radioButtonHintergrundMuster->Size = System::Drawing::Size(57, 17);
- this->radioButtonHintergrundMuster->TabIndex = 2;
- this->radioButtonHintergrundMuster->Text = L"Muster";
- this->radioButtonHintergrundMuster->UseVisualStyleBackColor = true;
- //
- // radioButtonHintergrundFarbe
- //
- this->radioButtonHintergrundFarbe->AutoSize = true;
- this->radioButtonHintergrundFarbe->Location = System::Drawing::Point(70, 19);
- this->radioButtonHintergrundFarbe->Name = L"radioButtonHintergrundFarbe";
- this->radioButtonHintergrundFarbe->Size = System::Drawing::Size(52, 17);
- this->radioButtonHintergrundFarbe->TabIndex = 1;
- this->radioButtonHintergrundFarbe->Text = L"Farbe";
- this->radioButtonHintergrundFarbe->UseVisualStyleBackColor = true;
- //
- // radioButtonHintergrundOhne
- //
- this->radioButtonHintergrundOhne->AutoSize = true;
- this->radioButtonHintergrundOhne->Checked = true;
- this->radioButtonHintergrundOhne->Location = System::Drawing::Point(9, 19);
- this->radioButtonHintergrundOhne->Name = L"radioButtonHintergrundOhne";
- this->radioButtonHintergrundOhne->Size = System::Drawing::Size(49, 17);
- this->radioButtonHintergrundOhne->TabIndex = 0;
- this->radioButtonHintergrundOhne->TabStop = true;
- this->radioButtonHintergrundOhne->Text = L"ohne";
- this->radioButtonHintergrundOhne->UseVisualStyleBackColor = true;
- //
- // groupBox3
- //
- this->groupBox3->Controls->Add(this->radioButtonLinie);
- this->groupBox3->Controls->Add(this->radioButtonRechteck);
- this->groupBox3->Controls->Add(this->radioButtonKreis);
- this->groupBox3->Location = System::Drawing::Point(326, 245);
- this->groupBox3->Name = L"groupBox3";
- this->groupBox3->Size = System::Drawing::Size(200, 52);
- this->groupBox3->TabIndex = 2;
- this->groupBox3->TabStop = false;
- this->groupBox3->Text = L"Figur";
- //
- // radioButtonLinie
- //
- this->radioButtonLinie->AutoSize = true;
- this->radioButtonLinie->Location = System::Drawing::Point(137, 19);
- this->radioButtonLinie->Name = L"radioButtonLinie";
- this->radioButtonLinie->Size = System::Drawing::Size(47, 17);
- this->radioButtonLinie->TabIndex = 2;
- this->radioButtonLinie->Text = L"Linie";
- this->radioButtonLinie->UseVisualStyleBackColor = true;
- //
- // radioButtonRechteck
- //
- this->radioButtonRechteck->AutoSize = true;
- this->radioButtonRechteck->Location = System::Drawing::Point(61, 19);
- this->radioButtonRechteck->Name = L"radioButtonRechteck";
- this->radioButtonRechteck->Size = System::Drawing::Size(72, 17);
- this->radioButtonRechteck->TabIndex = 1;
- this->radioButtonRechteck->Text = L"Rechteck";
- this->radioButtonRechteck->UseVisualStyleBackColor = true;
- //
- // radioButtonKreis
- //
- this->radioButtonKreis->AutoSize = true;
- this->radioButtonKreis->Checked = true;
- this->radioButtonKreis->Location = System::Drawing::Point(9, 19);
- this->radioButtonKreis->Name = L"radioButtonKreis";
- this->radioButtonKreis->Size = System::Drawing::Size(48, 17);
- this->radioButtonKreis->TabIndex = 0;
- this->radioButtonKreis->TabStop = true;
- this->radioButtonKreis->Text = L"Kreis";
- this->radioButtonKreis->UseVisualStyleBackColor = true;
- //
- // buttonStart
- //
- this->buttonStart->Location = System::Drawing::Point(326, 347);
- this->buttonStart->Name = L"buttonStart";
- this->buttonStart->Size = System::Drawing::Size(75, 23);
- this->buttonStart->TabIndex = 4;
- this->buttonStart->Text = L"Los geht\'s";
- this->buttonStart->UseVisualStyleBackColor = true;
- this->buttonStart->Click += gcnew System::EventHandler(this, &Form1::buttonStart_Click);
- //
- // buttonLoeschen
- //
- this->buttonLoeschen->Location = System::Drawing::Point(407, 347);
- this->buttonLoeschen->Name = L"buttonLoeschen";
- this->buttonLoeschen->Size = System::Drawing::Size(75, 23);
- this->buttonLoeschen->TabIndex = 5;
- this->buttonLoeschen->Text = L"Löschen";
- this->buttonLoeschen->UseVisualStyleBackColor = true;
- this->buttonLoeschen->Click += gcnew System::EventHandler(this, &Form1::buttonLoeschen_Click);
- //
- // buttonBeenden
- //
- this->buttonBeenden->Location = System::Drawing::Point(488, 347);
- this->buttonBeenden->Name = L"buttonBeenden";
- this->buttonBeenden->Size = System::Drawing::Size(75, 23);
- this->buttonBeenden->TabIndex = 6;
- this->buttonBeenden->Text = L"Beenden";
- this->buttonBeenden->UseVisualStyleBackColor = true;
- this->buttonBeenden->Click += gcnew System::EventHandler(this, &Form1::buttonBeenden_Click);
- //
- // trackBar1
- //
- this->trackBar1->Location = System::Drawing::Point(326, 303);
- this->trackBar1->Maximum = 3;
- this->trackBar1->Minimum = 1;
- this->trackBar1->Name = L"trackBar1";
- this->trackBar1->Size = System::Drawing::Size(200, 45);
- this->trackBar1->TabIndex = 3;
- this->trackBar1->Value = 2;
- //
- // Form1
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(584, 382);
- this->Controls->Add(this->buttonLoeschen);
- this->Controls->Add(this->buttonBeenden);
- this->Controls->Add(this->buttonStart);
- this->Controls->Add(this->groupBox3);
- this->Controls->Add(this->groupBox2);
- this->Controls->Add(this->groupBox1);
- this->Controls->Add(this->panel1);
- this->Controls->Add(this->trackBar1);
- this->Name = L"Form1";
- this->Text = L"Eine Spielerei";
- this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
- this->groupBox1->ResumeLayout(false);
- this->groupBox1->PerformLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDownLinieStaerke))->EndInit();
- this->groupBox2->ResumeLayout(false);
- this->groupBox2->PerformLayout();
- this->groupBox3->ResumeLayout(false);
- this->groupBox3->PerformLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar1))->EndInit();
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void buttonBeenden_Click(System::Object^ sender, System::EventArgs^ e) {
- Close();
- }
- private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
- //die Linienfarbe auf Schwarz setzen
- linienFarbe = Color::Black;
- //und auch die Hintergrundfarbe
- hintergrundFarbe = Color::Black;
- //die Einträge für die Linienstile erzeugen
- for each (Drawing2D::DashStyle element in linienstil)
- listBoxLinieStil->Items->Add("");
- //und für die Hintergrundmuster
- for each (Drawing2D::HatchStyle element in fuellstil)
- listBoxHintergrundMuster->Items->Add("");
- //einen Handle auf die Zeichenfläche des Panels setzen
- //zeichenflaeche ist als Attribut der Klasse Form1 vereinbart
- zeichenflaeche = panel1->CreateGraphics();
- }
- private: System::Void buttonLoeschen_Click(System::Object^ sender, System::EventArgs^ e) {
- //die Zeichenfläche löschen
- zeichenflaeche->Clear(panel1->BackColor);
- }
- private: System::Void buttonStart_Click(System::Object^ sender, System::EventArgs^ e) {
- //eine lokale Variable für die Größe
- Int32 groesse;
- //einen schwarzen Stift erzeugen
- Pen ^stift = gcnew Pen(linienFarbe);
- //einen schwarzen Pinsel erzeugen
- SolidBrush ^pinsel = gcnew SolidBrush(hintergrundFarbe);
- //die Dicke des Stiftes setzen
- stift->Width=Convert::ToSingle(numericUpDownLinieStaerke->Value);
- //den Linienstil setzen
- if (listBoxLinieStil->SelectedIndex>=0)
- stift->DashStyle=linienstil[listBoxLinieStil->SelectedIndex];
- //die Größe der Figur ermitteln
- switch (trackBar1->Value) {
- case 1: groesse=125;
- break;
- case 2: groesse=100;
- break;
- case 3: groesse=75;
- break;
- }
- //Figur ermitteln
- //beim Kreis und beim Rechteck auch die Füllung überprüfen
- if (radioButtonKreis->Checked == true) {
- if (radioButtonHintergrundOhne->Checked == true)
- zeichenflaeche->DrawEllipse(stift, panel1->ClientRectangle.Left + groesse, panel1->ClientRectangle.Top + groesse, panel1->ClientRectangle.Width - (groesse*2), panel1->ClientRectangle.Height - (groesse * 2));
- if (radioButtonHintergrundFarbe->Checked == true)
- zeichenflaeche->FillEllipse(pinsel, panel1->ClientRectangle.Left + groesse, panel1->ClientRectangle.Top + groesse, panel1->ClientRectangle.Width - (groesse*2), panel1->ClientRectangle.Height - (groesse * 2));
- //soll mit Muster gezeichnet werden und ist ein Muster ausgewählt?
- if (radioButtonHintergrundMuster->Checked == true && listBoxHintergrundMuster->SelectedIndex>=0) {
- //einen neuen Pinsel für das Muster erzeugen
- //die Vordergrundfarbe kommt vom Stift, der Hintergrund ist immer weiß
- Drawing2D::HatchBrush ^musterPinsel = gcnew Drawing2D::HatchBrush(fuellstil[listBoxHintergrundMuster->SelectedIndex], stift->Color, Color::White);
- zeichenflaeche->FillEllipse(musterPinsel,panel1->ClientRectangle.Left+groesse, panel1->ClientRectangle.Top+groesse,panel1->ClientRectangle.Width-(groesse*2), panel1->ClientRectangle.Height-(groesse*2));
- delete musterPinsel;
- }
- }
- if (radioButtonRechteck->Checked == true) {
- if (radioButtonHintergrundOhne->Checked == true)
- zeichenflaeche->DrawRectangle(stift, panel1->ClientRectangle.Left + groesse, panel1->ClientRectangle.Top + groesse, panel1->ClientRectangle.Width - (groesse*2), panel1->ClientRectangle.Height - (groesse * 2));
- if (radioButtonHintergrundFarbe->Checked == true)
- zeichenflaeche->FillRectangle(pinsel, panel1->ClientRectangle.Left + groesse, panel1->ClientRectangle.Top + groesse, panel1->ClientRectangle.Width - (groesse*2), panel1->ClientRectangle.Height - (groesse * 2));
- //soll mit Muster gezeichnet werden und ist ein Muster ausgewählt?
- if (radioButtonHintergrundMuster->Checked == true && listBoxHintergrundMuster->SelectedIndex>=0) {
- //einen neuen Pinsel für das Muster erzeugen
- //die Vordergrundfarbe kommt vom Stift, der Hintergrund ist immer weiß
- Drawing2D::HatchBrush ^musterPinsel = gcnew Drawing2D::HatchBrush(fuellstil[listBoxHintergrundMuster->SelectedIndex], stift->Color, Color::White);
- zeichenflaeche->FillRectangle(musterPinsel,panel1->ClientRectangle.Left+groesse, panel1->ClientRectangle.Top+groesse,panel1->ClientRectangle.Width-(groesse*2), panel1->ClientRectangle.Height-(groesse*2));
- delete musterPinsel;
- }
- }
- if (radioButtonLinie->Checked == true)
- zeichenflaeche->DrawLine(stift, panel1->ClientRectangle.Left + groesse, panel1->ClientRectangle.Height / 2, panel1->ClientRectangle.Width - groesse, panel1->ClientRectangle.Height / 2);
- //Stift und Pinsel löschen
- delete stift;
- delete pinsel;
- }
- private: System::Void buttonLinieFarbe_Click(System::Object^ sender, System::EventArgs^ e) {
- //den Dialog zur Farbauswahl anzeigen
- if (colorDialog1->ShowDialog() == Windows::Forms::DialogResult::OK) {
- //die Hintergrundfarbe für das Panel auf die ausgewählte Farbe setzen
- panelLinieFarbeVorschau->BackColor=colorDialog1->Color;
- //und die Linienfarbe
- //linienFarbe ist ein Attribut der Klasse Form1
- linienFarbe=colorDialog1->Color;
- }
- }
- private: System::Void buttonHintergrundFarbe_Click(System::Object^ sender, System::EventArgs^ e) {
- //den Dialog zur Farbauswahl anzeigen
- if (colorDialog1->ShowDialog() == Windows::Forms::DialogResult::OK) {
- //die Hintergrundfarbe für das Panel auf die ausgewählte Farbe setzen
- panelHintergrundFarbeVorschau->BackColor=colorDialog1->Color;
- //und die eigentliche Hintergrundfarbe
- //hintergrundFarbe ist ein Attribut der Klasse Form1
- hintergrundFarbe=colorDialog1->Color;
- //die Auswahl Farbe aktivieren
- radioButtonHintergrundFarbe->Checked=true;
- }
- }
- private: System::Void listBoxLinieStil_DrawItem(System::Object^ sender, System::Windows::Forms::DrawItemEventArgs^ e) {
- //eine lokale Variable für die Berechnung der Mitte
- Int32 Y;
- //ein neuer lokaler Stift
- Pen ^boxStift = gcnew Pen(Color::Black);
- //die Mitte berechnen
- Y=(e->Bounds.Top + e->Bounds.Bottom)/2;
- //den Hintergrund zeichnen
- e->DrawBackground();
- //und die Linie
- boxStift->DashStyle=linienstil[e->Index];
- e->Graphics->DrawLine(boxStift, e->Bounds.Left+1, Y, e->Bounds.Right-1, Y);
- //den Stift löschen
- delete boxStift;
- }
- private: System::Void listBoxHintergrundMuster_DrawItem(System::Object^ sender, System::Windows::Forms::DrawItemEventArgs^ e) {
- //ein neuer lokaler Pinsel für das Muster
- Drawing2D::HatchBrush ^boxPinsel = gcnew Drawing2D::HatchBrush(fuellstil[e->Index], Color::Black, Color::White);
- //den Hintergrund zeichnen
- e->DrawBackground();
- //und das Rechteck
- e->Graphics->FillRectangle(boxPinsel, e->Bounds.Left+1, e->Bounds.Top+1, e->Bounds.Width-1, e->Bounds.Height-1);
- //den Pinsel löschen
- delete boxPinsel;
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement