Пример #1
0
        protected override void FillGridBefore()
        {
            IList <XModelBase> stateList = this.m_EquipmentStateBusiness.GetAll();

            IList <string> colors = new List <string>();

            foreach (XModelBase model in stateList)
            {
                XCodeEquipmentStateInfo stateInfo = model as XCodeEquipmentStateInfo;

                GridEXFormatCondition condition = new GridEXFormatCondition();
                if (!colors.Contains(stateInfo.ColorRGB) && stateInfo.ColorRGB != "0,0,0")
                {
                    Color color = XColorHelper.GetColorFormStringRgb(stateInfo.ColorRGB);
                    condition.FormatStyle.BackColor = color;
                    condition.Column = this.grdData.RootTable.Columns["ColorRGB"];
                    condition.Value1 = stateInfo.ColorRGB;
                    if (condition.Column != null)
                    {
                        this.grdData.RootTable.FormatConditions.Add(condition);
                    }

                    colors.Add(stateInfo.ColorRGB);
                }
            }
        }
Пример #2
0
        protected override void FillGridBefore()
        {
            IList <string> colors = new List <string>();

            foreach (XModelBase model in this.m_CurrentList)
            {
                XCodeEquipmentStateInfo stateInfo = model as XCodeEquipmentStateInfo;

                GridEXFormatCondition condition = new GridEXFormatCondition();
                if (!colors.Contains(stateInfo.ColorRGB) && stateInfo.ColorRGB != "0,0,0")
                {
                    try
                    {
                        Color color = XColorHelper.GetColorFormStringRgb(stateInfo.ColorRGB);
                        condition.FormatStyle.BackColor = color;
                        condition.Column = this.grdData.RootTable.Columns["ColorRGB"];
                        condition.Value1 = stateInfo.ColorRGB;
                        this.grdData.RootTable.FormatConditions.Add(condition);

                        colors.Add(stateInfo.ColorRGB);
                    }
                    catch (Exception ex)
                    {
                        XErrorLogTool.WriteLog(ex.ToString());
                    }
                }
            }
        }
Пример #3
0
        static void OldSimpleMain(string[] args)
        {
            PdfSharpCore.Fonts.GlobalFontSettings.FontResolver = new FontResolver();

            MigraDocCore.DocumentObjectModel.MigraDoc.DocumentObjectModel.Shapes
            .ImageSource.ImageSourceImpl = new PdfSharpCore.ImageSharp.ImageSharpImageSource <SixLabors.ImageSharp.PixelFormats.Rgba32>();


            using (PdfSharpCore.Pdf.PdfDocument document = new PdfSharpCore.Pdf.PdfDocument())
            {
                document.Info.Title    = "Family Tree";
                document.Info.Author   = "FamilyTree Ltd. - Stefan Steiger";
                document.Info.Subject  = "Family Tree";
                document.Info.Keywords = "Family Tree, Genealogical Tree, Genealogy, Bloodline, Pedigree";


                document.ViewerPreferences.Direction = PdfSharpCore.Pdf.PdfReadingDirection.LeftToRight;

                PdfSharpCore.Pdf.PdfPage page = document.AddPage();

                // page.Width = PdfSettings.PaperFormatSettings.Width
                // page.Height = PdfSettings.PaperFormatSettings.Height

                page.Width  = 500;
                page.Height = 1000;

                page.Orientation = PdfSharpCore.PageOrientation.Landscape;


                double mid              = page.Width / 2;
                double textBoxWidth     = 200;
                double halfTextBoxWidth = textBoxWidth / 2;


                using (PdfSharpCore.Drawing.XGraphics gfx = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page))
                {
                    gfx.MUH = PdfSharpCore.Pdf.PdfFontEncoding.Unicode;

                    PdfSharpCore.Drawing.Layout.XTextFormatter tf = new PdfSharpCore.Drawing.Layout.XTextFormatter(gfx);
                    tf.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Left;

                    PdfSharpCore.Drawing.Layout.XTextFormatterEx2 etf = new PdfSharpCore.Drawing.Layout.XTextFormatterEx2(gfx);


                    string fn = @"C:\Users\username\Pictures\4_Warning_Signs_Of_Instability_In_Russia1.png";
                    // fn = @"C:\Users\username\Pictures\62e867ba-9bb7-40d0-b01f-57f7cc951929.jpg";
                    // DrawImg(fn, gfx, 10, 10);



                    double dblWidth     = 1.0;
                    string strHtmlColor = "#FF00FF";
                    PdfSharpCore.Drawing.XColor LineColor = XColorHelper.FromHtml(strHtmlColor);
                    PdfSharpCore.Drawing.XPen   pen       = new PdfSharpCore.Drawing.XPen(LineColor, dblWidth);


                    double dblX1 = 100;
                    double dblY1 = 100;

                    double dblX2 = 200;
                    double dblY2 = 200;
                    gfx.DrawLine(pen, dblX1, dblY1, dblX2, dblY2);



                    double rectX      = 100;
                    double rectY      = 100;
                    double rectWidth  = 200;
                    double rectHeight = 100;

                    PdfSharpCore.Drawing.XRect rect = new PdfSharpCore.Drawing.XRect(rectX, rectY
                                                                                     , rectWidth, rectHeight
                                                                                     );

                    PdfSharpCore.Drawing.XFont font = new PdfSharpCore.Drawing.XFont("Arial"
                                                                                     , 12.0, PdfSharpCore.Drawing.XFontStyle.Bold
                                                                                     );

                    int    lastFittingChar = 0;
                    double neededHeight    = 0.0;


                    string text = @"I bi dr Gummiboum
U schtah eifach so chli da
So wie jedä Gummiboum 
'sch im Fau aues, woni cha

U i nime d Tage so wie si sii
U si chömed u gö wider verbii
U aues wird anders oder blibt wies isch gsii

Ja i nime d Tage so we si sii
U si chömed u gö wider verbii
Aues wird anders oder blibt wies isch gsii

Ja aues wird anders oder blibt wies isch gsii

I bi dr Gummiboum
U verstoube fängs ä chli
Oh Gummiboum

I bin ä geile huere Gummiboum
öppert mues ne schliesslich sii";

                    etf.PrepareDrawString(text, font, rect, out lastFittingChar, out neededHeight);
                    System.Console.WriteLine(lastFittingChar);
                    System.Console.WriteLine(neededHeight);

                    string foo = text.Substring(0, lastFittingChar);
                    System.Console.WriteLine(foo);


                    tf.DrawString(text
                                  , font
                                  , PdfSharpCore.Drawing.XBrushes.Black
                                  , rect
                                  , PdfSharpCore.Drawing.XStringFormats.TopLeft
                                  );

                    //gfx.DrawRectangle(PdfSharpCore.Drawing.XBrushes.HotPink, rect);
                    gfx.DrawRectangle(pen, rect);
                } // End Using gfx


                byte[] baPdfDocument;

                using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
                {
                    document.Save(ms, false);
                    ms.Flush();

                    // baPdfDocument = new byte[ms.Length];
                    // ms.Seek(0, System.IO.SeekOrigin.Begin);
                    // ms.Read(baPdfDocument, 0, (int)ms.Length);

                    baPdfDocument = ms.ToArray();
                } // End Using ms


                System.IO.File.WriteAllBytes("FamilyTree.pdf", baPdfDocument);
                //document.Save(filename);
            } // End Using document

            System.Console.WriteLine(System.Environment.NewLine);
            System.Console.WriteLine(" --- Press any key to continue --- ");
            System.Console.ReadKey();
        } // End Sub Main
Пример #4
0
        static void WriteTest()
        {
            using (PdfSharp.Pdf.PdfDocument document = new PdfSharp.Pdf.PdfDocument())
            {
                document.Info.Title    = "Family Tree";
                document.Info.Author   = "FamilyTree Ltd. - Stefan Steiger";
                document.Info.Subject  = "Family Tree";
                document.Info.Keywords = "Family Tree, Genealogical Tree, Genealogy, Bloodline, Pedigree";


                PdfSharp.Pdf.Security.PdfSecuritySettings securitySettings = document.SecuritySettings;

                // Setting one of the passwords automatically sets the security level to
                // PdfDocumentSecurityLevel.Encrypted128Bit.
                securitySettings.UserPassword  = "******";
                securitySettings.OwnerPassword = "******";

                // Don't use 40 bit encryption unless needed for compatibility
                //securitySettings.DocumentSecurityLevel = PdfDocumentSecurityLevel.Encrypted40Bit;

                // Restrict some rights.
                securitySettings.PermitAccessibilityExtractContent = false;
                securitySettings.PermitAnnotations      = false;
                securitySettings.PermitAssembleDocument = false;
                securitySettings.PermitExtractContent   = false;
                securitySettings.PermitFormsFill        = true;
                securitySettings.PermitFullQualityPrint = false;
                securitySettings.PermitModifyDocument   = true;
                securitySettings.PermitPrint            = false;



                document.ViewerPreferences.Direction = PdfSharp.Pdf.PdfReadingDirection.LeftToRight;
                PdfSharp.Pdf.PdfPage page = document.AddPage();

                // page.Width = PdfSettings.PaperFormatSettings.Width
                // page.Height = PdfSettings.PaperFormatSettings.Height

                page.Orientation = PdfSharp.PageOrientation.Landscape;
                double dblLineWidth = 1.0;
                string strHtmlColor = "#FF00FF";
                PdfSharp.Drawing.XColor lineColor = XColorHelper.FromHtml(strHtmlColor);
                PdfSharp.Drawing.XPen   pen       = new PdfSharp.Drawing.XPen(lineColor, dblLineWidth);

                PdfSharp.Drawing.XFont font = new PdfSharp.Drawing.XFont("Arial"
                                                                         , 12.0, PdfSharp.Drawing.XFontStyle.Bold
                                                                         );



                using (PdfSharp.Drawing.XGraphics gfx = PdfSharp.Drawing.XGraphics.FromPdfPage(page))
                {
                    gfx.MUH = PdfSharp.Pdf.PdfFontEncoding.Unicode;

                    PdfSharp.Drawing.Layout.XTextFormatter tf = new PdfSharp.Drawing.Layout.XTextFormatter(gfx);
                    tf.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;

                    PdfSharp.Drawing.Layout.XTextFormatterEx2 etf = new PdfSharp.Drawing.Layout.XTextFormatterEx2(gfx);


                    gfx.DrawRectangle(pen, new PdfSharp.Drawing.XRect(100, 100, 100, 100));

                    using (PdfSharp.Drawing.XImage img = PdfSharp.Drawing.XImage.FromFile(@"D:\username\Documents\Visual Studio 2017\Projects\PdfSharp\TestApplication\Wikipedesketch1.png"))
                    {
                        gfx.DrawImage(img, 500, 500);
                    }

                    string text = "Lalala";

                    tf.DrawString(text
                                  , font
                                  , PdfSharp.Drawing.XBrushes.Black
                                  , new PdfSharp.Drawing.XRect(300, 300, 100, 100)
                                  , PdfSharp.Drawing.XStringFormats.TopLeft
                                  );
                } // End Using gfx

                // Save the document...
                string filename = "TestFilePwProtected.pdf";
                document.Save(filename);
                // ...and start a viewer.
                System.Diagnostics.Process.Start(filename);
            } // End Using document
        }     // End Sub WriteTest