public IColor AddColor(string color)
        {
            if (m_colorLookup.ContainsKey(color))
            {
                return(m_colorLookup[color]);
            }
            Color      color2     = LayoutConvert.ToColor(color);
            BIFF8Color bIFF8Color = null;

            for (int i = 0; i < m_colors.Count; i++)
            {
                if (m_colors[i].Equals(color2))
                {
                    bIFF8Color = m_colors[i];
                }
            }
            if (bIFF8Color == null)
            {
                if (m_colors.Count >= 56)
                {
                    return(m_colors[0]);
                }
                bIFF8Color = new BIFF8Color(color2, m_colors.Count + 8);
                m_colors.Add(bIFF8Color);
            }
            m_colorLookup[color] = bIFF8Color;
            return(bIFF8Color);
        }
Пример #2
0
 public IColor AddColor(string colorString)
 {
     System.Drawing.Color color = LayoutConvert.ToColor(colorString);
     if (this._nextPaletteIndex < 56)
     {
         int colorIndex = this._workbook.Palette.GetColorIndex(color.R, color.G, color.B);
         if (colorIndex == -1)
         {
             this._workbook.Palette.SetColorAt(this._nextPaletteIndex, color.R, color.G, color.B);
             this._nextPaletteIndex++;
         }
         else if (colorIndex >= this._nextPaletteIndex)
         {
             if (colorIndex == this._nextPaletteIndex)
             {
                 this._nextPaletteIndex++;
             }
             else
             {
                 Color colorAt  = this._workbook.Palette.GetColorAt(colorIndex);
                 Color colorAt2 = this._workbook.Palette.GetColorAt(this._nextPaletteIndex);
                 this._workbook.Palette.SetColorAt(colorIndex, colorAt2.Red, colorAt2.Green, colorAt2.Blue);
                 this._workbook.Palette.SetColorAt(this._nextPaletteIndex, colorAt.Red, colorAt.Green, colorAt.Blue);
                 this._nextPaletteIndex++;
             }
         }
     }
     return(this._workbook.Palette.GetColor(color));
 }
 private void ParseDeviceinfo(NameValueCollection deviceInfo)
 {
     if (deviceInfo != null)
     {
         string boolValue = deviceInfo["SuppressOutlines"];
         this.m_suppressOutlines = LayoutConvert.ParseBool(boolValue, false);
         string boolValue2 = deviceInfo["OmitDocumentMap"];
         this.m_omitDocumentMap = LayoutConvert.ParseBool(boolValue2, false);
         string boolValue3 = deviceInfo["OmitFormulas"];
         this.m_omitFormula = LayoutConvert.ParseBool(boolValue3, false);
         string boolValue4 = deviceInfo["SimplePageHeaders"];
         this.m_simplePageHeaders = LayoutConvert.ParseBool(boolValue4, false);
     }
 }
Пример #4
0
        private void Bg_worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker   = sender as BackgroundWorker;
            List <object>    listData = e.Argument as List <object>;

            DataListPrinting     dataContext          = listData[0] as DataListPrinting;
            DataPaperSizeSetting dataPaperSizeSetting = listData[1] as DataPaperSizeSetting;

            dataContext.IsEnableAll = false;

            List <BarCodePrinting> listprinting = dataContext.ListPrinting;
            int i = 1, max = listprinting.Count;

            foreach (BarCodePrinting printing in listprinting)
            {
                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }
                else
                {
                    try
                    {
                        printing.LayoutPaper = LayoutConvert.Convert(printing);
                        CodePrinter codePrinter = new CodePrinter(new PrinterSet()
                        {
                            PrinterSettings = dataContext.Printer,
                            Landscape       = dataContext.Landscape,
                            PaperSize       = new PaperSize("Customs Paper Size", dataPaperSizeSetting.BarcodeSizeW, dataPaperSizeSetting.BarcodeSizeH),
                            BarCode         = printing,
                            Horizontal      = dataPaperSizeSetting.Horizo
                        });
                        codePrinter.CodePrinter_EndPrint += CodePrinter_CodePrinter_EndPrint;
                        codePrinter.Print();

                        autoReset.WaitOne();
                        worker.ReportProgress(Convert.ToInt32(((double)i / max) * 100));

                        printing.Per     = 100;
                        printing.Success = true;

                        Thread.Sleep(500);
                        i++;
                    }
                    catch { }
                }
            }
        }
Пример #5
0
        private static string GetDateTimeFormat(string format, string language, object rplCalendar)
        {
            if (format == null || format.Length <= 0)
            {
                format = "G";
            }
            CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture(language);

            cultureInfo = new CultureInfo(cultureInfo.Name, useUserOverride: false);
            if (cultureInfo.DateTimeFormat == null)
            {
                cultureInfo.DateTimeFormat = DateTimeFormatInfo.CurrentInfo;
            }
            if (rplCalendar != null)
            {
                bool       flag              = false;
                Calendar   calendarInstance  = LayoutConvert.GetCalendarInstance((RPLFormat.Calendars)rplCalendar);
                Type       type              = calendarInstance.GetType();
                Calendar[] optionalCalendars = cultureInfo.OptionalCalendars;
                foreach (Calendar calendar in optionalCalendars)
                {
                    if (type == calendar.GetType())
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    cultureInfo.DateTimeFormat.Calendar = calendarInstance;
                }
                else
                {
                    calendarInstance = new GregorianCalendar();
                    cultureInfo.DateTimeFormat.Calendar = calendarInstance;
                }
            }
            string             empty          = string.Empty;
            DateTimeFormatInfo dateTimeFormat = cultureInfo.DateTimeFormat;
            string             timeSeparator  = dateTimeFormat.TimeSeparator;
            string             dateSeparator  = dateTimeFormat.DateSeparator;

            empty = ((format.Length != 1) ? format : GetDateTimePattern(format[0], dateTimeFormat));
            return(GetExcelPictureDateTimeFormat(empty, timeSeparator, dateSeparator));
        }
        public void BuildHeaderFooterString(StringBuilder str, RPLTextBoxProps textBox, ref string lastFont, ref double lastFontSize)
        {
            RPLElementStyle style = textBox.Style;
            string          text  = (string)style[20];

            if (!string.IsNullOrEmpty(text) && !text.Equals(lastFont))
            {
                str.Append("&").Append("\"");
                FormulaHandler.EncodeHeaderFooterString(str, text);
                str.Append("\"");
                lastFont = text;
            }
            string text2 = (string)style[21];

            if (!string.IsNullOrEmpty(text2))
            {
                double num = LayoutConvert.ToPoints(text2);
                if (num != 0.0 && num != lastFontSize)
                {
                    str.Append("&").Append((int)num);
                }
                lastFontSize = num;
            }
            StringBuilder stringBuilder = new StringBuilder();
            object        obj           = style[19];

            if (obj != null && (RPLFormat.FontStyles)obj == RPLFormat.FontStyles.Italic)
            {
                str.Append("&I");
                stringBuilder.Append("&I");
            }
            object obj2 = textBox.Style[22];

            if (obj2 != null && LayoutConvert.ToFontWeight((RPLFormat.FontWeights)obj2) >= 600)
            {
                str.Append("&B");
                stringBuilder.Append("&B");
            }
            object obj3 = textBox.Style[24];

            if (obj3 != null)
            {
                RPLFormat.TextDecorations num2 = (RPLFormat.TextDecorations)obj3;
                if (num2 == RPLFormat.TextDecorations.Underline)
                {
                    str.Append("&u");
                    stringBuilder.Append("&u");
                }
                if (num2 == RPLFormat.TextDecorations.LineThrough)
                {
                    str.Append("&s");
                    stringBuilder.Append("&s");
                }
            }
            string text3 = string.Empty;
            string text4 = ((RPLTextBoxPropsDef)textBox.Definition).Formula;

            if (text4 != null && text4.Length != 0)
            {
                if (text4.StartsWith("=", StringComparison.Ordinal))
                {
                    text4 = text4.Remove(0, 1);
                }
                text3 = FormulaHandler.ProcessHeaderFooterFormula(text4);
            }
            if (text3 != null && text3.Length != 0)
            {
                str.Append(text3);
            }
            else
            {
                string text5 = textBox.Value;
                if (text5 == null)
                {
                    text5 = ((RPLTextBoxPropsDef)textBox.Definition).Value;
                }
                if (text5 == null && textBox.OriginalValue != null)
                {
                    text5 = textBox.OriginalValue.ToString();
                }
                if (text5 != null)
                {
                    FormulaHandler.EncodeHeaderFooterString(str, text5.Trim());
                }
            }
            if (stringBuilder.Length > 0)
            {
                str.Append(stringBuilder);
            }
            str.Append(" ");
        }
Пример #7
0
        public static void ReadReportMeasurements(RPLReport report, ALayout layout, bool suppressOutlines, RPLReportSection firstReportSection)
        {
            int            num            = 0;
            int            left           = 0;
            int            num2           = 0;
            int            num3           = 0;
            int            left2          = 0;
            int            num4           = 0;
            int            num5           = 0;
            int            left3          = 0;
            int            num6           = 0;
            RPLPageContent rPLPageContent = report.RPLPaginatedPages[0];
            RPLPageLayout  pageLayout     = rPLPageContent.PageLayout;
            int            width          = LayoutConvert.ConvertMMTo20thPoints((double)rPLPageContent.MaxSectionWidth);

            for (RPLReportSection rPLReportSection = firstReportSection; rPLReportSection != null; rPLReportSection = rPLPageContent.GetNextReportSection())
            {
                layout.SetIsLastSection(!rPLPageContent.HasNextReportSection());
                RPLItemMeasurement rPLItemMeasurement = rPLReportSection.Columns[0];
                ALayout            pageHeaderLayout;
                if (rPLReportSection.Header != null)
                {
                    num             += LayoutConvert.ConvertMMTo20thPoints((double)rPLReportSection.Header.Top);
                    left             = LayoutConvert.ConvertMMTo20thPoints((double)rPLReportSection.Header.Left);
                    num2             = LayoutConvert.ConvertMMTo20thPoints((double)rPLReportSection.Header.Height);
                    pageHeaderLayout = layout.GetPageHeaderLayout(rPLReportSection.Header.Width, rPLReportSection.Header.Height);
                    if (num2 > 0)
                    {
                        if (pageLayout.Style != null)
                        {
                            pageHeaderLayout.AddReportItem(pageLayout, num, left, width, num2, 0, 0, null, null);
                        }
                        pageHeaderLayout.AddReportItem(rPLReportSection.Header.Element.RPLSource, num, left, width, num2, 0, 0, null, null);
                    }
                }
                else
                {
                    pageHeaderLayout = layout.GetPageHeaderLayout(0f, 0f);
                }
                if (rPLItemMeasurement != null)
                {
                    num3 += LayoutConvert.ConvertMMTo20thPoints((double)rPLItemMeasurement.Top);
                    left2 = LayoutConvert.ConvertMMTo20thPoints((double)rPLItemMeasurement.Left);
                    num4  = LayoutConvert.ConvertMMTo20thPoints((double)rPLItemMeasurement.Height);
                    if (layout.HeaderInBody)
                    {
                        num3 += num2;
                    }
                    if (layout.FooterInBody)
                    {
                        num5 = num3 + num4;
                    }
                    if (pageLayout.Style != null)
                    {
                        layout.AddReportItem(pageLayout, num3, left2, width, num4, 0, rPLItemMeasurement.State, null, null);
                    }
                    layout.AddReportItem(rPLItemMeasurement.Element.RPLSource, num3, left2, width, num4, 0, rPLItemMeasurement.State, null, null);
                }
                ALayout pageFooterLayout;
                if (rPLReportSection.Footer != null)
                {
                    num5            += LayoutConvert.ConvertMMTo20thPoints((double)rPLReportSection.Footer.Top);
                    left3            = LayoutConvert.ConvertMMTo20thPoints((double)rPLReportSection.Footer.Left);
                    num6             = LayoutConvert.ConvertMMTo20thPoints((double)rPLReportSection.Footer.Height);
                    pageFooterLayout = layout.GetPageFooterLayout(rPLReportSection.Footer.Width, rPLReportSection.Footer.Height);
                    if (num6 > 0)
                    {
                        if (pageLayout.Style != null)
                        {
                            pageFooterLayout.AddReportItem(pageLayout, num5, left3, width, num6, 0, 0, null, null);
                        }
                        pageFooterLayout.AddReportItem(rPLReportSection.Footer.Element.RPLSource, num5, left3, width, num6, 0, 0, null, null);
                    }
                }
                else
                {
                    pageFooterLayout = layout.GetPageFooterLayout(0f, 0f);
                }
                Dictionary <string, ToggleParent> toggleParents = null;
                if (!suppressOutlines)
                {
                    toggleParents = new Dictionary <string, ToggleParent>();
                }
                if (rPLReportSection.Header != null)
                {
                    Reader.ReadMeasurement(rPLReportSection.Header.Element, pageHeaderLayout, num, left, 1, BlockOutlines.None, toggleParents, suppressOutlines, 0, null);
                }
                if (rPLItemMeasurement != null)
                {
                    Reader.ReadMeasurement(rPLItemMeasurement.Element, layout, num3, left2, 1, BlockOutlines.None, toggleParents, suppressOutlines, 0, null);
                }
                if (rPLReportSection.Footer != null)
                {
                    Reader.ReadMeasurement(rPLReportSection.Footer.Element, pageFooterLayout, num5, left3, 1, BlockOutlines.None, toggleParents, suppressOutlines, 0, null);
                }
                int num7 = num3 + num4;
                if (layout.FooterInBody)
                {
                    num7 += num6;
                }
                num3 = (num = (num5 = num7));
                num4 = 0;
                num6 = 0;
                num2 = 0;
                rPLReportSection.Columns[0] = null;
                rPLReportSection.Header     = null;
                rPLReportSection.Footer     = null;
                layout.CompleteSection();
            }
            layout.CompletePage();
        }
Пример #8
0
 private static void ReadTablixStructure(RPLTablix tablix, ALayout layout, int top, int left, int generationIndex, BlockOutlines blockOutlines, Dictionary <string, ToggleParent> toggleParents, bool suppressOutlines, string subreportLanguage)
 {
     if (tablix != null)
     {
         int num = 0;
         if (tablix.ColumnWidths != null)
         {
             num = tablix.ColumnWidths.Length;
         }
         int[] array = new int[num + 1];
         array[0] = left;
         double num2           = (double)left;
         int    num3           = 0;
         int    rowHeaderWidth = 0;
         for (int i = 1; i <= num; i++)
         {
             num2    += LayoutConvert.ConvertMMTo20thPointsUnrounded((double)tablix.ColumnWidths[i - 1]);
             array[i] = (int)Math.Round(num2);
             if (tablix.ColsBeforeRowHeaders == 0 && i == tablix.RowHeaderColumns)
             {
                 rowHeaderWidth = (int)Math.Round(num2 - (double)left);
             }
         }
         num3 = (int)Math.Round(num2 - (double)left);
         int num4 = 0;
         if (tablix.RowHeights != null)
         {
             num4 = tablix.RowHeights.Length;
         }
         int[] array2 = new int[num4 + 1];
         array2[0] = top;
         double num5 = (double)top;
         int    num6 = 0;
         int    columnHeaderHeight = 0;
         for (int j = 1; j <= num4; j++)
         {
             num5     += LayoutConvert.ConvertMMTo20thPointsUnrounded((double)tablix.RowHeights[j - 1]);
             array2[j] = (int)Math.Round(num5);
             if (j == tablix.ColumnHeaderRows)
             {
                 columnHeaderHeight = (int)Math.Round(num5 - (double)top);
             }
         }
         num6 = (int)Math.Round(num5 - (double)top);
         List <RelativeStaticLocation> list = new List <RelativeStaticLocation>();
         bool         flag = false;
         RPLTablixRow nextRow;
         while ((nextRow = tablix.GetNextRow()) != null)
         {
             bool flag2 = false;
             RelativeStaticLocation relativeStaticLocation = new RelativeStaticLocation();
             if (!suppressOutlines && nextRow.OmittedHeaders != null)
             {
                 for (int k = 0; k < nextRow.OmittedHeaders.Count; k++)
                 {
                     RPLTablixMemberCell rPLTablixMemberCell = nextRow.OmittedHeaders[k];
                     if (Reader.SetRelativeStaticLocation(rPLTablixMemberCell, layout, relativeStaticLocation, list, ref flag2))
                     {
                         flag = true;
                     }
                     Reader.ReadTablixCellProperties(rPLTablixMemberCell, layout, array2, array, generationIndex + 1, tablix.LayoutDirection == RPLFormat.Directions.RTL, blockOutlines, toggleParents, suppressOutlines, subreportLanguage);
                     nextRow.OmittedHeaders[k] = null;
                 }
             }
             for (int l = 0; l < nextRow.NumCells; l++)
             {
                 RPLTablixCell rPLTablixCell = nextRow[l];
                 if (!suppressOutlines)
                 {
                     RPLTablixMemberCell rPLTablixMemberCell2 = rPLTablixCell as RPLTablixMemberCell;
                     if (rPLTablixMemberCell2 != null && Reader.SetRelativeStaticLocation(rPLTablixMemberCell2, layout, relativeStaticLocation, list, ref flag2))
                     {
                         flag = true;
                     }
                 }
                 Reader.ReadTablixCellProperties(rPLTablixCell, layout, array2, array, generationIndex + 1, tablix.LayoutDirection == RPLFormat.Directions.RTL, blockOutlines, toggleParents, suppressOutlines, subreportLanguage);
                 nextRow[l] = null;
             }
             if (!suppressOutlines && flag2 && !layout.SummaryColumnAfter.HasValue)
             {
                 layout.SummaryColumnAfter = relativeStaticLocation.IsSummaryAfter();
             }
         }
         if (!suppressOutlines)
         {
             int num7 = 0;
             while (!layout.SummaryRowAfter.HasValue && num7 < list.Count)
             {
                 RelativeStaticLocation relativeStaticLocation2 = list[num7];
                 layout.SummaryRowAfter = relativeStaticLocation2.IsSummaryAfter();
                 num7++;
             }
             if (flag)
             {
                 layout.AddStructuralItem(top, left, num3, num6, ALayout.TablixStructStart + ALayout.TablixStructGenerationOffset * generationIndex, rowHeaderWidth, columnHeaderHeight, tablix.LayoutDirection == RPLFormat.Directions.RTL);
             }
         }
     }
 }
Пример #9
0
        private static void ReadMeasurement(RPLElement element, ALayout layout, int top, int left, int generationIndex, BlockOutlines blockOutlines, Dictionary <string, ToggleParent> toggleParents, bool suppressOutlines, int elementWidth, string subreportLanguage)
        {
            RPLContainer rPLContainer = element as RPLContainer;

            if (rPLContainer != null)
            {
                if (rPLContainer.Children != null)
                {
                    bool         flag         = false;
                    int          num          = 0;
                    RPLSubReport rPLSubReport = element as RPLSubReport;
                    if (rPLSubReport != null)
                    {
                        flag = true;
                        if (!suppressOutlines)
                        {
                            toggleParents = new Dictionary <string, ToggleParent>();
                        }
                        string language = ((RPLSubReportProps)rPLSubReport.ElementProps).Language;
                        if (!string.IsNullOrEmpty(language))
                        {
                            subreportLanguage = language;
                        }
                    }
                    int[]     array  = new int[rPLContainer.Children.Length];
                    int[]     array2 = new int[rPLContainer.Children.Length];
                    int[]     array3 = new int[rPLContainer.Children.Length];
                    RPLItem[] array4 = new RPLItem[rPLContainer.Children.Length];
                    for (int i = 0; i < rPLContainer.Children.Length; i++)
                    {
                        RPLItemMeasurement rPLItemMeasurement = rPLContainer.Children[i];
                        if (0.0 == rPLItemMeasurement.Width && 0.0 == rPLItemMeasurement.Height)
                        {
                            rPLContainer.Children[i] = null;
                        }
                        else
                        {
                            if ((0.0 == rPLItemMeasurement.Width || 0.0 == rPLItemMeasurement.Height) && !(rPLItemMeasurement.Element is RPLLine))
                            {
                                rPLContainer.Children[i] = null;
                                continue;
                            }
                            int num2 = LayoutConvert.ConvertMMTo20thPoints((double)rPLItemMeasurement.Height);
                            int num3 = 0;
                            if (flag)
                            {
                                num3      = elementWidth;
                                array2[i] = LayoutConvert.ConvertMMTo20thPoints((double)rPLItemMeasurement.Top) + top + num;
                                num      += num2;
                            }
                            else
                            {
                                num3      = LayoutConvert.ConvertMMTo20thPoints((double)rPLItemMeasurement.Width);
                                array2[i] = LayoutConvert.ConvertMMTo20thPoints((double)rPLItemMeasurement.Top) + top;
                            }
                            array[i]  = num3;
                            array3[i] = LayoutConvert.ConvertMMTo20thPoints((double)rPLItemMeasurement.Left) + left;
                            RPLItem      rPLItem   = array4[i] = rPLItemMeasurement.Element;
                            byte         b         = default(byte);
                            RPLItemProps itemProps = layout.RPLReport.GetItemProps(rPLItem.RPLSource, out b);
                            if (b == 7)
                            {
                                RPLTextBoxPropsDef rPLTextBoxPropsDef = (RPLTextBoxPropsDef)itemProps.Definition;
                                if (rPLTextBoxPropsDef.IsSimple)
                                {
                                    layout.AddReportItem(rPLItem.RPLSource, array2[i], array3[i], num3, num2, generationIndex, rPLItemMeasurement.State, subreportLanguage, toggleParents);
                                }
                                else
                                {
                                    layout.AddReportItem(rPLItem, array2[i], array3[i], num3, num2, generationIndex, rPLItemMeasurement.State, subreportLanguage, toggleParents);
                                }
                                if (!suppressOutlines && rPLTextBoxPropsDef.IsToggleParent && !toggleParents.ContainsKey(rPLTextBoxPropsDef.Name))
                                {
                                    toggleParents.Add(rPLTextBoxPropsDef.Name, new ToggleParent(array2[i], array3[i], num3, num2));
                                }
                            }
                            else
                            {
                                layout.AddReportItem(rPLItem.RPLSource, array2[i], array3[i], num3, num2, generationIndex, rPLItemMeasurement.State, subreportLanguage, toggleParents);
                            }
                        }
                    }
                    for (int j = 0; j < rPLContainer.Children.Length; j++)
                    {
                        if (rPLContainer.Children[j] != null)
                        {
                            Reader.ReadMeasurement(array4[j], layout, array2[j], array3[j], generationIndex + 1, blockOutlines, toggleParents, suppressOutlines, array[j], subreportLanguage);
                            rPLContainer.Children[j] = null;
                            array4[j] = null;
                        }
                    }
                    rPLContainer.Children = null;
                }
            }
            else
            {
                Reader.ReadTablixStructure(element as RPLTablix, layout, top, left, generationIndex, blockOutlines, toggleParents, suppressOutlines, subreportLanguage);
            }
        }