public void InitAppAndPortalSettings(App app, int moduleId, PortalSettings portalSettings, IValueCollectionProvider provider) { foreach (var valueProvider in provider.Sources) { ValueSources.Add(valueProvider.Key, valueProvider.Value); } //// only add these in running inside an http-context. Otherwise leave them away! //if (HttpContext.Current != null) //{ // var request = HttpContext.Current.Request; // ValueSources.Add("querystring", new FilteredNameValueCollectionPropertyAccess(request.QueryString)); // ValueSources.Add("server", new FilteredNameValueCollectionPropertyAccess(request.ServerVariables)); // ValueSources.Add("form", new FilteredNameValueCollectionPropertyAccess(request.Form)); //} //ValueSources.Add("app", new AppPropertyAccess("app", app)); ////if (app.Settings != null) //// ValueSources.Add("appsettings", new DynamicEntityPropertyAccess("appsettings", app.Settings)); ////if (app.Resources != null) //// ValueSources.Add("appresources", new DynamicEntityPropertyAccess("appresources", app.Resources)); ModuleId = moduleId; PortalSettings = portalSettings; }
public void InitAppAndPortalSettings(App app, int moduleId, /*PortalSettings portalSettings,*/ IValueCollectionProvider provider) { foreach (var valueProvider in provider.Sources) { ValueSources.Add(valueProvider.Key, valueProvider.Value); } ModuleId = moduleId; //PortalSettings = portalSettings; }
protected override void OnSetRenderInfoCore(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { if (this._enumDropDown == null) { this._enumDropDown = new EnumDropDownValues <ValueSources>(); } this._isForwards = !newToken.GetProperty <BooleanProperty>(PropertyNames.FFTDirectionIsForward).Value; this._valueSource = this._enumDropDown.GetEnumMember(newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.ValueSource).Value); }
public MockBrushPropertyInfo(string name, string category, bool canWrite, string description = null, IReadOnlyList <string> colorSpaces = null, ValueSources valueSources = ValueSources.Default | ValueSources.Local | ValueSources.Resource, IReadOnlyList <PropertyVariation> variations = null, IReadOnlyList <IAvailabilityConstraint> availabilityConstraints = null) { Name = name; Description = description; Category = category; CanWrite = canWrite; ColorSpaces = colorSpaces; ValueSources = valueSources; Variations = variations; AvailabilityConstraints = availabilityConstraints; }
public MockPropertyInfo(string name, string description = null, string category = "", bool canWrite = true, IEnumerable <Type> converterTypes = null, ValueSources valueSources = ValueSources.Local | ValueSources.Default) { Name = name; Description = description; Category = category; CanWrite = canWrite; ValueSources = valueSources; if (converterTypes != null) { this.typeConverters = converterTypes .Where(type => type != null && typeof(TypeConverter).IsAssignableFrom(type)) .Select(type => (TypeConverter)Activator.CreateInstance(type)) .ToArray(); } if (typeof(T).IsValueType) { this.nullConverter = new NullableConverter(typeof(Nullable <>).MakeGenericType(typeof(T))); } }
public static Func <ColorBgra, double> GetGetValueFunc(this ValueSources valueSource) { if (valueSource == ValueSources.Red) { return((color) => { return color.R / 255.0; }); } if (valueSource == ValueSources.Green) { return((color) => { return color.G / 255.0; }); } if (valueSource == ValueSources.Blue) { return((color) => { return color.B / 255.0; }); } //if (valueSource == ValueSources.Intensity) return((color) => { return color.GetIntensity(); }); }
public void AddProperty <T> (string name, string category = "", bool canWrite = true, bool flag = false, IEnumerable <Type> converterTypes = null, string description = null, ValueSources valueSources = ValueSources.Local | ValueSources.Default) { IPropertyInfo propertyInfo; if (typeof(T).IsEnum) { var underlyingType = typeof(T).GetEnumUnderlyingType(); var enumPropertyInfoType = typeof(MockEnumPropertyInfo <,>) .MakeGenericType(underlyingType, typeof(T)); propertyInfo = (IPropertyInfo)Activator.CreateInstance(enumPropertyInfoType, name, description, category, canWrite, flag, converterTypes); } else { propertyInfo = new MockPropertyInfo <T> (name, description, category, canWrite, converterTypes); } AddProperty <T> (propertyInfo); }
protected override void OnSetRenderInfoCore(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { RectInt32 bounds = this.EnvironmentParameters.GetSelection(this.EnvironmentParameters.SourceSurface.Bounds).GetBoundsRectInt32(); if (this._enumDropDown == null) { this._enumDropDown = new EnumDropDownValues <ValueSources>(); } this._valueSource = this._enumDropDown.GetEnumMember(newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.ValueSource).Value); this._linkFrequencies = newToken.GetProperty <BooleanProperty>(PropertyNames.LinkCutoffFrequencies).Value; if (this.ShowSlidersLowPass) { this._lowPassX = newToken.GetProperty <DoubleProperty>(PropertyNames.CutoffFrequencyLowPassX).Value; if (this._linkFrequencies) { this._lowPassY = this._lowPassX / bounds.Width * bounds.Height; } else { this._lowPassY = newToken.GetProperty <DoubleProperty>(PropertyNames.CutoffFrequencyLowPassY).Value; } } if (this.ShowSlidersHighPass) { this._highPassX = newToken.GetProperty <DoubleProperty>(PropertyNames.CutoffFrequencyHighPassX).Value; if (this._linkFrequencies) { this._highPassY = this._highPassX / bounds.Width * bounds.Height; } else { this._highPassY = newToken.GetProperty <DoubleProperty>(PropertyNames.CutoffFrequencyHighPassY).Value; } } }
public MockPropertyInfo(string name, string description = null, string category = null, bool canWrite = true, IEnumerable <Type> converterTypes = null, ValueSources valueSources = ValueSources.Local | ValueSources.Default, PropertyVariationOption[] options = null, bool isUncommon = false, ITypeInfo realType = null) { Name = name; Description = description; Category = category; CanWrite = canWrite; IsUncommon = isUncommon; ValueSources = valueSources; if (converterTypes != null) { this.typeConverters = converterTypes .Where(type => type != null && typeof(TypeConverter).IsAssignableFrom(type)) .Select(type => (TypeConverter)Activator.CreateInstance(type)) .ToArray(); } if (typeof(T).IsValueType) { this.nullConverter = new NullableConverter(typeof(Nullable <>).MakeGenericType(typeof(T))); } Variations = options ?? EmptyVariationOptions; RealType = realType ?? typeof(T).ToTypeInfo(); }
public static Func <double, ColorBgra> GetGetColorFunc(this ValueSources valueSource) { if (valueSource == ValueSources.Red) { return((red) => { return ColorBgra.FromBgr(0, 0, (byte)Math.Round(255 * red)); }); } if (valueSource == ValueSources.Green) { return((green) => { return ColorBgra.FromBgr(0, (byte)Math.Round(255 * green), 0); }); } if (valueSource == ValueSources.Blue) { return((blue) => { return ColorBgra.FromBgr((byte)Math.Round(255 * blue), 0, 0); }); } //if (valueSource == ValueSources.Intensity) return((intensity) => { byte i = (byte)Math.Round(255 * intensity); return ColorBgra.FromBgr(i, i, i); }); }
public DescriptorPropertyInfo(PropertyDescriptor propertyInfo, object propertyProvider, ValueSources valueSources) { this.PropertyDescriptor = propertyInfo; this.PropertyProvider = propertyProvider; this.valueSources = valueSources; }
public FlagDescriptorPropertyInfo(TypeDescriptorContext typeDescriptorContext, ValueSources valueSources) : base(typeDescriptorContext, valueSources) { IsValueCombinable = true; elements = Enum.GetValues(typeDescriptorContext.PropertyDescriptor.PropertyType); foreach (object value in elements) { ulong uintVal = Convert.ToUInt64(value); predefinedValues.Add(value.ToString(), uintVal.ToString()); } }
public DescriptorPropertyInfo(TypeDescriptorContext typeDescriptorContext, ValueSources valueSources) { this.typeDescriptorContext = typeDescriptorContext; this.ValueSources = valueSources; }
public void AddProperty <T> (string name, string category = null, bool canWrite = true, bool flag = false, IEnumerable <Type> converterTypes = null, string description = null, bool constrained = true, ValueSources valueSources = ValueSources.Local | ValueSources.Default | ValueSources.Binding, IReadOnlyList <InputMode> inputModes = null, PropertyVariationOption[] options = null, bool isUncommon = false, ITypeInfo realType = null, bool ignoreEnum = false) { IPropertyInfo propertyInfo; if (typeof(T).IsEnum && !ignoreEnum) { var underlyingType = typeof(T).GetEnumUnderlyingType(); var enumPropertyInfoType = typeof(MockEnumPropertyInfo <,>) .MakeGenericType(underlyingType, typeof(T)); propertyInfo = (IPropertyInfo)Activator.CreateInstance(enumPropertyInfoType, name, description, category, canWrite, flag, converterTypes, constrained, options); } else if (inputModes != null) { propertyInfo = new MockPropertyInfoWithInputTypes <T> (name, inputModes, description, category, canWrite, converterTypes, valueSources, options); } else { propertyInfo = new MockPropertyInfo <T> (name, description, category, canWrite, converterTypes, valueSources, options, isUncommon, realType); } AddProperty <T> (propertyInfo); }
public EnumDescriptorPropertyInfo(TypeDescriptorContext typeDescriptorContext, ValueSources valueSources) : base(typeDescriptorContext, valueSources) { values = Enum.GetValues(PropertyDescriptor.PropertyType); var fields = PropertyDescriptor.PropertyType.GetFields(); names = new Hashtable(); foreach (System.Reflection.FieldInfo f in fields) { var att = (DescriptionAttribute)Attribute.GetCustomAttribute(f, typeof(DescriptionAttribute)); if (att != null) { names [f.Name] = att.Description; } else { names [f.Name] = f.Name; } } for (int i = 0; i < values.Length; i++) { //name var value = values.GetValue(i); string str = PropertyDescriptor.Converter.ConvertToString(value); if (names.Contains(str)) { str = (string)names [str]; } predefinedValues.Add(str, i.ToString()); } }
public FilePathPropertyInfo(TypeDescriptorContext typeDescriptorContext, ValueSources valueSources) : base(typeDescriptorContext, valueSources) { }
public FlagDescriptorPropertyInfo(PropertyDescriptor propertyDescriptor, object propertyProvider, ValueSources valueSources) : base(propertyDescriptor, propertyProvider, valueSources) { IsValueCombinable = true; foreach (object value in System.Enum.GetValues(propertyDescriptor.PropertyType)) { ulong uintVal = Convert.ToUInt64(value); predefinedValues.Add(value.ToString(), uintVal.ToString()); } }
public StringStandardValuesPropertyInfo(TypeConverter.StandardValuesCollection standardValuesCollection, TypeDescriptorContext typeDescriptorContext, ValueSources valueSources) : base(typeDescriptorContext, valueSources) { foreach (object stdValue in standardValuesCollection) { var value = PropertyDescriptor.Converter.ConvertToString(stdValue); if (value == ComponentModelObjectEditor.ComboSeparatorString) { //TODO: we need implement in proppy a way to allow separators continue; } standardValues.Add(value, stdValue); predefinedValues.Add(value, value); } }
public FilePathPropertyInfo(PropertyDescriptor propertyInfo, object propertyProvider, ValueSources valueSources) : base(propertyInfo, propertyProvider, valueSources) { }
public MockPropertyInfoWithInputTypes(string name, IReadOnlyList <InputMode> inputModes, string description = null, string category = null, bool canWrite = true, IEnumerable <Type> converterTypes = null, ValueSources valueSources = ValueSources.Default | ValueSources.Local, PropertyVariationOption[] variations = null) : base(name, description, category, canWrite, converterTypes, valueSources, variations) { InputModes = inputModes.ToArray(); }
public StringStandardValuesPropertyInfo(PropertyDescriptor propertyDescriptor, object propertyProvider, ValueSources valueSources) : base(propertyDescriptor, propertyProvider, valueSources) { foreach (object stdValue in PropertyDescriptor.Converter.GetStandardValues()) { var value = PropertyDescriptor.Converter.ConvertToString(stdValue); predefinedValues.Add(value, value); } }