adding read only property display
This commit is contained in:
parent
bddcdba380
commit
eaebe4ed4c
2 changed files with 28 additions and 16 deletions
|
|
@ -307,27 +307,39 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
// create a double editor
|
||||
if (propertyValue is double doubleValue)
|
||||
{
|
||||
var field = new DoubleField(theme);
|
||||
field.Initialize(0);
|
||||
field.DoubleValue = doubleValue;
|
||||
RegisterValueChanged(field, (valueString) => { return double.Parse(valueString); });
|
||||
|
||||
void RefreshField(object s, InvalidateArgs e)
|
||||
var readOnly = property.PropertyInfo.GetCustomAttributes(true).OfType<ReadOnlyAttribute>().FirstOrDefault() != null;
|
||||
if (readOnly)
|
||||
{
|
||||
if (e.InvalidateType.HasFlag(InvalidateType.DisplayValues))
|
||||
var valueField = new TextWidget(doubleValue.ToString("0.##"), textColor: theme.TextColor, pointSize: 10);
|
||||
rowContainer = new SettingsRow(property.DisplayName.Localize(),
|
||||
property.Description.Localize(),
|
||||
valueField,
|
||||
theme);
|
||||
}
|
||||
else // normal edit row
|
||||
{
|
||||
var field = new DoubleField(theme);
|
||||
field.Initialize(0);
|
||||
field.DoubleValue = doubleValue;
|
||||
RegisterValueChanged(field, (valueString) => { return double.Parse(valueString); });
|
||||
|
||||
void RefreshField(object s, InvalidateArgs e)
|
||||
{
|
||||
double newValue = (double)property.Value;
|
||||
if (newValue != field.DoubleValue)
|
||||
if (e.InvalidateType.HasFlag(InvalidateType.DisplayValues))
|
||||
{
|
||||
field.DoubleValue = newValue;
|
||||
double newValue = (double)property.Value;
|
||||
if (newValue != field.DoubleValue)
|
||||
{
|
||||
field.DoubleValue = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object3D.Invalidated += RefreshField;
|
||||
field.Content.Closed += (s, e) => object3D.Invalidated -= RefreshField;
|
||||
|
||||
rowContainer = CreateSettingsRow(property, field, theme);
|
||||
}
|
||||
|
||||
object3D.Invalidated += RefreshField;
|
||||
field.Content.Closed += (s, e) => object3D.Invalidated -= RefreshField;
|
||||
|
||||
rowContainer = CreateSettingsRow(property, field, theme);
|
||||
}
|
||||
else if (propertyValue is Color color)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
}
|
||||
|
||||
public SettingsRow(string title, string helpText, GuiWidget guiWidget, ThemeConfig theme)
|
||||
: this (title, helpText, theme)
|
||||
: this(title, helpText, theme)
|
||||
{
|
||||
this.Padding = new BorderDouble(right: theme.DefaultContainerPadding);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue