ControlPaint

ControlPaint

System. Windows .Forms (system. windows .forms.dll) sealed class

This class encapsulates a variety of static methods to help you paint your own custom controls and maintain consistency with the appearance of the rest of the UI. Unfortunately, none of these methods support Windows XP themes.

Most common UI elements are supported, including caption buttons, resizing grips, buttons , edit fields, comboboxes , various kinds of flat and 3D borders and frames , focus rectangles, and grids.

In addition, there is a class of methods that will automatically generate the Light() , LightLight() , Dark() , and DarkDark() versions of a specific System.Drawing. Color . If your control is, say, Red instead of Control , you don't want to use System.Drawing.SystemColors.ControlDark to paint a dark edge. Instead, use Dark() to retrieve a dark version of Red instead.

Probably the most frequently asked question in Windows.Forms development is "How do I draw a rubberband box/line?" ControlPaint offers DrawReversibleLine() , DrawReversibleFrame() , and FillReversibleRectangle() . Again, it is worth noting that Windows XP doesn't use XOR-ed rectangles any more, because of their limitations when painting over a mid-level color, so you should consider an alternative drawing strategy. One possible approach is to paint a semitransparent rectangle to represent your selection instead, calling Control.Invalidate() to restore the previous background between updates. This works best (and flicker free!) if your selection rectangle is painted as part of your Control.OnPaint() override, and your control has ControlStyles.DoubleBuffer set.

 public sealed class  ControlPaint  {  // Public Static Properties  public static Color  ContrastControlDark  {get; }  // Public Static Methods  public static IntPtr  CreateHBitmap16Bit  (System.Drawing.Bitmap  bitmap  , System.Drawing.Color  background  );    public static IntPtr  CreateHBitmapColorMask  (System.Drawing.Bitmap  bitmap  , IntPtr  monochromeMask  );    public static IntPtr  CreateHBitmapTransparencyMask  (System.Drawing.Bitmap  bitmap  );    public static Color  Dark  (System.Drawing.Color  baseColor  );    public static Color  Dark  (System.Drawing.Color  baseColor  , float  percOfDarkDark  );    public static Color  DarkDark  (System.Drawing.Color  baseColor  );    public static void  DrawBorder  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  bounds  ,          System.Drawing.Color  color  , ButtonBorderStyle  style  );    public static void  DrawBorder  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  bounds  ,          System.Drawing.Color  leftColor  , int  leftWidth  , ButtonBorderStyle  leftStyle  , System.Drawing.Color  topColor  , int  topWidth  ,         ButtonBorderStyle  topStyle  , System.Drawing.Color  rightColor  , int  rightWidth  , ButtonBorderStyle  rightStyle  ,          System.Drawing.Color  bottomColor  , int  bottomWidth  , ButtonBorderStyle  bottomStyle  );    public static void  DrawBorder3D  (System.Drawing.Graphics  graphics  , int  x  , int  y  , int  width  , int  height  );    public static void  DrawBorder3D  (System.Drawing.Graphics  graphics  , int  x  , int  y  , int  width  , int  height  , Border3DStyle  style  );    public static void  DrawBorder3D  (System.Drawing.Graphics  graphics  , int  x  , int  y  , int  width  , int  height  , Border3DStyle  style  ,         Border3DSide  sides  );    public static void  DrawBorder3D  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  );    public static void  DrawBorder3D  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,          Border3DStyle  style  );    public static void  DrawBorder3D  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,          Border3DStyle  style  , Border3DSide  sides  );    public static void  DrawButton  (System.Drawing.Graphics  graphics  , int  x  , int  y  , int  width  , int  height  , ButtonState  state  );    public static void  DrawButton  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,          ButtonState  state  );    public static void  DrawCaptionButton  (System.Drawing.Graphics  graphics  , int  x  , int  y  , int  width  , int  height  ,          CaptionButton  button  , ButtonState  state  );    public static void  DrawCaptionButton  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,          CaptionButton  button  , ButtonState  state  );    public static void  DrawCheckBox  (System.Drawing.Graphics  graphics  , int  x  , int  y  , int  width  , int  height  , ButtonState  state  );    public static void  DrawCheckBox  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,          ButtonState  state  );    public static void  DrawComboButton  (System.Drawing.Graphics  graphics  , int  x  , int  y  , int  width  , int  height  ,          ButtonState  state  );    public static void  DrawComboButton  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,         ButtonState  state  );    public static void  DrawContainerGrabHandle  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  bounds  );    public static void  DrawFocusRectangle  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  );    public static void  DrawFocusRectangle  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,          System.Drawing.Color  foreColor  , System.Drawing.Color  backColor  );    public static void  DrawGrabHandle  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,          bool  primary  , bool  enabled  );    public static void  DrawGrid  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  area  ,         System.Drawing.Size  pixelsBetweenDots  , System.Drawing.Color  backColor  );    public static void  DrawImageDisabled  (System.Drawing.Graphics  graphics  , System.Drawing.Image  image  , int  x  , int  y  ,          System.Drawing.Color  background  );    public static void  DrawLockedFrame  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,          bool  primary  );    public static void  DrawMenuGlyph  (System.Drawing.Graphics  graphics  , int  x  , int  y  , int  width  , int  height  , MenuGlyph  glyph  );    public static void  DrawMenuGlyph  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,          MenuGlyph  glyph  );    public static void  DrawMixedCheckBox  (System.Drawing.Graphics  graphics  , int  x  , int  y  , int  width  , int  height  ,          ButtonState  state  );    public static void  DrawMixedCheckBox  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,          ButtonState  state  );    public static void  DrawRadioButton  (System.Drawing.Graphics  graphics  , int  x  , int  y  , int  width  , int  height  ,          ButtonState  state  );    public static void  DrawRadioButton  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,         ButtonState  state  );    public static void  DrawReversibleFrame  (System.Drawing.Rectangle  rectangle  , System.Drawing.Color  backColor  ,         FrameStyle  style  );    public static void  DrawReversibleLine  (System.Drawing.Point  start  , System.Drawing.Point  end  ,         System.Drawing.Color  backColor  );    public static void  DrawScrollButton  (System.Drawing.Graphics  graphics  , int  x  , int  y  , int  width  , int  height  ,          ScrollButton  button  , ButtonState  state  );    public static void  DrawScrollButton  (System.Drawing.Graphics  graphics  , System.Drawing.Rectangle  rectangle  ,         ScrollButton  button  , ButtonState  state  );    public static void  DrawSelectionFrame  (System.Drawing.Graphics  graphics  , bool  active  ,          System.Drawing.Rectangle  outsideRect  , System.Drawing.Rectangle  insideRect  , System.Drawing.Color  backColor  );    public static void  DrawSizeGrip  (System.Drawing.Graphics  graphics  , System.Drawing.Color  backColor  , int  x  , int  y  ,          int  width  , int  height  );    public static void  DrawSizeGrip  (System.Drawing.Graphics  graphics  , System.Drawing.Color  backColor  ,         System.Drawing.Rectangle  bounds  );    public static void  DrawStringDisabled  (System.Drawing.Graphics  graphics  , string  s  , System.Drawing.Font  font  ,         System.Drawing.Color  color  , System.Drawing.RectangleF  layoutRectangle  , System.Drawing.StringFormat  format  );    public static void  FillReversibleRectangle  (System.Drawing.Rectangle  rectangle  , System.Drawing.Color  backColor  );    public static Color  Light  (System.Drawing.Color  baseColor  );    public static Color  Light  (System.Drawing.Color  baseColor  , float  percOfLightLight  );    public static Color  LightLight  (System.Drawing.Color  baseColor  ); } 


. Net Windows Forms in a Nutshell
.NET Windows Forms in a Nutshell
ISBN: 0596003382
EAN: 2147483647
Year: 2002
Pages: 794

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net