Visual C++ .NET/2D/TextureBrush

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

TextureBrush Demo

<source lang="csharp">

 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;
 public ref class Form1 : public System::Windows::Forms::Form
 {
 public:
   Form1(void)
   {
           this->SuspendLayout();
           this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
           this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
           this->ClientSize = System::Drawing::Size(292, 273);
           this->Name = L"Form1";
           this->Text = L"Texture Brush";
           this->Paint += 
               gcnew System::Windows::Forms::PaintEventHandler(this, 
                                                        &Form1::Form1_Paint);
           this->ResumeLayout(false);
       }
       System::Void Form1_Paint(System::Object^ sender, 
                                System::Windows::Forms::PaintEventArgs^ e)
       {
           // Load Image
           Image^ bimage = gcnew Bitmap("Images\\CLICppCover.gif");
           // Create brush
           TextureBrush^ tbsh = gcnew TextureBrush(bimage, 
                                                   WrapMode::TileFlipXY);
           // Translate brush to same start location as rectangle
           tbsh->TranslateTransform(25,25);
           // Fill rectangle with brush
           e->Graphics->FillRectangle(tbsh, 25, 25, 250, 250);
       }
 };

[STAThreadAttribute] int main(array<System::String ^> ^args) {

 Application::Run(gcnew Form1());
 return 0;

}

 </source>