Esempio n. 1
0
        /// <summary>
        /// Converts the provided value with the specified parameter back to <see cref="bool"/>.
        /// </summary>
        /// <param name="value">The value to convert.</param>
        /// <param name="options">The parameter, usually a string. For supported options, check the class constants starting with PARAM_.</param>
        public static bool?ConvertBack(object value, ref string options)
        {
            if (!(value is ScrollBarVisibility scrollBarVisibilityValue))
            {
                return(null);
            }

            var  trueEquivalent = GetTrueEquivalent(ref options);
            bool boolValue;

            if (scrollBarVisibilityValue == ScrollBarVisibility.Disabled)
            {
                boolValue = false;
            }
            else
            {
                if (scrollBarVisibilityValue != trueEquivalent)
                {
                    throw new Exception($"Value is not '{ScrollBarVisibility.Disabled}', but it is not a true equivalent either. The true equivalent is '{trueEquivalent}', but the provided value to convert to bool is '{scrollBarVisibilityValue}'.");
                }
                boolValue = true;
            }

            boolValue = (bool)BoolToBoolConverter.Convert(boolValue, ref options);

            return(boolValue);
        }
Esempio n. 2
0
        /// <summary>
        /// Converts the provided value with the specified parameter to <see cref="Visibility"/>.
        /// </summary>
        /// <param name="value">The value to convert.</param>
        /// <param name="options">The parameter, usually a string. For supported options, check the class constants starting with PARAM_.</param>
        public static Visibility?Convert(object value, ref string options)
        {
            bool?boolValue = BoolToBoolConverter.Convert(value, ref options);

            if (boolValue == null)
            {
                return(null);
            }

            var falseEquivalent = Visibility.Hidden;

            if (options != null)
            {
                // is already lowered in the BoolToBoolConverter
                //options = options.ToLowerInvariant();

                if (options.Contains(PARAM_COLLAPSE))
                {
                    falseEquivalent = Visibility.Collapsed;
                    options         = StringUtility.RemoveFirstOf(options, PARAM_COLLAPSE);
                }
            }

            return(boolValue.Value ? Visibility.Visible : falseEquivalent);
        }
Esempio n. 3
0
        /// <summary>
        /// Converts the provided value with the specified parameter to <see cref="ScrollBarVisibility"/>.
        /// </summary>
        /// <param name="value">The value to convert.</param>
        /// <param name="options">The parameter, usually a string. For supported options, check the class constants starting with PARAM_.</param>
        public static ScrollBarVisibility?Convert(object value, ref string options)
        {
            bool?boolValue = BoolToBoolConverter.Convert(value, ref options);

            if (boolValue == null)
            {
                return(null);
            }

            if (!boolValue.Value)
            {
                return(ScrollBarVisibility.Disabled);
            }
            else
            {
                // options is already lowered in the BoolToBoolConverter
                var trueEquivalent = GetTrueEquivalent(ref options, true);
                return(trueEquivalent);
            }
        }