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 // Jonathan Chambers (jonathan.chambers@ansys.com)
31 namespace System
.Windows
.Forms
.PropertyGridInternal
{
32 internal class PropertyGridTextBox
: System
.Windows
.Forms
.UserControl
{
33 #region Private Members
35 private TextBox textbox
;
36 private Button dialog_button
;
37 private Button dropdown_button
;
39 #endregion Private Members
42 public PropertyGridTextBox() {
43 dialog_button
= new Button();
44 dropdown_button
= new Button();
45 textbox
= new TextBox();
49 dialog_button
.Dock
= DockStyle
.Right
;
50 dialog_button
.Size
= new Size(16, 16);
51 dialog_button
.TabIndex
= 1;
52 dialog_button
.Visible
= false;
53 dialog_button
.Click
+= new System
.EventHandler(dialog_button_Click
);
55 dropdown_button
.Dock
= DockStyle
.Right
;
56 dropdown_button
.Size
= new Size(16, 16);
57 dropdown_button
.TabIndex
= 2;
58 dropdown_button
.Visible
= false;
59 dropdown_button
.Click
+= new System
.EventHandler(dropdown_button_Click
);
61 textbox
.AutoSize
= false;
62 textbox
.BorderStyle
= BorderStyle
.None
;
63 textbox
.Dock
= DockStyle
.Fill
;
66 Controls
.Add(textbox
);
67 Controls
.Add(dropdown_button
);
68 Controls
.Add(dialog_button
);
72 dropdown_button
.Paint
+=new PaintEventHandler(dropdown_button_Paint
);
73 dialog_button
.Paint
+=new PaintEventHandler(dialog_button_Paint
);
74 textbox
.DoubleClick
+=new EventHandler(textbox_DoubleClick
);
78 #endregion Contructors
80 #region Public Instance Properties
82 public bool DialogButtonVisible
{
84 return dialog_button
.Visible
;
87 dialog_button
.Visible
= value;
90 public bool DropDownButtonVisible
{
92 return dropdown_button
.Visible
;
95 dropdown_button
.Visible
= value;
99 public bool ReadOnly
{
101 return textbox
.ReadOnly
;
104 textbox
.ReadOnly
= value;
108 public new string Text
{
113 textbox
.Text
= value;
117 #endregion Public Instance Properties
121 public event EventHandler DropDownButtonClicked
;
122 public event EventHandler DialogButtonClicked
;
123 public event EventHandler ToggleValue
;
127 #region Private Helper Methods
129 private void dropdown_button_Paint(object sender
, PaintEventArgs e
)
131 ThemeEngine
.Current
.CPDrawComboButton(e
.Graphics
, dropdown_button
.ClientRectangle
, dropdown_button
.ButtonState
);
134 private void dialog_button_Paint(object sender
, PaintEventArgs e
) {
135 // best way to draw the ellipse?
136 e
.Graphics
.DrawString("...", new Font(Font
,FontStyle
.Bold
), Brushes
.Black
, 0,0);
139 private void dropdown_button_Click(object sender
, System
.EventArgs e
) {
140 if (DropDownButtonClicked
!= null)
141 DropDownButtonClicked(this, EventArgs
.Empty
);
144 private void dialog_button_Click(object sender
, System
.EventArgs e
) {
145 if (DialogButtonClicked
!= null)
146 DialogButtonClicked(this, EventArgs
.Empty
);
149 #endregion Private Helper Methods
151 private void textbox_DoubleClick(object sender
, EventArgs e
) {
152 if (ToggleValue
!= null)
153 ToggleValue(this, EventArgs
.Empty
);