#pragma once


namespace Zeichenwerkzeuge {

	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::Text;
   using namespace System::Drawing::Drawing2D;

	/// <summary>
	/// Zusammenfassung für Form1
	///
	/// Warnung: Wenn Sie den Namen dieser Klasse ändern, müssen Sie auch
	///          die Ressourcendateiname-Eigenschaft für das Tool zur Kompilierung verwalteter Ressourcen ändern,
	///          das allen RESX-Dateien zugewiesen ist, von denen diese Klasse abhängt.
	///          Anderenfalls können die Designer nicht korrekt mit den lokalisierten Ressourcen
	///          arbeiten, die diesem Formular zugewiesen sind.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
   private:
      array<int>^ hsStyles;
      array<String^>^ hsNames;
      HatchBrush^ hsBrush;

	public:
		Form1(void)
		{
			InitializeComponent();

         // Schraffuren laden
         hsStyles = safe_cast<array<int>>(Enum::GetValues(HatchStyle::typeid));
         hsNames = safe_cast<array<String^>>(Enum::GetNames(HatchStyle::typeid));
         comboBox1->DataSource = hsNames;
         hsBrush = nullptr;
		}

	protected:
		/// <summary>
		/// Verwendete Ressourcen bereinigen.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
   private: System::Windows::Forms::TabControl^  tabControl1;
   private: System::Windows::Forms::TabPage^  tab_Pens;
   private: System::Windows::Forms::Label^  label17;
   private: System::Windows::Forms::Label^  label16;
   private: System::Windows::Forms::Label^  label15;
   private: System::Windows::Forms::TabPage^  tab_Brushes;
   private: System::Windows::Forms::TableLayoutPanel^  tableLayoutPanel1;
   private: System::Windows::Forms::Panel^  tbl_panel1;
   private: System::Windows::Forms::Panel^  tbl_panel1_sub;
   private: System::Windows::Forms::Label^  tbl_label1;
   private: System::Windows::Forms::Panel^  tbl_panel2;
   private: System::Windows::Forms::Label^  label18;
   private: System::Windows::Forms::Panel^  tbl_panel3;
   private: System::Windows::Forms::ComboBox^  comboBox1;
   private: System::Windows::Forms::Label^  label19;
   private: System::Windows::Forms::Panel^  tbl_panel4;
   private: System::Windows::Forms::Label^  label20;
   private: System::Windows::Forms::Panel^  tbl_panel5;
   private: System::Windows::Forms::Label^  label21;

	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)
		{
         System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
         this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
         this->tab_Pens = (gcnew System::Windows::Forms::TabPage());
         this->label17 = (gcnew System::Windows::Forms::Label());
         this->label16 = (gcnew System::Windows::Forms::Label());
         this->label15 = (gcnew System::Windows::Forms::Label());
         this->tab_Brushes = (gcnew System::Windows::Forms::TabPage());
         this->tableLayoutPanel1 = (gcnew System::Windows::Forms::TableLayoutPanel());
         this->tbl_panel1 = (gcnew System::Windows::Forms::Panel());
         this->tbl_panel1_sub = (gcnew System::Windows::Forms::Panel());
         this->tbl_label1 = (gcnew System::Windows::Forms::Label());
         this->tbl_panel2 = (gcnew System::Windows::Forms::Panel());
         this->label18 = (gcnew System::Windows::Forms::Label());
         this->tbl_panel3 = (gcnew System::Windows::Forms::Panel());
         this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
         this->label19 = (gcnew System::Windows::Forms::Label());
         this->tbl_panel4 = (gcnew System::Windows::Forms::Panel());
         this->label20 = (gcnew System::Windows::Forms::Label());
         this->tbl_panel5 = (gcnew System::Windows::Forms::Panel());
         this->label21 = (gcnew System::Windows::Forms::Label());
         this->tabControl1->SuspendLayout();
         this->tab_Pens->SuspendLayout();
         this->tab_Brushes->SuspendLayout();
         this->tableLayoutPanel1->SuspendLayout();
         this->tbl_panel1->SuspendLayout();
         this->tbl_panel2->SuspendLayout();
         this->tbl_panel3->SuspendLayout();
         this->tbl_panel4->SuspendLayout();
         this->tbl_panel5->SuspendLayout();
         this->SuspendLayout();
         // 
         // tabControl1
         // 
         this->tabControl1->Controls->Add(this->tab_Pens);
         this->tabControl1->Controls->Add(this->tab_Brushes);
         this->tabControl1->Dock = System::Windows::Forms::DockStyle::Fill;
         this->tabControl1->Location = System::Drawing::Point(0, 0);
         this->tabControl1->Name = L"tabControl1";
         this->tabControl1->SelectedIndex = 0;
         this->tabControl1->Size = System::Drawing::Size(643, 545);
         this->tabControl1->TabIndex = 1;
         // 
         // tab_Pens
         // 
         this->tab_Pens->Controls->Add(this->label17);
         this->tab_Pens->Controls->Add(this->label16);
         this->tab_Pens->Controls->Add(this->label15);
         this->tab_Pens->Location = System::Drawing::Point(4, 22);
         this->tab_Pens->Name = L"tab_Pens";
         this->tab_Pens->Size = System::Drawing::Size(635, 519);
         this->tab_Pens->TabIndex = 2;
         this->tab_Pens->Text = L"Stifte";
         this->tab_Pens->UseVisualStyleBackColor = true;
         this->tab_Pens->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::tab_Pens_Paint);
         // 
         // label17
         // 
         this->label17->AutoSize = true;
         this->label17->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
            static_cast<System::Byte>(0)));
         this->label17->Location = System::Drawing::Point(20, 258);
         this->label17->Name = L"label17";
         this->label17->Size = System::Drawing::Size(134, 15);
         this->label17->TabIndex = 2;
         this->label17->Text = L"Verbindungspunkte:";
         // 
         // label16
         // 
         this->label16->AutoSize = true;
         this->label16->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
            static_cast<System::Byte>(0)));
         this->label16->Location = System::Drawing::Point(338, 50);
         this->label16->Name = L"label16";
         this->label16->Size = System::Drawing::Size(85, 15);
         this->label16->TabIndex = 1;
         this->label16->Text = L"Linientypen:";
         // 
         // label15
         // 
         this->label15->AutoSize = true;
         this->label15->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
            static_cast<System::Byte>(0)));
         this->label15->Location = System::Drawing::Point(20, 50);
         this->label15->Name = L"label15";
         this->label15->Size = System::Drawing::Size(97, 15);
         this->label15->TabIndex = 0;
         this->label15->Text = L"Linien-Enden:";
         // 
         // tab_Brushes
         // 
         this->tab_Brushes->Controls->Add(this->tableLayoutPanel1);
         this->tab_Brushes->Location = System::Drawing::Point(4, 22);
         this->tab_Brushes->Name = L"tab_Brushes";
         this->tab_Brushes->Size = System::Drawing::Size(635, 519);
         this->tab_Brushes->TabIndex = 3;
         this->tab_Brushes->Text = L"Pinsel";
         this->tab_Brushes->UseVisualStyleBackColor = true;
         // 
         // tableLayoutPanel1
         // 
         this->tableLayoutPanel1->ColumnCount = 3;
         this->tableLayoutPanel1->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, 
            33.33333F)));
         this->tableLayoutPanel1->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, 
            33.33333F)));
         this->tableLayoutPanel1->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, 
            33.33333F)));
         this->tableLayoutPanel1->Controls->Add(this->tbl_panel1, 0, 0);
         this->tableLayoutPanel1->Controls->Add(this->tbl_panel2, 1, 0);
         this->tableLayoutPanel1->Controls->Add(this->tbl_panel3, 2, 0);
         this->tableLayoutPanel1->Controls->Add(this->tbl_panel4, 0, 1);
         this->tableLayoutPanel1->Controls->Add(this->tbl_panel5, 1, 1);
         this->tableLayoutPanel1->Dock = System::Windows::Forms::DockStyle::Fill;
         this->tableLayoutPanel1->Location = System::Drawing::Point(0, 0);
         this->tableLayoutPanel1->Name = L"tableLayoutPanel1";
         this->tableLayoutPanel1->RowCount = 2;
         this->tableLayoutPanel1->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 50)));
         this->tableLayoutPanel1->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 50)));
         this->tableLayoutPanel1->Size = System::Drawing::Size(635, 519);
         this->tableLayoutPanel1->TabIndex = 0;
         // 
         // tbl_panel1
         // 
         this->tbl_panel1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
         this->tbl_panel1->Controls->Add(this->tbl_panel1_sub);
         this->tbl_panel1->Controls->Add(this->tbl_label1);
         this->tbl_panel1->Dock = System::Windows::Forms::DockStyle::Fill;
         this->tbl_panel1->Location = System::Drawing::Point(3, 3);
         this->tbl_panel1->Name = L"tbl_panel1";
         this->tbl_panel1->Size = System::Drawing::Size(205, 253);
         this->tbl_panel1->TabIndex = 0;
         this->tbl_panel1->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::tbl_panel1_Paint);
         // 
         // tbl_panel1_sub
         // 
         this->tbl_panel1_sub->Location = System::Drawing::Point(21, 76);
         this->tbl_panel1_sub->Name = L"tbl_panel1_sub";
         this->tbl_panel1_sub->Size = System::Drawing::Size(162, 150);
         this->tbl_panel1_sub->TabIndex = 1;
         this->tbl_panel1_sub->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::tbl_panel1_sub_MouseMove);
         // 
         // tbl_label1
         // 
         this->tbl_label1->AutoSize = true;
         this->tbl_label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Underline)), 
            System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
         this->tbl_label1->Location = System::Drawing::Point(6, 4);
         this->tbl_label1->Name = L"tbl_label1";
         this->tbl_label1->Size = System::Drawing::Size(67, 13);
         this->tbl_label1->TabIndex = 0;
         this->tbl_label1->Text = L"SolidBrush";
         // 
         // tbl_panel2
         // 
         this->tbl_panel2->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
         this->tbl_panel2->Controls->Add(this->label18);
         this->tbl_panel2->Dock = System::Windows::Forms::DockStyle::Fill;
         this->tbl_panel2->Location = System::Drawing::Point(214, 3);
         this->tbl_panel2->Name = L"tbl_panel2";
         this->tbl_panel2->Size = System::Drawing::Size(205, 253);
         this->tbl_panel2->TabIndex = 1;
         this->tbl_panel2->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::tbl_panel2_Paint);
         // 
         // label18
         // 
         this->label18->AutoSize = true;
         this->label18->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Underline)), 
            System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
         this->label18->Location = System::Drawing::Point(3, 4);
         this->label18->Name = L"label18";
         this->label18->Size = System::Drawing::Size(82, 13);
         this->label18->TabIndex = 1;
         this->label18->Text = L"TextureBrush";
         // 
         // tbl_panel3
         // 
         this->tbl_panel3->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
         this->tbl_panel3->Controls->Add(this->comboBox1);
         this->tbl_panel3->Controls->Add(this->label19);
         this->tbl_panel3->Dock = System::Windows::Forms::DockStyle::Fill;
         this->tbl_panel3->Location = System::Drawing::Point(425, 3);
         this->tbl_panel3->Name = L"tbl_panel3";
         this->tbl_panel3->Size = System::Drawing::Size(207, 253);
         this->tbl_panel3->TabIndex = 2;
         this->tbl_panel3->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::tbl_panel3_Paint);
         // 
         // comboBox1
         // 
         this->comboBox1->FormattingEnabled = true;
         this->comboBox1->Location = System::Drawing::Point(19, 76);
         this->comboBox1->Name = L"comboBox1";
         this->comboBox1->Size = System::Drawing::Size(171, 21);
         this->comboBox1->TabIndex = 3;
         this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox1_SelectedIndexChanged);
         // 
         // label19
         // 
         this->label19->AutoSize = true;
         this->label19->BackColor = System::Drawing::Color::White;
         this->label19->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Underline)), 
            System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
         this->label19->Location = System::Drawing::Point(3, 4);
         this->label19->Name = L"label19";
         this->label19->Size = System::Drawing::Size(73, 13);
         this->label19->TabIndex = 2;
         this->label19->Text = L"HatchBrush";
         // 
         // tbl_panel4
         // 
         this->tbl_panel4->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
         this->tbl_panel4->Controls->Add(this->label20);
         this->tbl_panel4->Dock = System::Windows::Forms::DockStyle::Fill;
         this->tbl_panel4->Location = System::Drawing::Point(3, 262);
         this->tbl_panel4->Name = L"tbl_panel4";
         this->tbl_panel4->Size = System::Drawing::Size(205, 254);
         this->tbl_panel4->TabIndex = 3;
         this->tbl_panel4->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::tbl_panel4_Paint);
         // 
         // label20
         // 
         this->label20->AutoSize = true;
         this->label20->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Underline)), 
            System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
         this->label20->Location = System::Drawing::Point(6, 9);
         this->label20->Name = L"label20";
         this->label20->Size = System::Drawing::Size(122, 13);
         this->label20->TabIndex = 3;
         this->label20->Text = L"LinearGradientBrush";
         // 
         // tbl_panel5
         // 
         this->tbl_panel5->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
         this->tbl_panel5->Controls->Add(this->label21);
         this->tbl_panel5->Dock = System::Windows::Forms::DockStyle::Fill;
         this->tbl_panel5->Location = System::Drawing::Point(214, 262);
         this->tbl_panel5->Name = L"tbl_panel5";
         this->tbl_panel5->Size = System::Drawing::Size(205, 254);
         this->tbl_panel5->TabIndex = 4;
         this->tbl_panel5->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::tbl_panel5_Paint);
         // 
         // label21
         // 
         this->label21->AutoSize = true;
         this->label21->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Underline)), 
            System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
         this->label21->Location = System::Drawing::Point(3, 9);
         this->label21->Name = L"label21";
         this->label21->Size = System::Drawing::Size(113, 13);
         this->label21->TabIndex = 4;
         this->label21->Text = L"PathGradientBrush";
         // 
         // Form1
         // 
         this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
         this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
         this->ClientSize = System::Drawing::Size(643, 545);
         this->Controls->Add(this->tabControl1);
         this->Name = L"Form1";
         this->Text = L"Zeichenwerkzeuge";
         this->tabControl1->ResumeLayout(false);
         this->tab_Pens->ResumeLayout(false);
         this->tab_Pens->PerformLayout();
         this->tab_Brushes->ResumeLayout(false);
         this->tableLayoutPanel1->ResumeLayout(false);
         this->tbl_panel1->ResumeLayout(false);
         this->tbl_panel1->PerformLayout();
         this->tbl_panel2->ResumeLayout(false);
         this->tbl_panel2->PerformLayout();
         this->tbl_panel3->ResumeLayout(false);
         this->tbl_panel3->PerformLayout();
         this->tbl_panel4->ResumeLayout(false);
         this->tbl_panel4->PerformLayout();
         this->tbl_panel5->ResumeLayout(false);
         this->tbl_panel5->PerformLayout();
         this->ResumeLayout(false);

      }
#pragma endregion
   private: 
      //
      // Stifte
      //
      void tab_Pens_Paint(Object^  sender, PaintEventArgs^  e) 
      {
         Graphics^ gc = e->Graphics;

         Pen^ pen1 = gcnew Pen(Color::Black, 4);
         Pen^ pen2 = gcnew Pen(Color::FromArgb((int) (DateTime::Now.Ticks % 255), 
                                           (int) (DateTime::Now.Ticks % 255), 
                                           (int) (DateTime::Now.Ticks % 255)), 2);

         gc->DrawLine(pen1, 10, 10, tab_Pens->ClientSize.Width-20, 10);
         gc->DrawLine(pen2, 10, 15, tab_Pens->ClientSize.Width-20, 15);
                                    
         delete pen1;
         delete pen2;
         
         
         gc->SmoothingMode = SmoothingMode::HighQuality;
         
         // Linien-Enden
         
         Pen^ lcPen = gcnew Pen(Color::Black, 5);
         array<LineCap>^ lcStyles = safe_cast<array<LineCap>>(Enum::GetValues(LineCap::typeid));
         array<String^>^ lcNames = safe_cast<array<String^>>(Enum::GetNames(LineCap::typeid));
         
         for (int i = 1; i < lcStyles->Length-2; ++i)
         {
             lcPen->StartCap = lcStyles[i];
             lcPen->EndCap   = lcPen->StartCap;
             
             gc->DrawLine(lcPen, label15->Location.X + label15->Width +20, 
                                 label15->Location.Y + label15->Height/2 +(i-1)*20, 
                                 label15->Location.X + label15->Width +70, 
                                 label15->Location.Y + label15->Height/2 +(i-1)*20);
             gc->DrawString(lcNames[i], this->Font, Brushes::Black,
                                        (float) label15->Location.X + label15->Width +100, 
                                        (float) label15->Location.Y +(i-1)*20);
         }
         delete lcPen;

         
         // Linientypen
         
         Pen^ dsPen = gcnew Pen(Color::Black, 5);
         array<DashStyle>^ dStyles = safe_cast<array<DashStyle>>(Enum::GetValues(DashStyle::typeid));
         array<String^>^ dNames = safe_cast<array<String^>>(Enum::GetNames(DashStyle::typeid));
         
         for (int i = 0; i < dStyles->Length-1; ++i)
         {
             dsPen->DashStyle = dStyles[i];
             
             gc->DrawLine(dsPen, label16->Location.X + label16->Width +20, 
                                 label16->Location.Y + label16->Height/2 +i*20, 
                                 label16->Location.X + label16->Width +70, 
                                 label16->Location.Y + label16->Height/2 +i*20);
             gc->DrawString(dNames[i], this->Font, Brushes::Black,
                                       (float) label16->Location.X + label16->Width +100, 
                                       (float) label16->Location.Y +i*20);
         }
         delete dsPen;

         
         // Verbindungspunkte
         
         Pen^ ljPen = gcnew Pen(Color::Black, 15);
         array<LineJoin>^ ljStyles = safe_cast<array<LineJoin>>(Enum::GetValues(LineJoin::typeid));
         array<String^>^ ljNames = safe_cast<array<String^>>(Enum::GetNames(LineJoin::typeid));
         
         for (int i = 0; i < ljStyles->Length; ++i)
         {
             ljPen->LineJoin = ljStyles[i];
             
             array<Point>^ points = gcnew array<Point> {
                                          Point(label17->Location.X + label17->Width +20, label17->Location.Y + label17->Height/2 +i*50),
                                          Point(label17->Location.X + label17->Width +70, label17->Location.Y + label17->Height/2 +i*50),
                                          Point(label17->Location.X + label17->Width +20, label17->Location.Y + label17->Height/2 +i*50 + 30)
                                          };
             gc->DrawLines(ljPen, points);
         }

         ljPen->MiterLimit = 2.0F;
         
         for (int i = 0; i < ljStyles->Length; ++i)
         {
         
             array<Point>^ points = gcnew array<Point>  {
                                          Point(label17->Location.X + label17->Width +120, label17->Location.Y + label17->Height/2 +i*50),
                                          Point(label17->Location.X + label17->Width +170, label17->Location.Y + label17->Height/2 +i*50),
                                          Point(label17->Location.X + label17->Width +120, label17->Location.Y + label17->Height/2 +i*50 + 30)
                                          };
             gc->DrawLines(ljPen, points);

             gc->DrawString(ljNames[i], this->Font, Brushes::Black,
                                        (float) label17->Location.X + label17->Width +200, 
                                        (float) label17->Location.Y +i*50);
                                   
         }
         delete ljPen;


         Pen^ pen3 = gcnew Pen(Color::Black, 5);
         pen3->StartCap = LineCap::RoundAnchor;
         pen3->EndCap   = LineCap::ArrowAnchor;
         pen3->DashStyle = DashStyle::Custom;
         pen3->DashPattern = gcnew array<float> {1.5F, 0.5F};
         
         gc->DrawLine(pen3, 10, tab_Pens->ClientSize.Height -30, 
                            tab_Pens->ClientSize.Width-20, tab_Pens->ClientSize.Height -30);
                                    
         delete pen3;            
      }


      // 
      // Pinsel
      //
      void tbl_panel1_Paint(Object^  sender, PaintEventArgs^  e) 
      {
         Brush^ brush1 = gcnew SolidBrush(Color::Black);
         Brush^ brush2 = gcnew SolidBrush(Color::FromArgb((int) (DateTime::Now.Ticks % 255), 
                                                          (int) (DateTime::Now.Ticks % 255), 
                                                          (int) (DateTime::Now.Ticks % 255)));

         e->Graphics->FillRectangle(brush1, 10, 20, tbl_panel1->ClientSize.Width-20, 5);
         e->Graphics->FillRectangle(brush2, 10, 25, tbl_panel1->ClientSize.Width-20, 15);
                                    
         delete brush1;
         delete brush2;
      }
      void tbl_panel1_sub_MouseMove(Object^  sender, MouseEventArgs^  e) 
      {
         BufferedGraphicsContext^ bgc;
         BufferedGraphics^ bg;
         
         bgc = BufferedGraphicsManager::Current;
         
         bg = bgc->Allocate(tbl_panel1_sub->CreateGraphics(), tbl_panel1_sub->ClientRectangle);
         bg->Graphics->Clear(Color::White);
         bg->Graphics->FillEllipse(Brushes::CornflowerBlue, 30, 30, 
                                   tbl_panel1_sub->ClientRectangle.Width-60, 
                                   tbl_panel1_sub->ClientRectangle.Height-60); 
         
         int trans = 255 * e->X / tbl_panel1_sub->ClientSize.Width;
         int blue =  255 * e->Y / tbl_panel1_sub->ClientSize.Height;
         SolidBrush ^brush = gcnew SolidBrush(Color::FromArgb(trans, 255, 0, blue));
         bg->Graphics->FillRectangle(brush, 0, 0, 
                                     tbl_panel1_sub->ClientRectangle.Width, 
                                     tbl_panel1_sub->ClientRectangle.Height);
         
         bg->Render();
         
         delete bg;
         delete brush;
      }
      void tbl_panel2_Paint(Object^  sender, PaintEventArgs^  e) 
      {
         System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
         Image^ img = safe_cast<Image^>(resources->GetObject(L"tbl_panel2.BackgroundImage"));
         
         TextureBrush^ brush = gcnew TextureBrush(img);
         
         e->Graphics->FillRectangle(brush, tbl_panel2->ClientRectangle);
         
         delete img;
         delete brush;
      }
      void tbl_panel3_Paint(Object^  sender, PaintEventArgs^  e) 
      {
         if (hsBrush != nullptr)           
             e->Graphics->FillRectangle(hsBrush, tbl_panel3->ClientRectangle);
      }
      void comboBox1_SelectedIndexChanged(Object^  sender, EventArgs^  e) 
      {
         if (hsBrush != nullptr)  
             delete hsBrush;
                      
         hsBrush = gcnew HatchBrush( (HatchStyle) hsStyles[comboBox1->SelectedIndex], Color::Red);
         tbl_panel3->Refresh();
      }
      void tbl_panel4_Paint(Object^  sender, PaintEventArgs^  e) 
      {
         LinearGradientBrush^ brush = gcnew LinearGradientBrush(Rectangle(0,0,
                                                                           tbl_panel4->ClientSize.Width, 10),
                                                             Color::White, Color::Red, 
                                                             LinearGradientMode::Horizontal);
                                                 
         e->Graphics->FillRectangle(brush, 0, 0, tbl_panel4->ClientRectangle.Width, tbl_panel4->ClientRectangle.Height/2);        
         
         brush = gcnew LinearGradientBrush(Rectangle(0,0,
                                                     tbl_panel4->ClientSize.Width, 10),
                                                     Color::White, Color::Red, 
                                                     LinearGradientMode::Vertical);
         e->Graphics->FillRectangle(brush, 0, tbl_panel4->ClientRectangle.Height/2, tbl_panel4->ClientRectangle.Width, tbl_panel4->ClientRectangle.Height);        
         
         
         delete brush;                                                        
      }
      void tbl_panel5_Paint(Object^  sender, PaintEventArgs^  e) 
      {
         array<Point>^ triangle = gcnew array<Point> {Point(0, 0),
                                                      Point(0, 100),
                                                      Point(50, 50) };
                                           
         PathGradientBrush^ brush = gcnew PathGradientBrush(triangle);
                                                 
         brush->WrapMode = WrapMode::TileFlipX;
         
         brush->CenterPoint = Point(10, 50); 
         
         brush->CenterColor = Color::White;
         
         brush->SurroundColors = gcnew array<Color> {Color::Red,
                                                     Color::Green,
                                                     Color::Blue    };
         
         e->Graphics->FillRectangle(brush, 0, 0, tbl_panel5->ClientRectangle.Width, tbl_panel5->ClientRectangle.Height);                                                                
         delete brush;
      }
};
}

