コード例 #1
0
ファイル: Util.cs プロジェクト: vikinka1233/endless-ql
        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);
        }
コード例 #2
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();
        }