Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Zlatev <ivan@ivanz.com>2008-02-28 17:59:47 +0300
committerIvan Zlatev <ivan@ivanz.com>2008-02-28 17:59:47 +0300
commit23a247a942a996fb4e7ab886d09cf42069aa681d (patch)
tree8f6fda51589e10cd35556e01311216448b76e99d
parent9f2ef9809cbccf4bcb5174cd95a95d8a2914b079 (diff)
2008-02-28 Ivan N. Zlatev <contact@i-nz.net>
* GridEntry.cs: - Use PropertyDescriptor.DisplayName instead of .Name for Label, so that DisplayNameAttribute doesn't get ignored. - Check for ParenthesizeNameAttribute and parenthesize the Label. - Add support for PasswordPropertyTextAttribute * PropertyGridView.cs: Check if an entry is a password. [Fixes bugs #365589, #365586, #365588] svn path=/branches/mono-1-9/mcs/; revision=96884
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog10
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs24
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs4
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs73
4 files changed, 73 insertions, 38 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
index 495fcd9349d..73375bf54eb 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
@@ -1,3 +1,13 @@
+2008-02-28 Ivan N. Zlatev <contact@i-nz.net>
+
+ * GridEntry.cs:
+ - Use PropertyDescriptor.DisplayName instead of .Name for Label,
+ so that DisplayNameAttribute doesn't get ignored.
+ - Check for ParenthesizeNameAttribute and parenthesize the Label.
+ - Add support for PasswordPropertyTextAttribute
+ * PropertyGridView.cs: Check if an entry is a password.
+ [Fixes bugs #365589, #365586, #365588]
+
2008-02-26 Ivan N. Zlatev <contact@i-nz.net>
* GridEntry.cs: Optimization in ToggleValue so that it caches
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
index b28debe475a..3edb9b9b7f0 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
@@ -102,7 +102,18 @@ namespace System.Windows.Forms.PropertyGridInternal
}
public override string Label {
- get { return PropertyDescriptor.Name; }
+ get {
+ PropertyDescriptor property = this.PropertyDescriptor;
+ if (property != null) {
+ string label = property.DisplayName;
+ ParenthesizePropertyNameAttribute parensAttr =
+ property.Attributes[typeof (ParenthesizePropertyNameAttribute)] as ParenthesizePropertyNameAttribute;
+ if (parensAttr != null && parensAttr.NeedParenthesis)
+ label = "(" + label + ")";
+ return label;
+ }
+ return String.Empty;
+ }
}
public override GridItem Parent {
@@ -350,7 +361,7 @@ namespace System.Windows.Forms.PropertyGridInternal
this.Value);
string error = null;
return SetValue (value, out error);
- } catch { // (Exception e) {
+ } catch { //(Exception e) {
// property_grid.ShowError (e.Message + Environment.NewLine + e.StackTrace);
}
}
@@ -595,6 +606,15 @@ namespace System.Windows.Forms.PropertyGridInternal
}
}
+ public bool IsPassword {
+ get {
+#if NET_2_0
+ if (PropertyDescriptor != null)
+ return PropertyDescriptor.Attributes.Contains (PasswordPropertyTextAttribute.Yes);
+#endif
+ return false;
+ }
+ }
// This is a way to set readonly properties (e.g properties without a setter).
// The way it works is that if CreateInstance is supported by the parent's converter
// it gets passed a list of properties and their values which it uses to create an
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs
index 30cd6dde93e..52bd3ecb0f4 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridTextBox.cs
@@ -179,6 +179,10 @@ namespace System.Windows.Forms.PropertyGridInternal
}
}
+ public char PasswordChar {
+ set { textbox.PasswordChar = value; }
+ }
+
#endregion Public Instance Properties
#region Events
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
index 5c194f8d4fe..bf99e47ec32 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyGridView.cs
@@ -40,6 +40,8 @@ namespace System.Windows.Forms.PropertyGridInternal {
internal class PropertyGridView : ScrollableControl, IWindowsFormsEditorService {
#region Private Members
+ private const char PASSWORD_PAINT_CHAR = '\u25cf'; // the dot char
+ private const char PASSWORD_TEXT_CHAR = '*';
private const int V_INDENT = 16;
private const int ENTRY_SPACING = 2;
private const int RESIZE_WIDTH = 3;
@@ -647,7 +649,13 @@ namespace System.Windows.Forms.PropertyGridInternal {
if (grid_item.IsResetable || !grid_item.HasDefaultValue)
font = bold_font;
Brush brush = grid_item.IsReadOnly ? inactive_text_brush : SystemBrushes.ControlText;
- string valueText = grid_item.IsMerged && !grid_item.HasMergedValue ? String.Empty : grid_item.ValueText;
+ string valueText = String.Empty;
+ if (!grid_item.IsMerged || grid_item.IsMerged && grid_item.HasMergedValue) {
+ if (grid_item.IsPassword)
+ valueText = new String (PASSWORD_PAINT_CHAR, grid_item.ValueText.Length);
+ else
+ valueText = grid_item.ValueText;
+ }
pevent.Graphics.DrawString (valueText, font,
brush,
new RectangleF (xLoc + ENTRY_SPACING, rect.Y + ENTRY_SPACING,
@@ -843,6 +851,7 @@ namespace System.Windows.Forms.PropertyGridInternal {
grid_textbox.ReadOnly = !entry.IsEditable;
}
UpdateGridTextBoxBounds (entry);
+ grid_textbox.PasswordChar = entry.IsPassword ? PASSWORD_TEXT_CHAR : '\0';
grid_textbox.Text = entry.IsMerged && !entry.HasMergedValue ? String.Empty : entry.ValueText;
grid_textbox.Visible = true;
InvalidateItem (entry);
@@ -926,13 +935,8 @@ namespace System.Windows.Forms.PropertyGridInternal {
Invalidate (new Rectangle (0, item.Top, Width, Height - item.Top));
}
- private void ShowDropDownControl (Control control, bool block)
+ private void ShowDropDownControl (Control control)
{
- Object queue_id;
-
- Form owner = FindForm ();
-
- Point location;
dropdown_form.Size = control.Size;
control.Dock = DockStyle.Fill;
dropdown_form.Controls.Add (control);
@@ -940,40 +944,37 @@ namespace System.Windows.Forms.PropertyGridInternal {
control.Width);
dropdown_form.Location = PointToScreen (new Point (grid_textbox.Right - control.Width, grid_textbox.Location.Y + row_height));
RepositionInScreenWorkingArea (dropdown_form);
- location = dropdown_form.Location;
+ Point location = dropdown_form.Location;
+ Form owner = FindForm ();
owner.AddOwnedForm (dropdown_form);
-
dropdown_form.Show ();
-
- if (dropdown_form.Location != location) {
+ if (dropdown_form.Location != location)
dropdown_form.Location = location;
- }
- if (block) {
- System.Windows.Forms.MSG msg = new MSG ();
- queue_id = XplatUI.StartLoop (Thread.CurrentThread);
- while (dropdown_form.Visible && XplatUI.GetMessage (queue_id, ref msg, IntPtr.Zero, 0, 0)) {
- switch (msg.message) {
- case Msg.WM_NCLBUTTONDOWN:
- case Msg.WM_NCMBUTTONDOWN:
- case Msg.WM_NCRBUTTONDOWN:
- case Msg.WM_LBUTTONDOWN:
- case Msg.WM_MBUTTONDOWN:
- case Msg.WM_RBUTTONDOWN:
- if (!HwndInControl (dropdown_form, msg.hwnd))
- CloseDropDown ();
- break;
- case Msg.WM_ACTIVATE:
- case Msg.WM_NCPAINT:
- if (owner.window.Handle == msg.hwnd)
- CloseDropDown ();
- break;
- }
- XplatUI.TranslateMessage (ref msg);
- XplatUI.DispatchMessage (ref msg);
+
+ System.Windows.Forms.MSG msg = new MSG ();
+ object queue_id = XplatUI.StartLoop (Thread.CurrentThread);
+ while (dropdown_form.Visible && XplatUI.GetMessage (queue_id, ref msg, IntPtr.Zero, 0, 0)) {
+ switch (msg.message) {
+ case Msg.WM_NCLBUTTONDOWN:
+ case Msg.WM_NCMBUTTONDOWN:
+ case Msg.WM_NCRBUTTONDOWN:
+ case Msg.WM_LBUTTONDOWN:
+ case Msg.WM_MBUTTONDOWN:
+ case Msg.WM_RBUTTONDOWN:
+ if (!HwndInControl (dropdown_form, msg.hwnd))
+ CloseDropDown ();
+ break;
+ case Msg.WM_ACTIVATE:
+ case Msg.WM_NCPAINT:
+ if (owner.window.Handle == msg.hwnd)
+ CloseDropDown ();
+ break;
}
- XplatUI.EndLoop (Thread.CurrentThread);
+ XplatUI.TranslateMessage (ref msg);
+ XplatUI.DispatchMessage (ref msg);
}
+ XplatUI.EndLoop (Thread.CurrentThread);
}
private void RepositionInScreenWorkingArea (Form form)
@@ -1017,7 +1018,7 @@ namespace System.Windows.Forms.PropertyGridInternal {
}
public void DropDownControl (Control control) {
- ShowDropDownControl (control, true);
+ ShowDropDownControl (control);
}
public System.Windows.Forms.DialogResult ShowDialog (Form dialog) {