Пример #1
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                foreach (var value in values)
                {
                    CheckType(value.GetType());
                }
                Thickness result     = new Thickness();
                var       properties = result.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
                int       count      = values.Length < 4 ? values.Length : 4;

                if (count > 0)
                {
                    result.Left = ToDouble(values[0]);
                }

                if (count > 1)
                {
                    result.Top = ToDouble(values[1]);
                }

                if (count > 2)
                {
                    result.Right = ToDouble(values[2]);
                }

                if (count > 3)
                {
                    result.Bottom = ToDouble(values[3]);
                }

                return(result);
            }

            catch (Exception)
            {
                return(null);
            }
        }