コード例 #1
0
        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;
        }
コード例 #2
0
ファイル: TokenReplaceEAV.cs プロジェクト: webworkadmin/2sxc
        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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 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;
 }
コード例 #5
0
        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)));
            }
        }
コード例 #6
0
        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(); });
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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;
                }
            }
        }
コード例 #9
0
        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();
        }
コード例 #10
0
        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);
            });
        }
コード例 #11
0
 public DescriptorPropertyInfo(PropertyDescriptor propertyInfo, object propertyProvider, ValueSources valueSources)
 {
     this.PropertyDescriptor = propertyInfo;
     this.PropertyProvider   = propertyProvider;
     this.valueSources       = valueSources;
 }
コード例 #12
0
        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());
            }
        }
コード例 #13
0
 public DescriptorPropertyInfo(TypeDescriptorContext typeDescriptorContext, ValueSources valueSources)
 {
     this.typeDescriptorContext = typeDescriptorContext;
     this.ValueSources          = valueSources;
 }
コード例 #14
0
        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);
        }
コード例 #15
0
        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());
            }
        }
コード例 #16
0
 public FilePathPropertyInfo(TypeDescriptorContext typeDescriptorContext, ValueSources valueSources) : base(typeDescriptorContext, valueSources)
 {
 }
コード例 #17
0
 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());
     }
 }
コード例 #18
0
 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);
     }
 }
コード例 #19
0
 public FilePathPropertyInfo(PropertyDescriptor propertyInfo, object propertyProvider, ValueSources valueSources) : base(propertyInfo, propertyProvider, valueSources)
 {
 }
コード例 #20
0
 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();
 }
コード例 #21
0
 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);
     }
 }