public virtual bool SetToolTipStyle(ValueLine vl) { if (vl.ValueLineType == ValueLineType.String) { return(false); } return(true); }
public virtual IValueConverter GetReadOnlyConverter(ValueLine vl) { if (vl.ValueLineType == ValueLineType.Boolean || vl.ValueLineType == ValueLineType.Enum) { return(Converters.Not); } return(null); }
public virtual ValidationRule GetValidation(ValueLine vl) { if (vl.Type.IsValueType && !vl.Type.IsNullable()) { return(NotNullValidationRule.Instance); } return(null); }
public virtual UpdateSourceTrigger GetUpdateSourceTrigger(ValueLine vl) { if (vl.ValueLineType == ValueLineType.Number || vl.ValueLineType == ValueLineType.Boolean) { return(UpdateSourceTrigger.PropertyChanged); } return(UpdateSourceTrigger.LostFocus); }
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(); } } }
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; } } }
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; } } }
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; } }
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); } }
private void BindParameter(ValueLine vl) { vl.Bind(ValueLine.ItemSourceProperty, "", EnumValues); vl.Bind(ValueLine.ValueLineTypeProperty, "ScriptParameter.Type", ParameterType); }
public virtual IValueConverter GetReadOnlyConverter(ValueLine vl) { if (vl.ValueLineType == ValueLineType.Boolean || vl.ValueLineType == ValueLineType.Enum) return Converters.Not; return null; }
public virtual UpdateSourceTrigger GetUpdateSourceTrigger(ValueLine vl) { if (vl.ValueLineType == ValueLineType.Number || vl.ValueLineType == ValueLineType.Boolean) return UpdateSourceTrigger.PropertyChanged; return UpdateSourceTrigger.LostFocus; }
public virtual bool SetToolTipStyle(ValueLine vl) { if (vl.ValueLineType == ValueLineType.String) return false; return true; }
public virtual ValidationRule GetValidation(ValueLine vl) { if (vl.Type.IsValueType && !vl.Type.IsNullable()) return NotNullValidationRule.Instance; return null; }
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; } }