Utiliza una deduccion de propiedades muy agresiva: Value (binding) -> ValueType -> ValueLineType -> ValueControl
Inheritance: LineBase
Esempio n. 1
0
        public virtual bool SetToolTipStyle(ValueLine vl)
        {
            if (vl.ValueLineType == ValueLineType.String)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public virtual IValueConverter GetReadOnlyConverter(ValueLine vl)
        {
            if (vl.ValueLineType == ValueLineType.Boolean || vl.ValueLineType == ValueLineType.Enum)
            {
                return(Converters.Not);
            }

            return(null);
        }
Esempio n. 3
0
        public virtual ValidationRule GetValidation(ValueLine vl)
        {
            if (vl.Type.IsValueType && !vl.Type.IsNullable())
            {
                return(NotNullValidationRule.Instance);
            }

            return(null);
        }
Esempio n. 4
0
        public virtual UpdateSourceTrigger GetUpdateSourceTrigger(ValueLine vl)
        {
            if (vl.ValueLineType == ValueLineType.Number || vl.ValueLineType == ValueLineType.Boolean)
            {
                return(UpdateSourceTrigger.PropertyChanged);
            }

            return(UpdateSourceTrigger.LostFocus);
        }
Esempio n. 5
0
        static void TaskSetNotNullItemsSource(FrameworkElement fe, string route, PropertyRoute context)
        {
            ValueLine vl = fe as ValueLine;

            if (vl != null && vl.NotSet(ValueLine.ItemSourceProperty) && context.PropertyRouteType == PropertyRouteType.FieldOrProperty)
            {
                if (context.Type.IsNullable() && context.Type.UnNullify().IsEnum&&
                    Validator.TryGetPropertyValidator(context).Let(pv => pv != null && pv.Validators.OfType <NotNullValidatorAttribute>().Any()))
                {
                    vl.ItemSource = EnumExtensions.UntypedGetValues(vl.Type.UnNullify()).ToObservableCollection();
                }
            }
        }
Esempio n. 6
0
        static void TaskSetUnitText(FrameworkElement fe, string route, PropertyRoute context)
        {
            ValueLine vl = fe as ValueLine;

            if (vl != null && vl.NotSet(ValueLine.UnitTextProperty) && context.PropertyRouteType == PropertyRouteType.FieldOrProperty)
            {
                UnitAttribute ua = context.PropertyInfo.GetCustomAttribute <UnitAttribute>();
                if (ua != null)
                {
                    vl.UnitText = ua.UnitName;
                }
            }
        }
Esempio n. 7
0
        static void TaskSetFormatText(FrameworkElement fe, string route, PropertyRoute context)
        {
            ValueLine vl = fe as ValueLine;

            if (vl != null && vl.NotSet(ValueLine.FormatProperty) && context.PropertyRouteType == PropertyRouteType.FieldOrProperty)
            {
                string format = Reflector.FormatString(context);
                if (format != null)
                {
                    vl.Format = format;
                }
            }
        }
Esempio n. 8
0
        static void TaskSetMaxLenth(FrameworkElement fe, string route, PropertyRoute context)
        {
            ValueLine vl = fe as ValueLine;

            if (vl != null && context.PropertyRouteType == PropertyRouteType.FieldOrProperty && context.Type == typeof(string))
            {
                var slv = Validator.TryGetPropertyValidator(context)?.Validators.OfType <StringLengthValidatorAttribute>().FirstOrDefault();
                if (slv != null && slv.Max != -1)
                {
                    vl.MaxTextLength = slv.Max;
                }

                //if (slv != null && slv.MultiLine)
                //    vl.ValueLineType = ValueLineType.TextArea;
            }
        }
Esempio n. 9
0
        public virtual IValueConverter GetConverter(ValueLine vl)
        {
            if (vl.ValueLineType == ValueLineType.Enum && vl.Type.IsNullable())
            {
                return(Converters.NullableEnum);
            }

            if (vl.ValueLineType == ValueLineType.Color)
            {
                return(Converters.Color);
            }

            if (vl.Type.IsNullable())
            {
                return(Converters.Identity);
            }

            return(null);
        }
        public static Control GetValueControl(QueryToken token, string bindingPath)
        {
            Type type = token.Type;

            if (type.IsLite())
            {
                Implementations implementations = token.GetImplementations().Value;

                Type cleanType = Lite.Extract(type);

                if (EntityKindCache.IsLowPopulation(cleanType) && !implementations.IsByAll)
                {
                    EntityCombo ec = new EntityCombo
                    {
                        Type            = type,
                        Implementations = implementations,
                    };

                    ec.SetBinding(EntityCombo.EntityProperty, new Binding
                    {
                        Path = new PropertyPath(bindingPath),
                        NotifyOnValidationError = true,
                        ValidatesOnDataErrors   = true,
                        ValidatesOnExceptions   = true,
                    });

                    return(ec);
                }
                else
                {
                    EntityLine el = new EntityLine
                    {
                        Type            = type,
                        Create          = false,
                        Implementations = implementations,
                    };

                    el.SetBinding(EntityLine.EntityProperty, new Binding
                    {
                        Path = new PropertyPath(bindingPath),
                        NotifyOnValidationError = true,
                        ValidatesOnDataErrors   = true,
                        ValidatesOnExceptions   = true
                    });

                    return(el);
                }
            }
            else if (type.IsEmbeddedEntity())
            {
                EntityLine el = new EntityLine
                {
                    Type            = type,
                    Create          = false,
                    Autocomplete    = false,
                    Find            = false,
                    Implementations = null,
                };

                el.SetBinding(EntityLine.EntityProperty, new Binding
                {
                    Path = new PropertyPath(bindingPath),
                    NotifyOnValidationError = true,
                    ValidatesOnDataErrors   = true,
                    ValidatesOnExceptions   = true
                });

                return(el);
            }
            else
            {
                ValueLine vl = new ValueLine()
                {
                    Type     = type,
                    Format   = token.Format,
                    UnitText = token.Unit,
                };

                if (type.UnNullify().IsEnum)
                {
                    vl.ItemSource = EnumEntity.GetValues(type.UnNullify()).PreAndNull(type.IsNullable()).ToObservableCollection();
                }

                vl.SetBinding(ValueLine.ValueProperty, new Binding
                {
                    Path = new PropertyPath(bindingPath), //odd
                    NotifyOnValidationError = true,
                    ValidatesOnDataErrors   = true,
                    ValidatesOnExceptions   = true,
                    Converter = Reflector.IsNumber(type) ? Converters.Identity : null,
                });

                return(vl);
            }
        }
Esempio n. 11
0
 private void BindParameter(ValueLine vl)
 {
     vl.Bind(ValueLine.ItemSourceProperty, "", EnumValues);
     vl.Bind(ValueLine.ValueLineTypeProperty, "ScriptParameter.Type", ParameterType);
 }
Esempio n. 12
0
        public virtual IValueConverter GetReadOnlyConverter(ValueLine vl)
        {
            if (vl.ValueLineType == ValueLineType.Boolean || vl.ValueLineType == ValueLineType.Enum)
                return Converters.Not;

            return null;
        }
Esempio n. 13
0
        public virtual UpdateSourceTrigger GetUpdateSourceTrigger(ValueLine vl)
        {
            if (vl.ValueLineType == ValueLineType.Number || vl.ValueLineType == ValueLineType.Boolean)
                return UpdateSourceTrigger.PropertyChanged; 

            return UpdateSourceTrigger.LostFocus;
            
        }
Esempio n. 14
0
        public virtual bool SetToolTipStyle(ValueLine vl)
        {
            if (vl.ValueLineType == ValueLineType.String)
                return false;

            return true; 
        }
Esempio n. 15
0
        public virtual ValidationRule GetValidation(ValueLine vl)
        {
            if (vl.Type.IsValueType && !vl.Type.IsNullable())
                return NotNullValidationRule.Instance;

            return null;
        }
Esempio n. 16
0
        public virtual IValueConverter GetConverter(ValueLine vl)
        {
            if (vl.ValueLineType == ValueLineType.Enum && vl.Type.IsNullable())
                return Converters.NullableEnum;

            if (vl.ValueLineType == ValueLineType.Color)
                return Converters.Color;

            if (vl.Type.IsNullable())
                return Converters.Identity;

            return null;
        }
Esempio n. 17
0
        public static Control GetValueControl(QueryToken token, string bindingPath)
        {
            Type type = token.Type;
            if (type.IsLite())
            {
                Implementations implementations = token.GetImplementations().Value;

                Type cleanType = Lite.Extract(type);

                if (EntityKindCache.IsLowPopulation(cleanType) && !implementations.IsByAll)
                {
                    EntityCombo ec = new EntityCombo
                    {
                        Type = type,
                        Implementations = implementations,
                    };

                    ec.SetBinding(EntityCombo.EntityProperty, new Binding
                    {
                        Path = new PropertyPath(bindingPath),
                        NotifyOnValidationError = true,
                        ValidatesOnDataErrors = true,
                        ValidatesOnExceptions = true,
                    });

                    return ec;
                }
                else
                {
                    EntityLine el = new EntityLine
                    {
                        Type = type,
                        Create = false,
                        Implementations = implementations,
                    };

                    el.SetBinding(EntityLine.EntityProperty, new Binding
                    {
                        Path = new PropertyPath(bindingPath),
                        NotifyOnValidationError = true,
                        ValidatesOnDataErrors = true,
                        ValidatesOnExceptions = true
                    });

                    return el;
                }
            }
            else if (type.IsEmbeddedEntity())
            {
                EntityLine el = new EntityLine
                {
                    Type = type,
                    Create = false,
                    Autocomplete = false,
                    Find = false,
                    Implementations = null,
                };

                el.SetBinding(EntityLine.EntityProperty, new Binding
                {
                    Path = new PropertyPath(bindingPath),
                    NotifyOnValidationError = true,
                    ValidatesOnDataErrors = true,
                    ValidatesOnExceptions = true
                });

                return el;
            }
            else
            {
                ValueLine vl = new ValueLine()
                {
                    Type = type,
                    Format = token.Format,
                    UnitText = token.Unit,
                };

                if (type.UnNullify().IsEnum)
                {
                    vl.ItemSource = EnumEntity.GetValues(type.UnNullify()).PreAndNull(type.IsNullable()).ToObservableCollection();
                }

                vl.SetBinding(ValueLine.ValueProperty, new Binding
                {
                    Path = new PropertyPath(bindingPath), //odd
                    NotifyOnValidationError = true,
                    ValidatesOnDataErrors = true,
                    ValidatesOnExceptions = true,
                    Converter = Reflector.IsNumber(type) ? Converters.Identity : null,
                });

                return vl;
            }
        }