Tweak DisplayAttribute, don't disable text labels, PropertyGrid should be feature complete now.

This commit is contained in:
Brant Martin
2018-04-27 10:25:57 -04:00
parent f2537706e7
commit b9e9be227a
2 changed files with 11 additions and 8 deletions

View File

@@ -12,22 +12,25 @@ namespace Torch.Views
public string Description;
public string ToolTip;
public string GroupName;
public int? Order;
public bool? Enabled;
public bool? Visible;
public bool? ReadOnly;
public int Order;
public bool Enabled = true;
public bool Visible = true;
public bool ReadOnly = false;
public DisplayAttribute()
{ }
public static implicit operator DisplayAttribute(System.ComponentModel.DataAnnotations.DisplayAttribute da)
{
if (da == null)
return null;
return new DisplayAttribute()
{
Name = da.GetName(),
Description = da.GetDescription(),
GroupName = da.GetGroupName(),
Order = da.GetOrder()
Order = da.GetOrder() ?? 0
};
}
}

View File

@@ -110,7 +110,7 @@ namespace Torch.Views
c.Value.Sort((a, b) =>
{
var c1 = descriptors[a]?.Order?.CompareTo(descriptors[b]?.Order);
var c1 = descriptors[a]?.Order.CompareTo(descriptors[b]?.Order);
if (c1.HasValue && c1.Value != 0)
return c1.Value;
return string.Compare((descriptors[a]?.Name ?? a.Name), descriptors[b]?.Name ?? b.Name, StringComparison.Ordinal);
@@ -138,8 +138,8 @@ namespace Torch.Views
text.Margin = new Thickness(3);
text.Tag = $"{text.Text}: {descriptor?.Description}";
text.IsMouseDirectlyOverChanged += Text_IsMouseDirectlyOverChanged;
if (descriptor?.Enabled == false)
text.IsEnabled = false;
//if (descriptor?.Enabled == false)
// text.IsEnabled = false;
grid.Children.Add(text);
FrameworkElement valueControl;