Adding lockable items that external to persist able
This commit is contained in:
parent
699cee2d9b
commit
2b89cb2c11
1 changed files with 23 additions and 39 deletions
|
|
@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
typeof(double), typeof(int), typeof(char), typeof(string), typeof(bool),
|
||||
typeof(Color),
|
||||
typeof(Vector2), typeof(Vector3), typeof(Vector4),
|
||||
typeof(Vector2), typeof(Vector3),
|
||||
typeof(DirectionVector), typeof(DirectionAxis),
|
||||
typeof(SelectedChildren),
|
||||
typeof(ImageBuffer),
|
||||
|
|
@ -421,29 +421,6 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
rowContainer = CreateSettingsColumn(property, field);
|
||||
}
|
||||
else if (propertyValue is Vector4 vector4)
|
||||
{
|
||||
var field = new Vector4Field(theme);
|
||||
if (property.PropertyInfo.GetCustomAttributes(true).OfType<VectorFieldLabelsAttribute>().FirstOrDefault() is VectorFieldLabelsAttribute vectorFieldLabels)
|
||||
{
|
||||
field.Labels = vectorFieldLabels.Labels;
|
||||
}
|
||||
|
||||
field.Initialize(0);
|
||||
field.Vector4 = vector4;
|
||||
field.ClearUndoHistory();
|
||||
|
||||
RegisterValueChanged(
|
||||
field,
|
||||
(valueString) => Vector4.Parse(valueString),
|
||||
(value) =>
|
||||
{
|
||||
var s = ((Vector4)value).ToString();
|
||||
return s.Substring(1, s.Length - 2);
|
||||
});
|
||||
|
||||
rowContainer = CreateSettingsColumn(property, field);
|
||||
}
|
||||
else if (propertyValue is DirectionVector directionVector)
|
||||
{
|
||||
var field = new DirectionVectorField(theme);
|
||||
|
|
@ -523,7 +500,8 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
else if (propertyValue is SelectedChildren childSelector)
|
||||
{
|
||||
if (property.PropertyInfo.GetCustomAttributes(true).OfType<ShowAsListAttribute>().FirstOrDefault() is ShowAsListAttribute showAsList)
|
||||
var showAsList = property.PropertyInfo.GetCustomAttributes(true).OfType<ShowAsListAttribute>().FirstOrDefault() != null;
|
||||
if (showAsList)
|
||||
{
|
||||
UIField field = new ChildrenSelectorListField(property, theme);
|
||||
|
||||
|
|
@ -966,7 +944,14 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
public static void AddUnlockLinkIfRequired(IObject3D item, GuiWidget editControlsContainer, ThemeConfig theme)
|
||||
{
|
||||
if (!item.Persistable)
|
||||
(string url, GuiWidget markdownWidget)? unlockdata = null;
|
||||
|
||||
if (item.GetType().GetCustomAttributes(typeof(RequiresPermissionsAttribute), true).FirstOrDefault() is RequiresPermissionsAttribute unlockLink
|
||||
&& !ApplicationController.Instance.UserHasPermission(item))
|
||||
{
|
||||
unlockdata = ApplicationController.Instance.GetUnlockData?.Invoke(item, theme);
|
||||
}
|
||||
else if (!item.Persistable)
|
||||
{
|
||||
// find the first self or child that is not authorized
|
||||
var permission = item.DescendantsAndSelf()
|
||||
|
|
@ -975,21 +960,20 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
if (permission.Any())
|
||||
{
|
||||
var unlockItem = permission.First();
|
||||
var unlockdata = ApplicationController.Instance.GetUnlockData?.Invoke(unlockItem, theme);
|
||||
|
||||
if (unlockdata != null
|
||||
&& !string.IsNullOrEmpty(unlockdata.Value.url))
|
||||
{
|
||||
if (unlockdata.Value.markdownWidget != null)
|
||||
{
|
||||
unlockdata.Value.markdownWidget.VAnchor = VAnchor.Fit;
|
||||
editControlsContainer.AddChild(unlockdata.Value.markdownWidget);
|
||||
}
|
||||
|
||||
editControlsContainer.AddChild(GetUnlockRow(theme, unlockdata.Value.url));
|
||||
}
|
||||
unlockdata = ApplicationController.Instance.GetUnlockData?.Invoke(unlockItem, theme);
|
||||
}
|
||||
}
|
||||
|
||||
if (unlockdata != null && !string.IsNullOrEmpty(unlockdata.Value.url))
|
||||
{
|
||||
if (unlockdata.Value.markdownWidget != null)
|
||||
{
|
||||
unlockdata.Value.markdownWidget.VAnchor = VAnchor.Fit;
|
||||
editControlsContainer.AddChild(unlockdata.Value.markdownWidget);
|
||||
}
|
||||
|
||||
editControlsContainer.AddChild(GetUnlockRow(theme, unlockdata.Value.url));
|
||||
}
|
||||
}
|
||||
|
||||
public static GuiWidget GetUnlockRow(ThemeConfig theme, string url)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue