Ejemplo n.º 1
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == DependencyProperty.UnsetValue)
            {
                return(value);
            }
            else if (Converter1 == null || Converter2 == null)
            {
                List <IValueConverter> convertersReverseList = new List <IValueConverter>(Converters);
                convertersReverseList.Reverse();

                foreach (var converter in convertersReverseList)
                {
                    value = converter.ConvertBack(value, targetType, parameter, culture);
                    if (value == Binding.DoNothing)
                    {
                        return(Binding.DoNothing);
                    }
                    if (value == DependencyProperty.UnsetValue)
                    {
                        return(DependencyProperty.UnsetValue);
                    }
                }

                return(value);
            }
            else
            {
                return(Converter1.ConvertBack(Converter2.ConvertBack(value, targetType, parameter, culture), targetType, parameter, culture));
            }
        }
Ejemplo n.º 2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == DependencyProperty.UnsetValue)
            {
                return(value);
            }
            else if (Converter1 == null || Converter2 == null)
            {
                foreach (var converter in Converters)
                {
                    value = converter.Convert(value, targetType, parameter, culture);
                    if (value == Binding.DoNothing)
                    {
                        return(Binding.DoNothing);
                    }
                    if (value == DependencyProperty.UnsetValue)
                    {
                        return(DependencyProperty.UnsetValue);
                    }
                }

                return(value);
            }
            else
            {
                return(Converter2.Convert(Converter1.Convert(value, targetType, Converter1Parameter ?? parameter, culture), targetType, Converter2Parameter ?? parameter, culture));
            }
        }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Any(x => x == DependencyProperty.UnsetValue))
            {
                return(DependencyProperty.UnsetValue);
            }

            var          averageMoney  = Converter1.Convert(values, targetType, parameter, culture);
            var          amountPaid    = (double)values[2];
            var          missingAmount = (double)averageMoney - amountPaid;
            const double precise       = 0.0000001;
            var          isNotEqual    = Math.Abs(missingAmount) >= precise && missingAmount >= 0.0;

            string status;

            if (isNotEqual)
            {
                object missingAmountConvertedValue = Converter2.Convert(missingAmount, targetType, parameter, culture);
                status = $"Thiếu: {missingAmountConvertedValue}";
            }
            else
            {
                status = "Đã thu đủ";
            }

            return(status);
        }
Ejemplo n.º 4
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Any(x => x == DependencyProperty.UnsetValue))
            {
                return(DependencyProperty.UnsetValue);
            }
            var avarageMoney = Converter1.Convert(values, targetType, parameter, culture);
            var MoneyString  = Converter2.Convert(avarageMoney, targetType, parameter, culture);
            var result       = Converter3.Convert(MoneyString, targetType, parameter, culture);

            return(result);
        }
Ejemplo n.º 5
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            object convertedValue = Converter1.Convert(value, targetType, parameter, culture);

            return(Converter2.Convert(convertedValue, targetType, parameter, culture));
        }
Ejemplo n.º 6
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            object convertedValue = Converter1.Convert(values, targetType, parameter, culture);

            return(Converter2.Convert(convertedValue, targetType, parameter, culture));
        }