Hatch Brush Array (HatchStyle minimum and maximum values) : HatchBrush « 2D « C# / CSharp Tutorial






using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
   
class HatchBrushArray: Form
{
     const int iSize = 32, iMargin = 8;
     const int iMin = 0, iMax = 52;  // 
   
     public static void Main()
     {
          Application.Run(new HatchBrushArray());
     }
     public HatchBrushArray()
     {
          ResizeRedraw = true; 
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
     }       
     protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
     {
          for (HatchStyle hs = (HatchStyle)iMin; hs <= (HatchStyle)iMax; hs++)
          {
               HatchBrush hbrush = 
                              new HatchBrush(hs, Color.White, Color.Black);
               int y = (int)hs / 8;
               int x = (int)hs % 8;
   
               grfx.FillRectangle(hbrush, iMargin + x * (iMargin + iSize), 
                                          iMargin + y * (iMargin + iSize), 
                                          iSize, iSize);
          }
     }
}








27.29.HatchBrush
27.29.1.new HatchBrush(HatchStyle.Cross,Color.White,Color.Black)
27.29.2.new HatchBrush
27.29.3.HatchBrush StyleHatchBrush Style
27.29.4.Create HatchBrush: style and colorCreate HatchBrush: style and color
27.29.5.HatchStyle.Plaid
27.29.6.HatchStyle.ZigZag
27.29.7.HatchStyle.LargeConfetti
27.29.8.Hatch Brush Array (HatchStyle minimum and maximum values)