Exemplo n.º 1
0
        public SettingsPropertyDefinitionWrapper(object @object) : base()
        {
            var type = @object.GetType();

            SettingsIdProperty       = AccessTools.Property(type, nameof(SettingsId));
            SettingTypeProperty      = AccessTools.Property(type, nameof(SettingType));
            PropertyProperty         = AccessTools.Property(type, nameof(PropertyReference));
            DisplayNameProperty      = AccessTools.Property(type, nameof(DisplayName));
            HintTextProperty         = AccessTools.Property(type, nameof(HintText));
            OrderProperty            = AccessTools.Property(type, nameof(Order));
            RequireRestartProperty   = AccessTools.Property(type, nameof(RequireRestart));
            GroupNameProperty        = AccessTools.Property(type, nameof(GroupName));
            IsMainToggleProperty     = AccessTools.Property(type, nameof(IsMainToggle));
            MinValueProperty         = AccessTools.Property(type, nameof(MinValue));
            MaxValueProperty         = AccessTools.Property(type, nameof(MaxValue));
            EditableMinValueProperty = AccessTools.Property(type, nameof(EditableMinValue));
            EditableMaxValueProperty = AccessTools.Property(type, nameof(EditableMaxValue));
            SelectedIndexProperty    = AccessTools.Property(type, nameof(SelectedIndex));


            SettingsId  = SettingsIdProperty?.GetValue(@object) as string ?? "ERROR";
            SettingType = SettingTypeProperty?.GetValue(@object) is { } settingTypeObject
                ? Enum.TryParse <SettingType>(settingTypeObject.ToString(), out var resultEnum)
                    ? resultEnum
                    : SettingType.NONE
                : SettingType.NONE;

            PropertyReference = PropertyProperty?.GetValue(@object) is { } value
                ? value is IRef @ref ? @ref : new RefWrapper(value)
                : null;

            DisplayName = DisplayNameProperty?.GetValue(@object) switch
            {
                string str => str,
                TextObject to => to.ToString(),
                       _ => DisplayName
            };
            HintText = HintTextProperty?.GetValue(@object) switch
            {
                string str => str,
                TextObject to => to.ToString(),
                       _ => HintText
            };
            Order          = OrderProperty?.GetValue(@object) as int? ?? -1;
            RequireRestart = RequireRestartProperty?.GetValue(@object) as bool? ?? true;

            GroupName    = GroupNameProperty?.GetValue(@object) as string ?? "";
            IsMainToggle = IsMainToggleProperty?.GetValue(@object) as bool? ?? false;

            MinValue         = MinValueProperty?.GetValue(@object) is { } minVal?minVal as decimal? ?? 0 : 0;
            MaxValue         = MaxValueProperty?.GetValue(@object) is { } maxVal?maxVal as decimal? ?? 0 : 0;
            EditableMinValue = EditableMinValueProperty?.GetValue(@object) is { } eMinVal?  eMinVal as decimal? ?? 0 : 0;
            EditableMaxValue = EditableMaxValueProperty?.GetValue(@object) is { } eMaxValue?eMaxValue as decimal? ?? 0 : 0;

            SelectedIndex = SelectedIndexProperty?.GetValue(@object) as int? ?? 0;
        }
    }
}
Exemplo n.º 2
0
        /// <summary>
        /// Static class constructor
        /// </summary>
        static ULongUpDown()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ULongUpDown),
                                                     new FrameworkPropertyMetadata(typeof(ULongUpDown)));

            MaxValueProperty.OverrideMetadata(typeof(ULongUpDown),
                                              new PropertyMetadata(ulong.MaxValue));

            MinValueProperty.OverrideMetadata(typeof(ULongUpDown),
                                              new PropertyMetadata(ulong.MinValue));

            // Override Min/Max default values
            ////            AbstractBaseUpDown<ulong>.MinValueProperty.OverrideMetadata(
            ////                typeof(ULongUpDown), new PropertyMetadata(ulong.MinValue));
            ////
            ////            AbstractBaseUpDown<ulong>.MaxValueProperty.OverrideMetadata(
            ////                typeof(ULongUpDown), new PropertyMetadata(ulong.MaxValue));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Static class constructor
        /// </summary>
        static ShortUpDown()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ShortUpDown),
                                                     new FrameworkPropertyMetadata(typeof(ShortUpDown)));

            MaxValueProperty.OverrideMetadata(typeof(ShortUpDown),
                                              new PropertyMetadata(short.MaxValue));

            MinValueProperty.OverrideMetadata(typeof(ShortUpDown),
                                              new PropertyMetadata(short.MinValue));

            // Override Min/Max default values
            ////            AbstractBaseUpDown<short>.MinValueProperty.OverrideMetadata(
            ////                typeof(ShortUpDown), new PropertyMetadata(short.MinValue));
            ////
            ////            AbstractBaseUpDown<short>.MaxValueProperty.OverrideMetadata(
            ////                typeof(ShortUpDown), new PropertyMetadata(short.MaxValue));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Static class constructor
        /// </summary>
        static DecimalUpDown()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(DecimalUpDown),
                                                     new FrameworkPropertyMetadata(typeof(DecimalUpDown)));

            MaxValueProperty.OverrideMetadata(typeof(DecimalUpDown),
                                              new PropertyMetadata(decimal.MaxValue));

            MinValueProperty.OverrideMetadata(typeof(DecimalUpDown),
                                              new PropertyMetadata(decimal.MinValue));

            // Override Min/Max default values
            ////            AbstractBaseUpDown<decimal>.MinValueProperty.OverrideMetadata(
            ////                typeof(DecimalUpDown), new PropertyMetadata(decimal.MinValue));
            ////
            ////            AbstractBaseUpDown<decimal>.MaxValueProperty.OverrideMetadata(
            ////                typeof(DecimalUpDown), new PropertyMetadata(decimal.MaxValue));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Static class constructor
        /// </summary>
        static FloatUpDown()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(FloatUpDown),
                                                     new FrameworkPropertyMetadata(typeof(FloatUpDown)));

            FormatStringProperty.OverrideMetadata(typeof(FloatUpDown),
                                                  new PropertyMetadata("F2"));

            MaxValueProperty.OverrideMetadata(typeof(FloatUpDown),
                                              new PropertyMetadata(float.MaxValue));

            MinValueProperty.OverrideMetadata(typeof(FloatUpDown),
                                              new PropertyMetadata(float.MinValue));

            // Override Min/Max default values
            ////            AbstractBaseUpDown<float>.MinValueProperty.OverrideMetadata(
            ////                typeof(FloatUpDown), new PropertyMetadata(float.MinValue));
            ////
            ////            AbstractBaseUpDown<float>.MaxValueProperty.OverrideMetadata(
            ////                typeof(FloatUpDown), new PropertyMetadata(float.MaxValue));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Static class constructor
        /// </summary>
        static DoubleUpDown()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(DoubleUpDown),
                                                     new FrameworkPropertyMetadata(typeof(DoubleUpDown)));

            // overide default values inherited dependency properties
            FormatStringProperty.OverrideMetadata(typeof(DoubleUpDown),
                                                  new PropertyMetadata("F2"));

            MaxValueProperty.OverrideMetadata(typeof(DoubleUpDown),
                                              new PropertyMetadata(double.MaxValue));

            MinValueProperty.OverrideMetadata(typeof(DoubleUpDown),
                                              new PropertyMetadata(double.MinValue));

            // Override Min/Max default values
            ////            AbstractBaseUpDown<double>.MinValueProperty.OverrideMetadata(
            ////                typeof(DoubleUpDown), new PropertyMetadata(double.MinValue));
            ////
            ////            AbstractBaseUpDown<double>.MaxValueProperty.OverrideMetadata(
            ////                typeof(DoubleUpDown), new PropertyMetadata(double.MaxValue));
        }
Exemplo n.º 7
0
 set => this.SetValue(MinValueProperty, value);
Exemplo n.º 8
0
 set => SetValue(MinValueProperty, value);
Exemplo n.º 9
0
 set => base.SetValue(MinValueProperty, value);
Exemplo n.º 10
0
 set => SetCurrentValue(MinValueProperty, value);