Ejemplo n.º 1
0
 public override void SetStyle(QLSStyle style)
 {
     Styles = new List <QLSStyle>()
     {
         style
     };
 }
Ejemplo n.º 2
0
        private bool RetrieveValidStyle(QLSStyle[] styles, out QLSStyle style)
        {
            style = null;
            foreach (QLSStyle qlsStyle in styles)
            {
                if (qlsStyle.QValueType == GetQValueType())
                {
                    style = qlsStyle;
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        public override void ApplyParentStyle(params QLSStyle[] styles)
        {
            QLSStyle style;

            if (!RetrieveValidStyle(styles, out style))
            {
                return;
            }

            _style = Util.CombineStyles(_style, style);

            string[] errors = new string[0];
            _styleParser?.ParseStyle(_style, out errors);
        }
        private static ElementManagerLeaf AddQLSToLeaf(QLSNode node, ElementManagerLeaf leaf)
        {
            QLSStyle style = new QLSStyle(QValueType.Unknown, new QLSWidgetSpecification(WidgetType.Default, new List <string>()));

            if (node.NodeStyles.Count > 1)
            {
                throw new InvalidOperationException("Multiple styles in leaf node");
            }
            else if (node.NodeStyles.Count == 1)
            {
                style = node.NodeStyles[0];
            }

            leaf.SetStyle(style);
            return(leaf);
        }
Ejemplo n.º 5
0
        public static QLSStyle CombineStyles(QLSStyle dominantStyle, QLSStyle style)
        {
            QLSStyle result = new QLSStyle(dominantStyle.QValueType, dominantStyle.WidgetSpecification);

            foreach (var styleValue in dominantStyle.StylingValues)
            {
                result.AddStyleValue(styleValue);
            }

            foreach (var styleValue in style.StylingValues)
            {
                if (!result.GetStylingValues().Select(x => x.StyleProperty).Contains(styleValue.StyleProperty))
                {
                    result.AddStyleValue(styleValue);
                }
            }

            return(result);
        }
Ejemplo n.º 6
0
 public abstract void SetStyle(QLSStyle style);
Ejemplo n.º 7
0
 public override void SetStyle(QLSStyle style)
 {
     _style = style;
 }
Ejemplo n.º 8
0
 public void ParseStyle(QLSStyle qlsValues, out string[] errors)
 {
     _styleParser.ParseStyle(qlsValues, out errors);
 }
Ejemplo n.º 9
0
 public WidgetLeafBuilder(Y elementManagerLeaf) : base(elementManagerLeaf)
 {
     _style = elementManagerLeaf.GetStyle();
 }
Ejemplo n.º 10
0
        public void ParseStyle(QLSStyle qlsStyle, out string[] errors)
        {
            List <string>  collectedErrors = new List <string>();
            ColorConverter colorConverter  = new ColorConverter();

            foreach (QLSValue qlsValue in qlsStyle.GetStylingValues())
            {
                if (_supportedStyleProperties.ContainsKey(qlsValue.StyleProperty) && qlsValue.QValueType == _supportedStyleProperties[qlsValue.StyleProperty].Item2)
                {
                    try
                    {
                        StyleProperty styleProperty = _supportedStyleProperties[qlsValue.StyleProperty].Item1;
                        switch (styleProperty)
                        {
                        case StyleProperty.Height:
                            Height = QValueTypeParser.ParseInteger(qlsValue.StyleValue);
                            break;

                        case StyleProperty.Width:
                            Width = QValueTypeParser.ParseInteger(qlsValue.StyleValue);
                            break;

                        case StyleProperty.MarginTop:
                            MarginTop = QValueTypeParser.ParseInteger(qlsValue.StyleValue);
                            break;

                        case StyleProperty.MarginBottom:
                            MarginBottom = QValueTypeParser.ParseInteger(qlsValue.StyleValue);
                            break;

                        case StyleProperty.BackgroundColor:
                            BackgroundColor = QValueTypeParser.ParseHexadecimal(qlsValue.StyleValue).ToColor();
                            break;

                        case StyleProperty.Font:
                            Font = QValueTypeParser.ParseText(qlsValue.StyleValue);
                            break;

                        case StyleProperty.FontSize:
                            FontSize = QValueTypeParser.ParseInteger(qlsValue.StyleValue);
                            break;

                        case StyleProperty.TextColor:
                            TextColor = QValueTypeParser.ParseHexadecimal(qlsValue.StyleValue).ToColor();
                            break;

                        case StyleProperty.AutoSize:
                            AutoSize = QValueTypeParser.ParseBoolean(qlsValue.StyleValue);
                            break;
                        }
                    }
                    catch (InvalidOperationException invalidOperation)
                    {
                        // Exception created by the parser, if parsing fails, the default value is still used
                        // Send the exception message back with the results
                        collectedErrors.Add(invalidOperation.Message);
                    }
                }
                else
                {
                    collectedErrors.Add(UserMessages.UnsupportedStyle(qlsValue.StyleValue, qlsValue.StyleProperty.ToString(), "Windows"));
                }
            }
            errors = collectedErrors.ToArray();
        }