/// <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}'"); * }*/ }
public CssSelector(bool IsFromStylesheet, ReadOnlySpan <char> Selector) : base(CssSelector.Parse(Selector)) { this.IsFromStylesheet = IsFromStylesheet; }
/// <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) { }
public CssSelector(ReadOnlySpan <char> Selector) : base(CssSelector.Parse(Selector)) { this.IsFromStylesheet = false; }