Example #1
0
 public void AssignTo(RectStyle rect)
 {
     rect.f = this.f;
     rect.e = this.e;
     rect.g = this.g;
     rect.i = this.i;
     this.a.AssignTo(rect.a);
     this.c.AssignTo(rect.c);
     this.b.AssignTo(rect.b);
     this.d.AssignTo(rect.d);
 }
Example #2
0
        public static void ParseRectStyleFromHTML(HTMLNode node, RectStyle rect)
        {
            Param  param    = node.Param.ByName("width");
            string fontsize = "";

            if (param != null)
            {
                fontsize = param.Value.Trim();
            }
            else
            {
                int num = node.Css.Css.IndexOf("width", CssType.ForAll, "");
                if (num != -1)
                {
                    fontsize = node.Css.Css[num].Value.Trim();
                }
            }
            if (fontsize != string.Empty)
            {
                if (fontsize.EndsWith("%"))
                {
                    rect.Width     = int.Parse(fontsize.Substring(0, fontsize.Length - 1));
                    rect.WidthType = LengthType.Rate;
                }
                else
                {
                    rect.Width      = FontSizeFromHTML(fontsize);
                    rect.OrginWidth = rect.Width;
                    rect.WidthType  = LengthType.Length;
                }
            }
            else
            {
                rect.Width      = -1;
                rect.OrginWidth = -1;
            }
            param    = node.Param.ByName("height");
            fontsize = "";
            if (param != null)
            {
                fontsize = param.Value.Trim();
            }
            else
            {
                int num2 = node.Css.Css.IndexOf("height", CssType.ForAll, "");
                if (num2 != -1)
                {
                    fontsize = node.Css.Css[num2].Value.Trim();
                }
            }
            if (fontsize != string.Empty)
            {
                if (fontsize.EndsWith("%"))
                {
                    rect.Height     = int.Parse(fontsize.Substring(0, fontsize.Length - 1));
                    rect.HeightType = LengthType.Rate;
                }
                else
                {
                    rect.Height     = FontSizeFromHTML(fontsize);
                    rect.HeightType = LengthType.Length;
                }
            }
            for (int i = 0; i < node.Css.Css.Count; i++)
            {
                string key = node.Css.Css[i].Name.ToLower();
                if (key != null)
                {
                    int num6;
                    Dictionary <string, int> c = null;
                    if (c == null)
                    {
                        Dictionary <string, int> dictionary1 = new Dictionary <string, int>(0x1a);
                        dictionary1.Add("background-color", 0);
                        dictionary1.Add("border", 1);
                        dictionary1.Add("border-left", 2);
                        dictionary1.Add("border-right", 3);
                        dictionary1.Add("border-top", 4);
                        dictionary1.Add("border-bottom", 5);
                        dictionary1.Add("border-width", 6);
                        dictionary1.Add("border-type", 7);
                        dictionary1.Add("border-color", 8);
                        dictionary1.Add("border-top-color", 9);
                        dictionary1.Add("border-right-color", 10);
                        dictionary1.Add("border-bottom-color", 11);
                        dictionary1.Add("border-left-color", 12);
                        dictionary1.Add("border-top-style", 13);
                        dictionary1.Add("border-right-style", 14);
                        dictionary1.Add("border-bottom-style", 15);
                        dictionary1.Add("border-left-style", 0x10);
                        dictionary1.Add("border-top-width", 0x11);
                        dictionary1.Add("border-right-width", 0x12);
                        dictionary1.Add("border-bottom-width", 0x13);
                        dictionary1.Add("border-left-width", 20);
                        dictionary1.Add("margin", 0x15);
                        dictionary1.Add("margin-bottom", 0x16);
                        dictionary1.Add("margin-left", 0x17);
                        dictionary1.Add("margin-right", 0x18);
                        dictionary1.Add("margin-top", 0x19);
                        c = dictionary1;
                    }
                    if (c.TryGetValue(key, out num6))
                    {
                        BorderStyle style;
                        int         num4;
                        BorderType  type;
                        Color       color2;
                        switch (num6)
                        {
                        case 0:
                        {
                            Color color = ColorFromHTML(node.Css.Css[i].Value.Trim());
                            rect.BGColor = color;
                            break;
                        }

                        case 1:
                            style = BorderStyleFromParam(node.Css.Css[i].Value, rect.TopBorder);
                            rect.SetBorderColor(style.BorderColor);
                            rect.SetBorderType(style.Type);
                            rect.SetBorderWidth(style.Width);
                            break;

                        case 2:
                            style = BorderStyleFromParam(node.Css.Css[i].Value, rect.LeftBorder);
                            rect.LeftBorder.BorderColor = style.BorderColor;
                            rect.LeftBorder.Type        = style.Type;
                            rect.LeftBorder.Width       = style.Width;
                            break;

                        case 3:
                            style = BorderStyleFromParam(node.Css.Css[i].Value, rect.RightBorder);
                            rect.RightBorder.BorderColor = style.BorderColor;
                            rect.RightBorder.Type        = style.Type;
                            rect.RightBorder.Width       = style.Width;
                            break;

                        case 4:
                            style = BorderStyleFromParam(node.Css.Css[i].Value, rect.TopBorder);
                            rect.TopBorder.BorderColor = style.BorderColor;
                            rect.TopBorder.Type        = style.Type;
                            rect.TopBorder.Width       = style.Width;
                            break;

                        case 5:
                            style = BorderStyleFromParam(node.Css.Css[i].Value, rect.BottomBorder);
                            rect.BottomBorder.BorderColor = style.BorderColor;
                            rect.BottomBorder.Type        = style.Type;
                            rect.BottomBorder.Width       = style.Width;
                            break;

                        case 6:
                            num4 = FontSizeFromHTML(node.Css.Css[i].Value);
                            rect.SetBorderWidth(num4);
                            break;

                        case 7:
                            type = BorderTypeFromHTML(node.Css.Css[i].Value);
                            rect.SetBorderType(type);
                            break;

                        case 8:
                            color2 = ColorFromHTML(node.Css.Css[i].Value);
                            rect.SetBorderColor(color2);
                            break;

                        case 9:
                            color2 = ColorFromHTML(node.Css.Css[i].Value);
                            rect.TopBorder.BorderColor = color2;
                            break;

                        case 10:
                            color2 = ColorFromHTML(node.Css.Css[i].Value);
                            rect.RightBorder.BorderColor = color2;
                            break;

                        case 11:
                            color2 = ColorFromHTML(node.Css.Css[i].Value);
                            rect.BottomBorder.BorderColor = color2;
                            break;

                        case 12:
                            color2 = ColorFromHTML(node.Css.Css[i].Value);
                            rect.LeftBorder.BorderColor = color2;
                            break;

                        case 13:
                            type = BorderTypeFromHTML(node.Css.Css[i].Value);
                            rect.TopBorder.Type = type;
                            break;

                        case 14:
                            type = BorderTypeFromHTML(node.Css.Css[i].Value);
                            rect.RightBorder.Type = type;
                            break;

                        case 15:
                            type = BorderTypeFromHTML(node.Css.Css[i].Value);
                            rect.BottomBorder.Type = type;
                            break;

                        case 0x10:
                            type = BorderTypeFromHTML(node.Css.Css[i].Value);
                            rect.LeftBorder.Type = type;
                            break;

                        case 0x11:
                            num4 = FontSizeFromHTML(node.Css.Css[i].Value);
                            rect.TopBorder.Width = num4;
                            break;

                        case 0x12:
                            num4 = FontSizeFromHTML(node.Css.Css[i].Value);
                            rect.RightBorder.Width = num4;
                            break;

                        case 0x13:
                            num4 = FontSizeFromHTML(node.Css.Css[i].Value);
                            rect.BottomBorder.Width = num4;
                            break;

                        case 20:
                            num4 = FontSizeFromHTML(node.Css.Css[i].Value);
                            rect.LeftBorder.Width = num4;
                            break;

                        case 0x15:
                            num4 = FontSizeFromHTML(node.Css.Css[i].Value);
                            rect.SetMargin(num4);
                            break;

                        case 0x16:
                            num4 = FontSizeFromHTML(node.Css.Css[i].Value);
                            rect.BottomBorder.Width = num4;
                            break;

                        case 0x17:
                            num4 = FontSizeFromHTML(node.Css.Css[i].Value);
                            rect.LeftBorder.Width = num4;
                            break;

                        case 0x18:
                            num4 = FontSizeFromHTML(node.Css.Css[i].Value);
                            rect.RightBorder.Margin = num4;
                            break;

                        case 0x19:
                            num4 = FontSizeFromHTML(node.Css.Css[i].Value);
                            rect.TopBorder.Margin = num4;
                            break;
                        }
                    }
                }
            }
            Param param2 = node.Param.ByName("bgcolor");

            if (param2 != null)
            {
                Color color3 = ColorFromHTML(param2.Value.Trim());
                rect.BGColor = color3;
            }
            Param param3 = node.Param.ByName("align");

            if (param3 != null)
            {
                Alignment alignment = AlignFromHtml(param3.Value.Trim());
                rect.Align = alignment;
            }
            Param param4 = node.Param.ByName("border");

            if (param4 != null)
            {
                int width = FontSizeFromHTML(param4.Value.Trim());
                rect.SetBorderWidth(width);
                if (width > 0)
                {
                    rect.SetBorderType(BorderType.SOLID);
                }
            }
            Param param5 = node.Param.ByName("bordercolor");

            if (param5 != null)
            {
                Color color4 = ColorFromHTML(param5.Value.Trim());
                rect.SetBorderColor(color4);
            }
        }