1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2005 Novell, Inc.
23 // Alan McGovern (alan.mcgovern@gmail.com)
30 namespace System.Windows.Forms
32 public class DrawListViewItemEventArgs : EventArgs
34 #region Private Fields
36 private Rectangle bounds;
37 private bool drawDefault;
38 private Graphics graphics;
39 private ListViewItem item;
40 private int itemIndex;
41 private ListViewItemStates state;
43 #endregion Private Fields
48 public bool DrawDefault {
49 get { return drawDefault; }
50 set { drawDefault = value; }
53 public Rectangle Bounds {
54 get { return bounds; }
57 public Graphics Graphics {
58 get { return graphics; }
61 public ListViewItem Item {
65 public int ItemIndex {
66 get { return itemIndex; }
69 public ListViewItemStates State {
78 public DrawListViewItemEventArgs (Graphics graphics, ListViewItem item,
79 Rectangle bounds, int itemIndex, ListViewItemStates state)
81 this.graphics = graphics;
84 this.itemIndex = itemIndex;
88 #endregion Constructors
91 #region Public Methods
93 public void DrawBackground ()
95 graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (item.BackColor), bounds);
98 public void DrawFocusRectangle ()
100 if ((state & ListViewItemStates.Focused) != 0)
101 ThemeEngine.Current.CPDrawFocusRectangle (graphics, bounds, item.ListView.ForeColor, item.ListView.BackColor);
104 public void DrawText ()
106 DrawText (TextFormatFlags.Default);
109 public void DrawText (TextFormatFlags flags)
111 TextRenderer.DrawText (graphics, item.Text, item.Font, bounds, item.ForeColor, flags);
114 #endregion Public Methods