-
Notifications
You must be signed in to change notification settings - Fork 27
/
PropertyGrid.cs
35 lines (33 loc) · 1.19 KB
/
PropertyGrid.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
namespace Bonsai.Design
{
/// <summary>
/// Provides a user interface for browsing the properties of an object.
/// </summary>
public class PropertyGrid : System.Windows.Forms.PropertyGrid
{
/// <inheritdoc/>
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
{
ScaleDescriptionPanel(this, factor);
base.ScaleControl(factor, specified);
}
internal static void ScaleDescriptionPanel(System.Windows.Forms.PropertyGrid propertyGrid, SizeF factor)
{
foreach (Control control in propertyGrid.Controls)
{
var controlType = control.GetType();
if (controlType.Name == "DocComment")
{
var userSizedField = controlType.BaseType.GetField(
"userSized",
BindingFlags.Instance | BindingFlags.NonPublic);
userSizedField.SetValue(control, true);
control.Height = (int)(control.Height * factor.Height);
}
}
}
}
}