Ejemplo n.º 1
0
        /// <summary>
        /// Exports the empty page.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <param name="doc">The document.</param>
        void ExportEmptyPage(ExporterState state, PdfDocument doc)
        {
            PdfPage page = doc.Pages.AddNewPage(this.context.GetDot((float)this.context.PageRects.PageRectangle.Width), this.context.GetDot((float)this.context.PageRects.PageRectangle.Height));

            state.CurrentPage = page;
            PdfContent content = page.AddNewContent();

            content.Filters.Enqueue(PdfFilter.FlateFilter);
            PdfGraphics pdfGraphics = content.Graphics;
            Graphics    g           = new Graphics(this.context, this, pdfGraphics);

            g.SaveState();
            g.Scale((double)this.context.GetForce(), (double)-this.context.GetForce());
            g.Translate(0.0, -this.context.PageRects.PageRectangle.Height);
            GcLabel label = new GcLabel((int)((this.context.PageRects.PageRectangle.Width / 2.0) - 220.0), (int)(this.context.PageRects.PageRectangle.Height / 3.0), 440, 100)
            {
                Text = "No Page can be print, please check the settings.",
                Font = new Font(this.context.DefaultFont.FontFamily.ToString(), 20.0)
            };

            label.Alignment.VerticalAlignment   = TextVerticalAlignment.Center;
            label.Alignment.HorizontalAlignment = TextHorizontalAlignment.Center;
            label.Alignment.WordWrap            = true;
            label.Foreground = FillEffects.Red;
            label.Background = new SolidColorBrush(Colors.Red);
            GcPaintHelper.PaintLabel(label.GetBlock(this.context), g, state);
            g.RestoreState();
        }
Ejemplo n.º 2
0
 internal void Init()
 {
     this.innerLabel            = new GcLabel();
     this.innerLabel.Font       = new Font(GcReportContext.defaultFont.FontFamilyName, 40.0);
     this.innerLabel.Foreground = new SolidColorBrush(Color.FromArgb(0x66, 0x7f, 0xc9, 0xff));
     this.innerLabel.Alignment.HorizontalAlignment = TextHorizontalAlignment.Center;
     this.innerLabel.Alignment.VerticalAlignment   = TextVerticalAlignment.Center;
     this.innerLabel.Alignment.TextRotationAngle   = 45.0;
     this.innerLabel.Alignment.TextOrientation     = TextOrientation.TextRotateCustom;
     this.outlineFillEffect = FillEffects.Black;
     this.showOutline       = true;
     this.layoutType        = LayoutType.Diagonal;
     this.outlineWidth      = 1;
 }
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);
        }