2 // ToolStripItemTextRenderEventArgs.cs
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 // Copyright (c) 2006 Jonathan Pobst
26 // Jonathan Pobst (monkey@jpobst.com)
32 namespace System
.Windows
.Forms
34 public class ToolStripItemTextRenderEventArgs
: ToolStripItemRenderEventArgs
37 private Color text_color
;
38 private ToolStripTextDirection text_direction
;
39 private Font text_font
;
40 private TextFormatFlags text_format
;
41 private Rectangle text_rectangle
;
43 #region Public Constructors
44 public ToolStripItemTextRenderEventArgs (Graphics g
, ToolStripItem item
, string text
, Rectangle textRectangle
, Color textColor
, Font textFont
, ContentAlignment textAlign
)
48 this.text_rectangle
= textRectangle
;
49 this.text_color
= textColor
;
50 this.text_font
= textFont
;
51 this.text_direction
= item
.TextDirection
;
54 case ContentAlignment
.BottomCenter
:
55 this.text_format
= TextFormatFlags
.Bottom
| TextFormatFlags
.HorizontalCenter
;
57 case ContentAlignment
.BottomLeft
:
58 this.text_format
= TextFormatFlags
.Bottom
| TextFormatFlags
.Left
;
60 case ContentAlignment
.BottomRight
:
61 this.text_format
= TextFormatFlags
.Bottom
| TextFormatFlags
.Right
;
63 case ContentAlignment
.MiddleCenter
:
64 this.text_format
= TextFormatFlags
.VerticalCenter
| TextFormatFlags
.HorizontalCenter
;
66 case ContentAlignment
.MiddleLeft
:
68 this.text_format
= (TextFormatFlags
.VerticalCenter
| TextFormatFlags
.Left
);
70 case ContentAlignment
.MiddleRight
:
71 this.text_format
= TextFormatFlags
.VerticalCenter
| TextFormatFlags
.Right
;
73 case ContentAlignment
.TopCenter
:
74 this.text_format
= TextFormatFlags
.Top
| TextFormatFlags
.HorizontalCenter
;
76 case ContentAlignment
.TopLeft
:
77 this.text_format
= TextFormatFlags
.Top
| TextFormatFlags
.Left
;
79 case ContentAlignment
.TopRight
:
80 this.text_format
= TextFormatFlags
.Top
| TextFormatFlags
.Right
;
84 if ((Application
.KeyboardCapture
== null || !ToolStripManager
.ActivatedByKeyboard
) && !SystemInformation
.MenuAccessKeysUnderlined
)
85 this.text_format
|= TextFormatFlags
.HidePrefix
;
88 public ToolStripItemTextRenderEventArgs (Graphics g
, ToolStripItem item
, string text
, Rectangle textRectangle
, Color textColor
, Font textFont
, TextFormatFlags format
)
92 this.text_rectangle
= textRectangle
;
93 this.text_color
= textColor
;
94 this.text_font
= textFont
;
95 this.text_format
= format
;
96 this.text_direction
= ToolStripTextDirection
.Horizontal
;
100 #region Public Properties
102 get { return this.text; }
103 set { this.text = value; }
106 public Color TextColor
{
107 get { return this.text_color; }
108 set { this.text_color = value; }
111 public ToolStripTextDirection TextDirection
{
112 get { return this.text_direction; }
113 set { this.text_direction = value; }
116 public Font TextFont
{
117 get { return this.text_font; }
118 set { this.text_font = value; }
121 public TextFormatFlags TextFormat
{
122 get { return this.text_format; }
123 set { this.text_format = value; }
126 public Rectangle TextRectangle
{
127 get { return this.text_rectangle; }
128 set { this.text_rectangle = value; }