Beispiel #1
0
        public static bool ValidateSize(string size, ObjectType objectType, string objectName, string propertyName, bool restrictMaxValue, ErrorContext errorContext, out double sizeInMM, out string roundSize)
        {
            bool   flag     = ObjectType.Line == objectType;
            double minValue = flag ? Validator.NegativeMin : Validator.NormalMin;
            double maxValue = restrictMaxValue ? Validator.NormalMax : 1.7976931348623157E+308;

            return(PublishingValidator.ValidateSize(size, flag, minValue, maxValue, objectType, objectName, propertyName, errorContext, out sizeInMM, out roundSize));
        }
Beispiel #2
0
 private static bool ValidateSize(ExpressionInfo size, double minValue, double maxValue, ObjectType objectType, string objectName, string propertyName, ErrorContext errorContext)
 {
     Global.Tracer.Assert(null != size);
     if (ExpressionInfo.Types.Constant == size.Type)
     {
         bool   allowNegative = false;
         double num           = default(double);
         string text          = default(string);
         return(PublishingValidator.ValidateSize(size.Value, allowNegative, minValue, maxValue, objectType, objectName, propertyName, errorContext, out num, out text));
     }
     return(true);
 }
Beispiel #3
0
        public static Style ValidateAndCreateStyle(StringList names, ExpressionInfoList values, ObjectType objectType, string objectName, ErrorContext errorContext)
        {
            Style style = new Style(ConstructionPhase.Publishing);

            Global.Tracer.Assert(null != names);
            Global.Tracer.Assert(null != values);
            Global.Tracer.Assert(names.Count == values.Count);
            ExpressionInfo backgroundImageSource   = null;
            ExpressionInfo backgroundImageValue    = null;
            ExpressionInfo backgroundImageMIMEType = null;

            for (int i = 0; i < names.Count; i++)
            {
                switch (names[i])
                {
                case "BackgroundImageSource":
                    backgroundImageSource = values[i];
                    break;

                case "BackgroundImageValue":
                    backgroundImageValue = values[i];
                    break;

                case "BackgroundImageMIMEType":
                    backgroundImageMIMEType = values[i];
                    break;

                case "BackgroundRepeat":
                    if (PublishingValidator.ValidateBackgroundRepeat(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BorderColor":
                case "BorderColorLeft":
                case "BorderColorRight":
                case "BorderColorTop":
                case "BorderColorBottom":
                    if (PublishingValidator.ValidateColor(values[i], objectType, objectName, "BorderColor", errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BorderStyle":
                case "BorderStyleLeft":
                case "BorderStyleRight":
                case "BorderStyleTop":
                case "BorderStyleBottom":
                    if (PublishingValidator.ValidateBorderStyle(values[i], objectType, objectName, "BorderStyle", errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BorderWidth":
                case "BorderWidthLeft":
                case "BorderWidthRight":
                case "BorderWidthTop":
                case "BorderWidthBottom":
                    if (PublishingValidator.ValidateSize(values[i], Validator.BorderWidthMin, Validator.BorderWidthMax, objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BackgroundColor":
                case "BackgroundGradientEndColor":
                    if (PublishingValidator.ValidateColor(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BackgroundGradientType":
                    if (PublishingValidator.ValidateBackgroundGradientType(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "FontStyle":
                    if (PublishingValidator.ValidateFontStyle(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "FontFamily":
                    style.AddAttribute(names[i], values[i]);
                    break;

                case "FontSize":
                    if (PublishingValidator.ValidateSize(values[i], Validator.FontSizeMin, Validator.FontSizeMax, objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "FontWeight":
                    if (PublishingValidator.ValidateFontWeight(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Format":
                    style.AddAttribute(names[i], values[i]);
                    break;

                case "TextDecoration":
                    if (PublishingValidator.ValidateTextDecoration(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "TextAlign":
                    if (PublishingValidator.ValidateTextAlign(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "VerticalAlign":
                    if (PublishingValidator.ValidateVerticalAlign(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Color":
                    if (PublishingValidator.ValidateColor(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "PaddingLeft":
                case "PaddingRight":
                case "PaddingTop":
                case "PaddingBottom":
                    if (PublishingValidator.ValidateSize(values[i], Validator.PaddingMin, Validator.PaddingMax, objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "LineHeight":
                    if (PublishingValidator.ValidateSize(values[i], Validator.LineHeightMin, Validator.LineHeightMax, objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Direction":
                    if (PublishingValidator.ValidateDirection(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "WritingMode":
                    if (PublishingValidator.ValidateWritingMode(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Language":
                {
                    CultureInfo cultureInfo = default(CultureInfo);
                    if (PublishingValidator.ValidateSpecificLanguage(values[i], objectType, objectName, names[i], errorContext, out cultureInfo))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;
                }

                case "UnicodeBiDi":
                    if (PublishingValidator.ValidateUnicodeBiDi(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Calendar":
                    if (PublishingValidator.ValidateCalendar(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "NumeralLanguage":
                    if (PublishingValidator.ValidateLanguage(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "NumeralVariant":
                    if (PublishingValidator.ValidateNumeralVariant(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                default:
                    Global.Tracer.Assert(false);
                    break;
                }
            }
            PublishingValidator.ValidateBackgroundImage(backgroundImageSource, backgroundImageValue, backgroundImageMIMEType, style, objectType, objectName, errorContext);
            if (0 < style.StyleAttributes.Count)
            {
                return(style);
            }
            return(null);
        }