Esempio n. 1
0
        /// <summary>
        /// Creates a new property set under the specified name and binds to it to detect when a value changes.
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Selector"></param>
        /// <param name="Owner"></param>
        /// <param name="Unset"></param>
        /// <returns></returns>
        private CssComputedStyle NewPropertySet(string Name, string Selector, ICssElement Owner, bool Unset, EPropertySetOrigin Origin)
        {
            var retVal = new CssComputedStyle(Name, new CssSelector(false, Selector), Owner, false, Unset, Origin);

            // Capture all update events.
            retVal.Property_Changed += Handle_Declared_Property_Change;
            return(retVal);
        }
Esempio n. 2
0
        public StyleProperties(ICssElement owning_element)
        {
            owningElement = owning_element;

            // Populate our rules with a few different common states
            CssRules.TryAdd(STATE_IMPLICIT, NewPropertySet(STATE_IMPLICIT, null, owning_element, false, EPropertySetOrigin.UserAgent));
            CssRules.TryAdd(STATE_USER, NewPropertySet(STATE_USER, null, owning_element, true, EPropertySetOrigin.Author));

            CssRules.TryAdd(STATE_HOVER, NewPropertySet(STATE_HOVER, ":hover", owning_element, true, EPropertySetOrigin.Author));
            CssRules.TryAdd(STATE_FOCUS, NewPropertySet(STATE_FOCUS, ":focus", owning_element, true, EPropertySetOrigin.Author));

            Cascaded = new CssComputedStyle(null, null, owning_element, true);
            Cascaded.Property_Changed += Handle_Cascaded_Property_Change;
            // Blending
            Cascaded.Opacity.onValueChange += Handle_Cascaded_Blend_Change;
            // Transformations
            Cascaded.Transform.onValueChange += Handle_Cascaded_Transform_Change;
        }
Esempio n. 3
0
 public MultiStringProperty(AtomicName <ECssPropertyID> CssName, ICssElement Owner, WeakReference <CssComputedStyle> Source, bool Locked)
     : base(CssName, Locked, Source, Owner)
 {
 }
Esempio n. 4
0
 public NullableLengthProperty(AtomicName <ECssPropertyID> CssName, ICssElement Owner, WeakReference <CssComputedStyle> Source, bool Locked)
     : base(CssName, Owner, Source, Locked)
 {
 }
Esempio n. 5
0
        /// <summary>
        /// Creates a new set of element styling properties
        /// </summary>
        /// <param name="ReadOnly">If TRUE then none of this instances property values may be set directly.</param>
        /// <param name="Unset">If TRUE then property values will all be set to <see cref="CssValue.Null"/>.</param>
        public CssComputedStyle(string Name, CssSelector Selector, ICssElement Owner, bool ReadOnly = false, bool Unset = false, EPropertySetOrigin Origin = EPropertySetOrigin.Author)
        {
            this.Name     = Name;
            this.Selector = Selector;
            this.Origin   = Origin;
            this.ReadOnly = ReadOnly;
            var selfRef = new WeakReference <CssComputedStyle>(this);

            CssProperties = new List <ICssProperty>(MAX_PROPERTY_ID_INDEX + 1);

            CssProperties[(int)ECssPropertyID.Top]    = new IntProperty(ECssPropertyID.Top, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.Right]  = new IntProperty(ECssPropertyID.Right, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.Bottom] = new IntProperty(ECssPropertyID.Bottom, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.Left]   = new IntProperty(ECssPropertyID.Left, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.Direction]   = new EnumProperty <EDirection>(ECssPropertyID.Direction, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.WritingMode] = new EnumProperty <EWritingMode>(ECssPropertyID.WritingMode, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.Display]     = new EnumProperty <EDisplayMode>(ECssPropertyID.Display, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.BoxSizing]   = new EnumProperty <EBoxSizingMode>(ECssPropertyID.BoxSizing, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.Positioning] = new EnumProperty <EBoxPositioning>(ECssPropertyID.Positioning, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.ScrollBehavior] = new EnumProperty <EScrollBehavior>(ECssPropertyID.ScrollBehavior, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.OverflowX]      = new EnumProperty <EOverflowMode>(ECssPropertyID.OverflowX, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.OverflowY]      = new EnumProperty <EOverflowMode>(ECssPropertyID.OverflowY, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.ObjectFit] = new EnumProperty <EObjectFit>(ECssPropertyID.ObjectFit, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.ObjectPosition] = new PositionProperty(ECssPropertyID.ObjectPosition, Owner, selfRef, this.ReadOnly);
            // CssProperties[(int)ECssPropertyID.ObjectPositionX] = new IntProperty(ECssPropertyID.ObjectPositionX, Owner, selfRef, this.ReadOnly);
            // CssProperties[(int)ECssPropertyID.ObjectPositionY] = new IntProperty(ECssPropertyID.ObjectPositionY, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.Width]  = new IntProperty(ECssPropertyID.Width, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.Height] = new IntProperty(ECssPropertyID.Height, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.MinWidth]  = new IntProperty(ECssPropertyID.MinWidth, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.MinHeight] = new IntProperty(ECssPropertyID.MinHeight, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.MaxWidth]  = new NullableIntProperty(ECssPropertyID.MaxWidth, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.MaxHeight] = new NullableIntProperty(ECssPropertyID.MaxHeight, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.MarginTop]    = new IntProperty(ECssPropertyID.MarginTop, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.MarginRight]  = new IntProperty(ECssPropertyID.MarginRight, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.MarginBottom] = new IntProperty(ECssPropertyID.MarginBottom, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.MarginLeft]   = new IntProperty(ECssPropertyID.MarginLeft, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.PaddingTop]    = new IntProperty(ECssPropertyID.PaddingTop, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.PaddingRight]  = new IntProperty(ECssPropertyID.PaddingRight, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.PaddingBottom] = new IntProperty(ECssPropertyID.PaddingBottom, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.PaddingLeft]   = new IntProperty(ECssPropertyID.PaddingLeft, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.BorderTopStyle]    = new EnumProperty <EBorderStyle>(ECssPropertyID.BorderTopStyle, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.BorderRightStyle]  = new EnumProperty <EBorderStyle>(ECssPropertyID.BorderRightStyle, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.BorderBottomStyle] = new EnumProperty <EBorderStyle>(ECssPropertyID.BorderBottomStyle, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.BorderLeftStyle]   = new EnumProperty <EBorderStyle>(ECssPropertyID.BorderLeftStyle, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.BorderTopWidth]    = new IntProperty(ECssPropertyID.BorderTopWidth, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.BorderRightWidth]  = new IntProperty(ECssPropertyID.BorderRightWidth, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.BorderBottomWidth] = new IntProperty(ECssPropertyID.BorderBottomWidth, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.BorderLeftWidth]   = new IntProperty(ECssPropertyID.BorderLeftWidth, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.TextAlign] = new EnumProperty <ETextAlign>(ECssPropertyID.TextAlign, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.DpiX]       = new NumberProperty(ECssPropertyID.DpiX, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.DpiY]       = new NumberProperty(ECssPropertyID.DpiY, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.FontWeight] = new IntProperty(ECssPropertyID.FontWeight, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.FontStyle]  = new EnumProperty <EFontStyle>(ECssPropertyID.FontStyle, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.FontSize]   = new NumberProperty(ECssPropertyID.FontSize, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.FontFamily] = new MultiStringProperty(ECssPropertyID.FontFamily, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.Color]   = new ColorProperty(ECssPropertyID.Color, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.Opacity] = new NumberProperty(ECssPropertyID.Opacity, Owner, selfRef, this.ReadOnly);

            CssProperties[(int)ECssPropertyID.LineHeight] = new IntProperty(ECssPropertyID.LineHeight, Owner, selfRef, this.ReadOnly);
            CssProperties[(int)ECssPropertyID.Transform]  = new TransformListProperty(ECssPropertyID.Transform, Owner, selfRef, this.ReadOnly);

            /*CssPropertyMap = new ConcurrentDictionary<AtomicName<ECssPropertyID>, ICssProperty>(3, CssProperties.Count);
             * for (int i = 0; i < CssProperties.Count; i++)
             * {
             *  ICssProperty p = CssProperties[i];
             *  p.Selector = Selector;
             *  p.onValueChange += Property_onChanged;
             *
             *  bool success = CssPropertyMap.TryAdd(p.CssName, p);
             *  if (!success)
             *      throw new Exception($"Failed to fully form {nameof(CssPropertyMap)} for {nameof(CssPropertySet)}. Failed on member: '{p.CssName}'");
             * }*/
        }
Esempio n. 6
0
 /// <summary>
 /// Creates a new set of element styling properties
 /// </summary>
 /// <param name="ReadOnly">If TRUE then none of this instances property values may be set directly.</param>
 /// <param name="Unset">If TRUE then property values will all be set to <see cref="CssValue.Null"/>.</param>
 public CssComputedStyle(CssSelector Selector, ICssElement Owner, bool ReadOnly = false, bool Unset = false) : this(null, Selector, Owner, ReadOnly, Unset)
 {
 }
Esempio n. 7
0
 /// <summary>
 /// Creates a new set of element styling properties
 /// </summary>
 /// <param name="ReadOnly">If TRUE then none of this instances property values may be set directly.</param>
 public CssComputedStyle(string Name, ICssElement Owner, bool ReadOnly = false) : this(Name, null, Owner, ReadOnly)
 {
 }