Ejemplo n.º 1
0
        /// <summary>
        /// Generates the range block.
        /// </summary>
        /// <param name="rLabel">The r label.</param>
        /// <param name="leftSource">The left source.</param>
        /// <param name="centerSource">The center source.</param>
        /// <param name="rightSource">The right source.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        static List <List <List <GcPrintableControl> > > GenerateRangeBlock(GcRichLabel rLabel, string leftSource, string centerSource, string rightSource, GcReportContext context)
        {
            int width  = rLabel.Width;
            int height = rLabel.Height;

            if (rLabel.Padding.Horizontal > 0)
            {
                width -= rLabel.Padding.Horizontal;
            }
            if (rLabel.Padding.Vertical > 0)
            {
                width -= rLabel.Padding.Vertical;
            }
            Windows.Foundation.Rect rect = new Windows.Foundation.Rect(0.0, 0.0, (double)width, (double)height);
            List <List <List <GcPrintableControl> > > list = new List <List <List <GcPrintableControl> > > {
                null, null, null
            };

            if ((!string.IsNullOrEmpty(leftSource) || !string.IsNullOrEmpty(centerSource)) || !string.IsNullOrEmpty(rightSource))
            {
                if ((rect.IsEmpty || (rect.Width == 0.0)) || (rect.Height == 0.0))
                {
                    return(list);
                }
                string str  = leftSource;
                string str2 = centerSource;
                string str3 = rightSource;
                if (!string.IsNullOrEmpty(str))
                {
                    list[0] = GenerateRangeBlockPart(rLabel, str, rect, -1, context);
                }
                if (!string.IsNullOrEmpty(str2))
                {
                    list[1] = GenerateRangeBlockPart(rLabel, str2, rect, 0, context);
                }
                if (!string.IsNullOrEmpty(str3))
                {
                    list[2] = GenerateRangeBlockPart(rLabel, str3, rect, 1, context);
                }
            }
            return(list);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generates the range block part.
        /// </summary>
        /// <param name="rLabel">The r label.</param>
        /// <param name="source">The source.</param>
        /// <param name="rect">The rect.</param>
        /// <param name="part">The part.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        static List <List <GcPrintableControl> > GenerateRangeBlockPart(GcRichLabel rLabel, string source, Windows.Foundation.Rect rect, int part, GcReportContext context)
        {
            List <List <GcPrintableControl> > list = new List <List <GcPrintableControl> >();

            if ((!string.IsNullOrEmpty(source) && !rect.IsEmpty) && ((rect.Width != 0.0) && (rect.Height != 0.0)))
            {
                string        str;
                StringReader  reader         = new StringReader(source);
                int           allHeight      = 0;
                Font          font           = rLabel.Font ?? context.DefaultFont;
                string        fontFamilyName = font.FontFamilyName;
                bool          strikeout      = font.Strikeout;
                double        fontSize       = font.FontSize;
                UnderlineType underline      = font.Underline;
                bool          bold           = font.Bold;
                bool          italic         = font.Italic;
                Brush         foreground     = rLabel.Foreground;
                Image         leftImage      = null;
                switch (part)
                {
                case -1:
                    leftImage = rLabel.LeftImage;
                    break;

                case 0:
                    leftImage = rLabel.CenterImage;
                    break;

                case 1:
                    leftImage = rLabel.RightImage;
                    break;
                }
                while ((str = reader.ReadLine()) != null)
                {
                    List <GcPrintableControl> lists = GenerateRangeBlockLine(rLabel, str, rect, leftImage, ref font, ref fontFamilyName, ref strikeout, ref fontSize, ref underline, ref bold, ref italic, ref foreground);
                    int num3 = AdjustLineByPart(lists, context, part, true, allHeight, rect);
                    list.Add(lists);
                    if ((num3 <= 0) && (lists.Count <= 0))
                    {
                        num3 = (int)Math.Ceiling(context.MeasureNoWrapString("X", font).Height);
                    }
                    allHeight += num3;
                }
                int num4 = 0;
                switch (rLabel.VerticalAlignment)
                {
                case TextVerticalAlignment.General:
                case TextVerticalAlignment.Top:
                case TextVerticalAlignment.Justify:
                    break;

                case TextVerticalAlignment.Center:
                case TextVerticalAlignment.Distributed:
                    num4 = (int)((rect.Height - allHeight) / 2.0);
                    break;

                case TextVerticalAlignment.Bottom:
                    num4 = (int)(rect.Height - allHeight);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                if (num4 != 0)
                {
                    using (List <List <GcPrintableControl> > .Enumerator enumerator = list.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            foreach (GcPrintableControl local1 in enumerator.Current)
                            {
                                local1.Y += num4;
                            }
                        }
                    }
                }
            }
            return(list);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Generates the range block line.
        /// </summary>
        /// <param name="rLabel">The r label.</param>
        /// <param name="source">The source.</param>
        /// <param name="rect">The rect.</param>
        /// <param name="image">The image.</param>
        /// <param name="font">The font.</param>
        /// <param name="fontName">Name of the font.</param>
        /// <param name="isStrikethrough">if set to <c>true</c> [is strikethrough].</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="underlineType">Type of the underline.</param>
        /// <param name="isBold">if set to <c>true</c> [is bold].</param>
        /// <param name="isItalic">if set to <c>true</c> [is italic].</param>
        /// <param name="foreground">The foreground.</param>
        /// <returns></returns>
        static List <GcPrintableControl> GenerateRangeBlockLine(GcRichLabel rLabel, string source, Windows.Foundation.Rect rect, Image image, ref Font font, ref string fontName, ref bool isStrikethrough, ref double fontSize, ref UnderlineType underlineType, ref bool isBold, ref bool isItalic, ref Brush foreground)
        {
            List <GcPrintableControl> list = new List <GcPrintableControl>();

            if ((!string.IsNullOrEmpty(source) && !rect.IsEmpty) && ((rect.Width != 0.0) && (rect.Height != 0.0)))
            {
                string str = string.Empty;
                while (!string.IsNullOrEmpty(source))
                {
                    string        str2           = fontName;
                    bool          flag           = isStrikethrough;
                    double        num            = fontSize;
                    UnderlineType single         = underlineType;
                    bool          flag2          = isBold;
                    bool          flag3          = isItalic;
                    Brush         foregroundNext = foreground;
                    int           length         = -1;
                    length = source.IndexOf("&");
                    if (length < 0)
                    {
                        length = source.Length;
                    }
                    str = str + source.Substring(0, length);
                    string       str3       = ((length + 1) < source.Length) ? source.Substring(length + 1, 1) : string.Empty;
                    int          startIndex = -1;
                    bool         flag4      = false;
                    PageInfoType pageNumber = PageInfoType.PageNumber;
                    bool         flag5      = false;
                    int          num4       = 0;
                    try
                    {
                        Match match;
                        switch (str3)
                        {
                        case "1":
                        case "2":
                        case "3":
                        case "4":
                        case "5":
                        case "6":
                        case "7":
                        case "8":
                        case "9":
                        case "0":
                            match = FontSizeRegex.Match(source.Substring(length));
                            if ((!match.Success || !match.Groups["fontSize"].Success) || string.IsNullOrEmpty(match.Groups["fontSize"].Value))
                            {
                                goto Label_079D;
                            }
                            num        = int.Parse(match.Groups["fontSize"].Value);
                            flag4      = true;
                            num4       = 0;
                            startIndex = (length + "&".Length) + match.Groups["fontSize"].Value.Length;
                            if (match.Groups["nextIsNumber"].Success)
                            {
                                startIndex++;
                            }
                            goto Label_07C0;

                        case "K":
                        {
                            match = RgbColorRegex.Match(source.Substring(length));
                            if (!match.Success)
                            {
                                break;
                            }
                            byte r = byte.Parse(match.Groups["red"].Value, (NumberStyles)NumberStyles.AllowHexSpecifier);
                            byte g = byte.Parse(match.Groups["green"].Value, (NumberStyles)NumberStyles.AllowHexSpecifier);
                            byte b = byte.Parse(match.Groups["blue"].Value, (NumberStyles)NumberStyles.AllowHexSpecifier);
                            foregroundNext = new SolidColorBrush(Windows.UI.Color.FromArgb(0xff, r, g, b));
                            flag4          = true;
                            num4           = 0;
                            startIndex     = ((length + "&".Length) + "K".Length) + 6;
                            goto Label_07C0;
                        }

                        case "S":
                            flag       = !flag;
                            flag4      = true;
                            num4       = 0;
                            startIndex = (length + "&".Length) + "S".Length;
                            goto Label_07C0;

                        case "U":
                            if (single != UnderlineType.None)
                            {
                                goto Label_04DA;
                            }
                            single = UnderlineType.Single;
                            goto Label_04E2;

                        case "\"":
                            match = FontRegex.Match(source.Substring(length));
                            if (match.Success)
                            {
                                string str4 = match.Groups["fontName"].Value;
                                string str5 = match.Groups["fontStyle"].Value;
                                if (str4.IndexOf("-") < 0)
                                {
                                    str2  = str4;
                                    flag4 = true;
                                    num4  = 0;
                                }
                                if (str5.IndexOf("-") < 0)
                                {
                                    if (str5.IndexOf("Bold") >= 0)
                                    {
                                        flag2 = true;
                                    }
                                    if (str5.IndexOf("Italic") >= 0)
                                    {
                                        flag3 = true;
                                    }
                                    if (str5.IndexOf("Regular") >= 0)
                                    {
                                        flag2 = flag3 = false;
                                    }
                                    flag4 = true;
                                    num4  = 0;
                                }
                                startIndex = length + match.Value.Length;
                            }
                            goto Label_07C0;

                        case "B":
                            flag2      = !flag2;
                            flag4      = true;
                            num4       = 0;
                            startIndex = (length + "&".Length) + "B".Length;
                            goto Label_07C0;

                        case "I":
                            flag3      = !flag3;
                            flag4      = true;
                            num4       = 0;
                            startIndex = (length + "&".Length) + "I".Length;
                            goto Label_07C0;

                        case "&":
                            str        = str + "&";
                            flag4      = true;
                            num4       = 0;
                            startIndex = length + ("&".Length * 2);
                            goto Label_07C0;

                        case "D":
                            str        = str + "{0}";
                            flag4      = true;
                            num4       = 1;
                            pageNumber = PageInfoType.Date;
                            startIndex = (length + "&".Length) + "D".Length;
                            goto Label_07C0;

                        case "T":
                            str        = str + "{0}";
                            flag4      = true;
                            num4       = 1;
                            pageNumber = PageInfoType.Time;
                            startIndex = (length + "&".Length) + "T".Length;
                            goto Label_07C0;

                        case "P":
                            str        = str + "{0}";
                            flag4      = true;
                            num4       = 1;
                            pageNumber = PageInfoType.PageNumber;
                            startIndex = (length + "&".Length) + "P".Length;
                            goto Label_07C0;

                        case "N":
                            str        = str + "{0}";
                            flag4      = true;
                            num4       = 1;
                            pageNumber = PageInfoType.PageCount;
                            startIndex = (length + "&".Length) + "N".Length;
                            goto Label_07C0;

                        case "G":
                            if (image != null)
                            {
                                flag4 = true;
                                num4  = 0;
                                flag5 = true;
                            }
                            startIndex = (length + "&".Length) + "G".Length;
                            goto Label_07C0;

                        case "F":
                            str        = str + rLabel.WorkbookName;
                            startIndex = (length + "&".Length) + "F".Length;
                            goto Label_07C0;

                        case "A":
                            str        = str + rLabel.WorksheetName;
                            startIndex = (length + "&".Length) + "A".Length;
                            goto Label_07C0;

                        default:
                            goto Label_079D;
                        }
                        if (!ThemeColorRegex.Match(source.Substring(length)).Success)
                        {
                            goto Label_079D;
                        }
                        foregroundNext = rLabel.Foreground;
                        flag4          = true;
                        num4           = 0;
                        startIndex     = ((length + "&".Length) + "K".Length) + 5;
                        goto Label_07C0;
Label_04DA:
                        if (single == UnderlineType.Single)
                        {
                            single = UnderlineType.None;
                        }
Label_04E2:
                        flag4      = true;
                        num4       = 0;
                        startIndex = (length + "&".Length) + "U".Length;
                        goto Label_07C0;
Label_079D:
                        startIndex = length + "&".Length;
                    }
                    catch
                    {
                        startIndex = length + "&".Length;
                    }
Label_07C0:
                    if (startIndex >= source.Length)
                    {
                        source = string.Empty;
                    }
                    else
                    {
                        source = source.Substring(startIndex);
                    }
                    if (!string.IsNullOrEmpty(str) && (flag4 || string.IsNullOrEmpty(source)))
                    {
                        GcLabel label = null;
                        switch (num4)
                        {
                        case 0:
                            label = new GcLabel(str);
                            break;

                        case 1:
                        {
                            GcPageInfo info = new GcPageInfo
                            {
                                Format = str,
                                Type   = pageNumber
                            };
                            label = info;
                            break;
                        }
                        }
                        label.CanGrow    = false;
                        label.CanShrink  = false;
                        label.Foreground = foreground;
                        if ((((font.FontFamilyName != fontName) || (font.Strikeout != isStrikethrough)) || ((font.FontSize != fontSize) || (font.Underline != underlineType))) || ((font.Bold != isBold) || (font.Italic != isItalic)))
                        {
                            font           = new Font(fontName, fontSize);
                            font.Strikeout = isStrikethrough;
                            font.Bold      = isBold;
                            font.Italic    = isItalic;
                            font.Underline = underlineType;
                        }
                        label.Alignment.WordWrap = false;
                        label.Font = font;
                        list.Add(label);
                        str = string.Empty;
                    }
                    if (flag5 && (image != null))
                    {
                        GcImage image2 = new GcImage(image);
                        list.Add(image2);
                        flag5 = false;
                    }
                    fontName        = str2;
                    isStrikethrough = flag;
                    fontSize        = num;
                    underlineType   = single;
                    isBold          = flag2;
                    isItalic        = flag3;
                    foreground      = foregroundNext;
                }
            }
            return(list);
        }