代码改变世界

C#Brush的使用(转载)

2010-03-01 20:09  爱研究源码的javaer  阅读(1636)  评论(0编辑  收藏  举报

C#brush的使用

private void Form1_Paint(object sender, PaintEventArgs e)
        {
     // (实心刷)
                  Rectangle  myrect1 = new Rectangle(20, 80, 250, 100);
                 SolidBrush  mysbrush1 = new SolidBrush(Color.DarkOrchid);                 
                 SolidBrush  mysbrush2 = new SolidBrush(Color.Aquamarine);      
                  SolidBrush  mysbrush3 = new SolidBrush(Color.DarkOrange);

     //(梯度刷)
                  LinearGradientBrush  mylbrush5 = new LinearGradientBrush(rect1,
                  Color.DarkOrange, Color.Aquamarine,
                  LinearGradientMode.BackwardDiagonal);

                 //(阴影刷)
                 HatchBrush  myhbrush5 = new HatchBrush(HatchStyle.DiagonalCross,
                  Color.DarkOrange, Color.Aquamarine);
                  HatchBrush  myhbrush2 = new HatchBrush(HatchStyle.DarkVertical,
                  Color.DarkOrange, Color.Aquamarine);
                  HatchBrush  myhbrush3 = new HatchBrush(HatchStyle.LargeConfetti,
                  Color.DarkOrange, Color.Aquamarine);

                 //(纹理刷)
                  TextureBrush textureBrush = new TextureBrush(new Bitmap(@"e:\123.jpg"));
               
   e.Graphics.FillRectangle(mysbrush1, rect1);         // (实心刷)
       e.Graphics.FillRectangle(mylbrush1, rect1);            //(梯度刷)

              e.Graphics.FillRectangle(myhbrush1, rect1);             //(阴影刷)      
     
            e.Graphics.FillRectangle(mytextureBrush, rect1);       //(纹理刷)

 
        }

转自:http://www.cnblogs.com/rentiansheng/archive/2010/03/01/1675787.html