mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Conditions UI - Open dropdowns automatically when editing static values
Conditions UI - Added missing defaults for enum/bool Data models - Use enum descriptions in display
This commit is contained in:
1 parent
7ccfe775fd
commit
ceccc7ceec
9 files changed
+23
-34
No files matched your search
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=utilities/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
@@ -45,7 +45,8 @@ namespace Artemis.UI.Shared
|
||||
}
|
||||
|
||||
DisplayValue = GetCurrentValue();
|
||||
DisplayValueType = DataModelPath.GetPropertyType();
|
||||
DisplayValueType = DisplayValue != null ? DisplayValue.GetType() : DataModelPath.GetPropertyType();
|
||||
|
||||
UpdateDisplayParameters();
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -1,4 +1,6 @@
|
||||
namespace Artemis.UI.Shared.DefaultTypes.DataModel.Display
|
||||
using System;
|
||||
|
||||
namespace Artemis.UI.Shared.DefaultTypes.DataModel.Display
|
||||
{
|
||||
public class DefaultDataModelDisplayViewModel : DataModelDisplayViewModel<object>
|
||||
{
|
||||
@@ -24,6 +26,9 @@
|
||||
|
||||
protected override void OnDisplayValueUpdated()
|
||||
{
|
||||
if (DisplayValue is Enum enumDisplayValue)
|
||||
DisplayValue = EnumUtilities.HumanizeValue(enumDisplayValue);
|
||||
|
||||
ShowToString = DisplayValue != null;
|
||||
ShowNull = DisplayValue == null;
|
||||
}
|
||||
|
||||
@@ -216,13 +216,6 @@ namespace Artemis.UI.Shared.Services
|
||||
|
||||
private DataModelInputViewModel InstantiateDataModelInputViewModel(DataModelVisualizationRegistration registration, DataModelPropertyAttribute description, object initialValue)
|
||||
{
|
||||
// The view models expecting value types shouldn't be given null, avoid that
|
||||
if (registration.SupportedType.IsValueType)
|
||||
{
|
||||
if (initialValue == null)
|
||||
initialValue = Activator.CreateInstance(registration.SupportedType);
|
||||
}
|
||||
|
||||
// This assumes the type can be converted, that has been checked when the VM was created
|
||||
if (initialValue != null && initialValue.GetType() != registration.SupportedType)
|
||||
initialValue = Convert.ChangeType(initialValue, registration.SupportedType);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Humanizer;
|
||||
|
||||
@@ -12,23 +10,6 @@ namespace Artemis.UI.Shared
|
||||
/// </summary>
|
||||
public static class EnumUtilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a human readable description of the given enum value
|
||||
/// </summary>
|
||||
/// <param name="value">The value to get a description for</param>
|
||||
/// <returns>A human readable description of the given enum value</returns>
|
||||
public static string Description(this Enum value)
|
||||
{
|
||||
object[] attributes = value.GetType().GetField(value.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
if (attributes.Any())
|
||||
return (attributes.First() as DescriptionAttribute).Description;
|
||||
|
||||
// If no description is found, the least we can do is replace underscores with spaces
|
||||
// You can add your own custom default formatting logic here
|
||||
TextInfo ti = CultureInfo.CurrentCulture.TextInfo;
|
||||
return ti.ToTitleCase(ti.ToLower(value.ToString().Replace("_", " ")));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list containing a <see cref="ValueDescription" /> for each value in the enum type
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user