diff --git a/Arma.Studio.Data/ArmA.Studio.Data.csproj b/Arma.Studio.Data/ArmA.Studio.Data.csproj index c48e1ec..bc05829 100644 --- a/Arma.Studio.Data/ArmA.Studio.Data.csproj +++ b/Arma.Studio.Data/ArmA.Studio.Data.csproj @@ -178,6 +178,7 @@ + diff --git a/Arma.Studio.Data/UI/PropertyAttribute.cs b/Arma.Studio.Data/UI/PropertyAttribute.cs index 8d39834..527836e 100644 --- a/Arma.Studio.Data/UI/PropertyAttribute.cs +++ b/Arma.Studio.Data/UI/PropertyAttribute.cs @@ -32,6 +32,22 @@ public class PropertyAttribute : Attribute /// public object Default { get; set; } + /// + /// UI-Configuration. + /// The Minimum value the property is supposed to have. + /// + public double MinValue { get; set; } + /// + /// UI-Configuration. + /// The Maximum value the property is supposed to have. + /// + public double MaxValue { get; set; } + /// + /// UI-Configuration. + /// Stepsize for numeric up-down. + /// + public double Stepsize { get; set; } + public PropertyAttribute(string title) { this.Title = title; @@ -39,6 +55,9 @@ public PropertyAttribute(string title) this.Description = string.Empty; this.Group = null; this.Default = null; + this.MinValue = double.MinValue; + this.MaxValue = double.MaxValue; + this.Stepsize = 1; } } } diff --git a/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerBase.cs b/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerBase.cs index 446aa25..3154bff 100644 --- a/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerBase.cs +++ b/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerBase.cs @@ -26,6 +26,22 @@ public object Value } } + /// + /// UI-Configuration. + /// The Minimum value the property is supposed to have. + /// + public double MinValue { get; set; } + /// + /// UI-Configuration. + /// The Maximum value the property is supposed to have. + /// + public double MaxValue { get; set; } + /// + /// UI-Configuration. + /// Stepsize for numeric up-down. + /// + public double Stepsize { get; set; } + public string Title { get; } public string ToolTip { get; } public PropertyContainerBase(string title, string tooltip, object data, string propertyName, Func getFunc, Action setFunc) diff --git a/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerColor.cs b/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerColor.cs index 0ac4bb3..6353587 100644 --- a/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerColor.cs +++ b/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerColor.cs @@ -27,7 +27,11 @@ public static PropertyContainerColor Create(object data, PropertyInfo propertyIn { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerColor(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Color)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerColor(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Color)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } } diff --git a/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerEnum.cs b/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerEnum.cs index 086ae0b..4fb2ce6 100644 --- a/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerEnum.cs +++ b/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerEnum.cs @@ -45,7 +45,7 @@ public static PropertyContainerEnum Create(object data, PropertyInfo propertyInf } var enumValues = Enum.GetValues(propertyInfo.PropertyType); - return new PropertyContainerEnum( + var container = new PropertyContainerEnum( attribute.Title, attribute.Description, data, @@ -53,6 +53,10 @@ public static PropertyContainerEnum Create(object data, PropertyInfo propertyInf enumValues.Cast().Select((it) => new EnumValue(it, Studio.Data.UI.Converters.EnumNameConverter.Instance.Convert(propertyInfo.PropertyType, it))), (obj) => propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } } diff --git a/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerPrimitive.cs b/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerPrimitive.cs index 51d62d9..4701139 100644 --- a/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerPrimitive.cs +++ b/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerPrimitive.cs @@ -20,7 +20,11 @@ public static PropertyContainerByte Create(object data, PropertyInfo propertyInf { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerByte(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Byte)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerByte(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Byte)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerSByte : PropertyContainerBase @@ -41,7 +45,11 @@ public static PropertyContainerSByte Create(object data, PropertyInfo propertyIn { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerSByte(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (SByte)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerSByte(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (SByte)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerInt32 : PropertyContainerBase @@ -62,7 +70,11 @@ public static PropertyContainerInt32 Create(object data, PropertyInfo propertyIn { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerInt32(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Int32)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerInt32(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Int32)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerUInt32 : PropertyContainerBase @@ -83,7 +95,11 @@ public static PropertyContainerUInt32 Create(object data, PropertyInfo propertyI { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerUInt32(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (UInt32)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerUInt32(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (UInt32)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerInt16 : PropertyContainerBase @@ -104,7 +120,11 @@ public static PropertyContainerInt16 Create(object data, PropertyInfo propertyIn { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerInt16(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Int16)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerInt16(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Int16)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerUInt16 : PropertyContainerBase @@ -125,7 +145,11 @@ public static PropertyContainerUInt16 Create(object data, PropertyInfo propertyI { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerUInt16(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (UInt16)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerUInt16(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (UInt16)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerInt64 : PropertyContainerBase @@ -146,7 +170,11 @@ public static PropertyContainerInt64 Create(object data, PropertyInfo propertyIn { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerInt64(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Int64)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerInt64(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Int64)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerUInt64 : PropertyContainerBase @@ -167,7 +195,11 @@ public static PropertyContainerUInt64 Create(object data, PropertyInfo propertyI { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerUInt64(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (UInt64)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerUInt64(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (UInt64)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerSingle : PropertyContainerBase @@ -188,7 +220,11 @@ public static PropertyContainerSingle Create(object data, PropertyInfo propertyI { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerSingle(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Single)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerSingle(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Single)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerDouble : PropertyContainerBase @@ -209,7 +245,11 @@ public static PropertyContainerDouble Create(object data, PropertyInfo propertyI { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerDouble(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Double)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerDouble(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Double)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerChar : PropertyContainerBase @@ -230,7 +270,11 @@ public static PropertyContainerChar Create(object data, PropertyInfo propertyInf { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerChar(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Char)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerChar(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Char)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerBoolean : PropertyContainerBase @@ -251,7 +295,11 @@ public static PropertyContainerBoolean Create(object data, PropertyInfo property { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerBoolean(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Boolean)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerBoolean(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Boolean)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerString : PropertyContainerBase @@ -272,7 +320,11 @@ public static PropertyContainerString Create(object data, PropertyInfo propertyI { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerString(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (String)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerString(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (String)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } public class PropertyContainerDecimal : PropertyContainerBase @@ -293,7 +345,11 @@ public static PropertyContainerDecimal Create(object data, PropertyInfo property { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainerDecimal(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Decimal)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainerDecimal(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (Decimal)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } } \ No newline at end of file diff --git a/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerPrimitive.tt b/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerPrimitive.tt index 9728d4f..8535bff 100644 --- a/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerPrimitive.tt +++ b/Arma.Studio.PropertiesWindow/PropertyContainers/PropertyContainerPrimitive.tt @@ -43,7 +43,11 @@ namespace Arma.Studio.PropertiesWindow.PropertyContainers { throw new ArgumentException("Missing Arma.Studio.Data.UI.PropertyAttribute.", nameof(propertyInfo)); } - return new PropertyContainer<#= type.Name #>(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (<#= type.Name #>)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + var container = new PropertyContainer<#= type.Name #>(attribute.Title, attribute.Description, data, propertyInfo.Name, (obj) => (<#= type.Name #>)propertyInfo.GetValue(obj, null), (obj, val) => propertyInfo.SetValue(obj, val, null)); + container.Stepsize = attribute.Stepsize; + container.MinValue = attribute.MinValue; + container.MaxValue = attribute.MaxValue; + return container; } } <# } #> diff --git a/Arma.Studio.PropertiesWindow/Themes/Generic.xaml b/Arma.Studio.PropertiesWindow/Themes/Generic.xaml index 8b33090..42de0a5 100644 --- a/Arma.Studio.PropertiesWindow/Themes/Generic.xaml +++ b/Arma.Studio.PropertiesWindow/Themes/Generic.xaml @@ -27,7 +27,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -93,7 +93,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -115,7 +115,7 @@ - + @@ -126,7 +126,7 @@ - + @@ -148,7 +148,7 @@ - + @@ -159,7 +159,7 @@ - + @@ -170,7 +170,7 @@ - + diff --git a/Arma.Studio.UiEditor/Data/ControlBase.cs b/Arma.Studio.UiEditor/Data/ControlBase.cs index 72e87c2..d646e49 100644 --- a/Arma.Studio.UiEditor/Data/ControlBase.cs +++ b/Arma.Studio.UiEditor/Data/ControlBase.cs @@ -176,7 +176,7 @@ public double Height /// /// Useful to note is that the following should yield the correct sizeEx value: (0.0264 * safeZoneH) * FontSize /// - [ArmaName("sizeEx", Group = PropGroup_Text)] + [ArmaName("sizeEx", Group = PropGroup_Text, MaxValue = 1.0, MinValue = 0.0, Stepsize = 0.01)] public double FontSize { get => this._FontSize; @@ -382,11 +382,11 @@ public bool IsDeletable } private bool _IsDeletable; #endregion - #region Property: Opacity {fade} (System.Double) + #region Property: Fade {fade} (System.Double) /// /// Initial fade of the control /// - [ArmaName("fade", Group = PropGroup_Visual)] + [ArmaName("fade", Group = PropGroup_Visual, MaxValue = 1.0, MinValue = 0.0, Stepsize = 0.01)] public double Fade { get => this._Fade;