Ejemplo n.º 1
0
        public ExtentTest RecordPassStatus(
            string LogNote,
            string ScreenshotLocation,
            string TestCase,
            string description,
            Status TestStatus,
            ExtentTest test,
            DocX doc)
        {
            ScreenCaputres.TakeSreenShot(context, ScreenshotLocation + TestCase + ".png");
            test.Log(TestStatus, LogNote);
            test.CreateNode(LogNote).Log(TestStatus, description).AddScreenCaptureFromPath("images\\" + TestCase + ".png");
            Xceed.Words.NET.Image img = doc.AddImage(ScreenshotLocation + TestCase + ".png");
            Picture p = img.CreatePicture();
            //Create a new paragraph
            Paragraph par = doc.InsertParagraph(LogNote);

            p.HeightInches = 3.8;
            p.WidthInches  = 6.5;
            par.AppendPicture(p);
            Paragraph desc = doc.InsertParagraph(description);

            par.Alignment = Alignment.center;
            par.FontSize(16);
            par.AppendLine("\n");
            par.AppendLine("\n");
            return(test);
        }
Ejemplo n.º 2
0
        private void SaveToWordFile()
        {
            ScreenCapture sc = new ScreenCapture();

            // capture entire screen, and save it to a file
            System.Drawing.Image img1 = sc.CaptureScreen();
            // display image in a Picture control named imageDisplay
            pictureBox1.Image = img1;
            // capture this window, and save it;
            //sc.CaptureWindowToFile(this.Handle, Guid.NewGuid()+".gif", ImageFormat.Gif);
            img1.Save("Screenshot" + ".jpg", ImageFormat.Gif);
            counter++;
            string fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\" + "Capture Screen" + "\\";

            if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\" + "Capture Screen" + "\\"))
            {
                Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\" + "Capture Screen" + "\\");
            }
            if (!File.Exists(fileName + DateTime.Now.ToString("dd-MM-yyyy") + ".docx"))
            {
                var docCreate = DocX.Create(fileName + DateTime.Now.ToString("dd-MM-yyyy") + ".docx");
                docCreate.Save();
            }
            var     docload = DocX.Load(fileName + DateTime.Now.ToString("dd-MM-yyyy") + ".docx");
            Image   img     = docload.AddImage("Screenshot.jpg");
            Picture p       = img.CreatePicture();

            p.Width  = 690;
            p.Height = 365;
            Xceed.Words.NET.Paragraph par = docload.InsertParagraph(Convert.ToString(counter));
            par.AppendPicture(p);
            docload.Save();
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            //创建文档
            using (DocX document = DocX.Create(@"HelloWorld.docx"))
            {
                //插入段落
                Paragraph p = document.InsertParagraph();

                //段落加入文本,定义格式
                p.Append("Hello World!")              //内容
                .Font(new Xceed.Words.NET.Font("宋体")) //字体格式
                .FontSize(20)                         //字体大小
                .Color(Color.Blue)                    //字体颜色
                .Bold()
                .Alignment = Alignment.center;        //字体对其方式

                p = document.InsertParagraph();       //创建段落
                p.Append("CHINA")
                .Font(new Xceed.Words.NET.Font("微软雅黑"))
                .FontSize(18)
                .Color(Color.Red);

                //插入表格4x4,使用addtable后再inserttable
                var table1 = document.AddTable(9, 4);
                table1.Design = TableDesign.TableGrid;

                for (int i = 0; i < 9; i++)
                {
                    for (int k = 0; k < 4; k++)
                    {
                        table1.Rows[i].Cells[k].Paragraphs.First().InsertText(string.Format("第{0}行,第{1}列", i, k));
                    }
                }
                //合并单元格
                table1.MergeCellsInColumn(0, 0, 1);
                //////水平合并(合并第1行的第1、2个单元格)
                //table1.ApplyHorizontalMerge(0, 0, 1);
                //table1.Rows[0].Cells[0].Paragraphs[0].ChildObjects.Add(table.Rows[0].Cells[1].Paragraphs[0].ChildObjects[0]);

                ////垂直合并(合并第1列的第3、4个单元格)
                //table.ApplyVerticalMerge(0,2, 3);
                //table.Rows[2].Cells[0].Paragraphs[0].ChildObjects.Add(table.Rows[3].Cells[0].Paragraphs[0].ChildObjects[0]);


                document.InsertTable(table1);

                //追加行
                document.Tables[0].InsertRow().Cells[1].Paragraphs.First().InsertText("新添11加的行");
                //插入图片
                p = document.InsertParagraph();
                Xceed.Words.NET.Image image = document.AddImage(@"1.jpg");
                Picture pic = image.CreatePicture();
                p.InsertPicture(pic);
                p.Alignment = Alignment.right;
                //保存文档
                document.Save();
            }
            MessageBox.Show("Done!");
        }
Ejemplo n.º 4
0
        private void SaveToNewFile()
        {
            try
            {
                string fileName = !string.IsNullOrEmpty(_FileName) ? _FileName + ".docx" : DateTime.Now.ToString("dd-MM-yyyy") + ".docx";

                if (!IsFileLocked(WordFileDirectory + fileName))
                {
                    sc = new ScreenCapture();

                    // capture entire screen, and save it to a file
                    System.Drawing.Image img1 = sc.CaptureScreen();

                    // capture this window, and save it;
                    //sc.CaptureWindowToFile(this.Handle, Guid.NewGuid()+".gif", ImageFormat.Gif);
                    img1.Save("Screenshot" + ".jpg", ImageFormat.Jpeg);

                    if (!Directory.Exists(WordFileDirectory))
                    {
                        Directory.CreateDirectory(WordFileDirectory);
                    }

                    if (!File.Exists(WordFileDirectory + fileName))
                    {
                        var docCreate = DocX.Create(WordFileDirectory + fileName);
                        docCreate.Save();
                    }
                    var     docload = DocX.Load(WordFileDirectory + fileName);
                    Image   img     = docload.AddImage("Screenshot.jpg");
                    Picture p       = img.CreatePicture();
                    p.Width  = 690;
                    p.Height = 365;

                    Paragraph par = docload.InsertParagraph(Convert.ToString(" "));
                    par.AppendPicture(p);
                    docload.Save();
                }
                else
                {
                    MessageBox.Show("The action can't be completed because the file is open in System.", "Error", MessageBoxButtons.OK);
                }
            }
            catch (IOException ex)
            {
                flag = true;
                MessageBox.Show("The action can't be completed because the file is open in System.", "Error", MessageBoxButtons.OK);
            }
            catch (Exception ex)
            {
                flag = true;
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK);
            }
            finally
            {
                ThreadStart();
            }
        }
Ejemplo n.º 5
0
        public void GenerateObservation()
        {
            report.InsertParagraph("Observation:").Bold().UnderlineStyle(UnderlineStyle.singleLine);
            report.InsertParagraph("Yield: " + Yield);
            report.InsertParagraph(ObservationText);

            foreach (string actualimg in ObservationImg)
            {
                Xceed.Words.NET.Image observtionimg = report.AddImage(actualimg);
                Picture observationpic = observtionimg.CreatePicture();
                report.InsertParagraph().AppendPicture(observationpic);
            }

            Console.WriteLine("Observation generated");
        }
Ejemplo n.º 6
0
        private void SaveToExistingFile()
        {
            try
            {
                sc = new ScreenCapture();

                // capture entire screen, and save it to a file
                System.Drawing.Image img1 = sc.CaptureScreen();

                // capture this window, and save it;
                //sc.CaptureWindowToFile(this.Handle, Guid.NewGuid()+".gif", ImageFormat.Gif);
                img1.Save("Screenshot" + ".jpg", ImageFormat.Jpeg);

                if (!File.Exists(ExistingFileName))
                {
                    var docCreate = DocX.Create(ExistingFileName);
                    docCreate.Save();
                }
                var     docload = DocX.Load(ExistingFileName);
                Image   img     = docload.AddImage("Screenshot.jpg");
                Picture p       = img.CreatePicture();
                p.Width  = 690;
                p.Height = 365;

                Paragraph par = docload.InsertParagraph(Convert.ToString(" "));
                par.AppendPicture(p);
                docload.Save();
            }
            catch (IOException ex)
            {
                flag = true;
                MessageBox.Show("The action can't be completed because the file is open in System.", "Error", MessageBoxButtons.OK);
            }
            catch (Exception ex)
            {
                flag = true;
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK);
            }
            finally
            {
                ThreadStart();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Record Status for Word doc
        /// </summary>
        /// <param name="LogNote"></param>
        /// <param name="ScreenshotLocation"></param>
        /// <param name="TestCase"></param>
        /// <param name="doc"></param>
        public void RecordStepStatus(
            string LogNote,
            string ScreenshotLocation,
            string TestCase,
            DocX doc)
        {
            ScreenCaputres.TakeSreenShot(context, ScreenshotLocation + TestCase + ".png");
            //Document
            Xceed.Words.NET.Image img = doc.AddImage(ScreenshotLocation + TestCase + ".png");
            Picture p = img.CreatePicture();
            //Create a new paragraph
            Paragraph par = doc.InsertParagraph(LogNote);

            p.HeightInches = 3.8;
            p.WidthInches  = 6.8;
            par.AppendPicture(p);
            par.Alignment = Alignment.center;
            par.FontSize(16);
            par.AppendLine("\n");
            par.AppendLine("\n");
        }
Ejemplo n.º 8
0
        /*public void CalculateValues()
         * {
         *  StartingMaterial.CalculateStartingMaterialValues();
         *  foreach (MoleculeRow item in Reagents)
         *  {
         *      item.CalculateReagentValues(StartingMaterial);
         *  }
         *  foreach (var item in Products)
         *  {
         *      item.CalculateProductValues(StartingMaterial);
         *  }
         *
         *
         *
         *
         * }*/


        public void GenerateReaction()
        {
            report.InsertParagraph("Reactions:\n").Bold().UnderlineStyle(UnderlineStyle.singleLine);

            Xceed.Words.NET.Image reactionimg = report.AddImage(ReactionImgPath);

            Picture reactionpic = reactionimg.CreatePicture();


            report.InsertParagraph().AppendPicture(reactionpic);

            report.InsertParagraph("Table of materials:\n").Bold().UnderlineStyle(UnderlineStyle.singleLine);

            //Material table
            int rowcnt = 2 + Reagents.Count + Solvents.Count + Products.Count;
            //header -> x1; starting material-> 1x; reagent cnt; solvent cnt; product cnt
            Table MaterialTable = report.AddTable(rowcnt, 10);

            float[] widths = new float[10] {
                50, 50, 50, 50, 60, 45, 40, 40, 40, 40
            };
            MaterialTable.SetWidths(widths);
            //ugly but... meh...
            MaterialTable.Rows[0].Cells[0].Paragraphs[0].Append("Name").Bold();
            MaterialTable.Rows[0].Cells[1].Paragraphs[0].Append("CAS").Bold();
            MaterialTable.Rows[0].Cells[2].Paragraphs[0].Append("MW (g/mol)").Bold();
            MaterialTable.Rows[0].Cells[3].Paragraphs[0].Append("Ratio").Bold();
            MaterialTable.Rows[0].Cells[4].Paragraphs[0].Append("n (mmol)").Bold();
            MaterialTable.Rows[0].Cells[5].Paragraphs[0].Append("m (mg)").Bold();
            MaterialTable.Rows[0].Cells[6].Paragraphs[0].Append("V (uL)").Bold();
            MaterialTable.Rows[0].Cells[7].Paragraphs[0].Append("Den. (g/ml)").Bold();
            MaterialTable.Rows[0].Cells[8].Paragraphs[0].Append("Mp. (°C)").Bold();
            MaterialTable.Rows[0].Cells[9].Paragraphs[0].Append("Bp. (°C)").Bold();

            //starting material
            InsertRow(MaterialTable, StartingMaterial, 1);

            int actualrow = 2;

            //reagents
            foreach (MoleculeRow item in Reagents)
            {
                InsertRow(MaterialTable, item, actualrow);
                actualrow++;
            }

            //solvents
            foreach (MoleculeRow item in Solvents)
            {
                InsertRow(MaterialTable, item, actualrow);
                actualrow++;
            }

            //product
            foreach (var item in Products)
            {
                InsertProductRow(MaterialTable, item, actualrow);
                actualrow++;
            }


            //products row background
            for (int i = Products.Count; i > 0; i--)
            {
                foreach (Cell item in MaterialTable.Rows[rowcnt - i].Cells)
                {
                    item.FillColor = Color.LightGray;
                }
            }

            report.InsertTable(MaterialTable);

            //Console.WriteLine("Material table generated");
        }
Ejemplo n.º 9
0
        public static void CriaDocumento(string localImagem, string nomeDoc)
        {
            var feature  = FeatureContext.Current.FeatureInfo.Title.ToString().Trim().Replace(" ", "");
            var scenario = ScenarioContext.Current.ScenarioInfo.Title.ToString().Trim().Replace(" ", "");

            var tempo                  = string.Format("{0:dd-MM-yyyy-hh-mm-ss}", DateTime.Now);
            var dateTime               = GeneralHelpers.GetCurrentDate("dd-MM-yyyy");
            var localArquivoBase       = AppDomain.CurrentDomain.BaseDirectory.Replace("bin\\Debug\\", "Evidências");
            var localArquivosDeletados = AppDomain.CurrentDomain.BaseDirectory.Replace("bin\\Debug\\", "Arquivos-Deletados" + "\\" + tempo);

            var localArquivoCompleto = string.Format("{0}\\{1}\\{2}\\{3}", localArquivoBase, feature, scenario, dateTime);

            if (!Directory.Exists(localArquivosDeletados))
            {
                Directory.CreateDirectory(localArquivosDeletados);
            }

            if (nomeDoc == null)
            {
                nomeDoc = tempo;

                List <string> arquivos = new List <string>(Directory.GetFiles(localImagem));
                if (arquivos.Contains(nomeDoc + ".docx"))
                {
                    for (int i = 0; i <= arquivos.Count; i++)
                    {
                        using (FileStream fs = new FileStream(nomeDoc + ".docx", FileMode.Open))
                        {
                            //abre um documento
                            using (var document = DocX.Load(fs))
                            {
                                //Instancia a imagem ao Xceed.Words.NET
                                Xceed.Words.NET.Image img = document.AddImage(arquivos[i]);

                                // Cria um tipo Picture desta imagem
                                Picture pic = img.CreatePicture(400, 600);

                                //Insere e configura a imagem
                                Paragraph p0 = document.InsertParagraph();

                                p0.InsertPicture(pic, 0)
                                .SpacingAfter(30)
                                .Alignment = Alignment.center;

                                //salva o documento


                                nomeArquivo = localArquivoBase + "\\" + nomeDoc + ".docx";
                                document.SaveAs(nomeArquivo);
                            }
                        }
                    }
                }
                else
                {
                    //cria um novo documento
                    using (var document = DocX.Create(nomeDoc + ".docx"))
                    {
                        document.InsertParagraph("Teste: " + nomeDoc
                                                 )
                        .FontSize(15d)
                        .Bold()
                        .SpacingAfter(50d)
                        .Alignment = Alignment.left;

                        for (int i = 0; i < arquivos.Count; i++)
                        {
                            //Instancia a imagem ao Xceed.Words.NET
                            Xceed.Words.NET.Image img = document.AddImage(arquivos[i]);

                            // Cria um tipo Picture desta imagem
                            Picture pic = img.CreatePicture(400, 600);

                            //Insere e configura a imagem
                            Paragraph p0 = document.InsertParagraph();

                            p0.InsertPicture(pic, 0)
                            .SpacingAfter(30)
                            .Alignment = Alignment.center;

                            //salva o documento
                            nomeArquivo = localArquivoCompleto + "\\" + nomeDoc + ".docx";
                            document.SaveAs(nomeArquivo);

                            Directory.Move(arquivos[i], localArquivosDeletados);
                        }
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            // region creates the file and inserts the document header
            #region one
            string fileName = "greeting.docx";
            var    doc      = DocX.Create(fileName);
            doc.InsertParagraph("Hello There!");
            #endregion

            // reates a document header
            #region two
            string title = "What is 12/25 Publishing?";

            //Formats the document header
            // and gives attributes such as font family, font size,
            // position, font color etc

            Formatting titleFormat = new Formatting();
            titleFormat.FontFamily     = new Xceed.Words.NET.Font("Times New Roman");
            titleFormat.Size           = 20D;
            titleFormat.Position       = 40;
            titleFormat.FontColor      = Color.Blue;
            titleFormat.Bold           = true;
            titleFormat.UnderlineColor = Color.Black;
            titleFormat.Italic         = false;

            // paragraph Text
            string textParagraph = "That's a good question! " + Environment.NewLine +
                                   "12/25 Publishing is an independent publishing house with a passion for children's books. " +
                                   "Please visit Amazon for our latest offering, 'Jeremy Brown and The Unorthodox Crown'" + Environment.NewLine;

            //Formats the paragraph text and sets font family, font size, line spacing, etc
            Formatting textParagraphFormat = new Formatting();
            textParagraphFormat.FontFamily = new Xceed.Words.NET.Font("Times New Roman");
            textParagraphFormat.Size       = 12D;
            textParagraphFormat.Spacing    = 1;

            //Insert title
            Paragraph paragraphTitle = doc.InsertParagraph(title, true, titleFormat);
            paragraphTitle.Alignment = Alignment.center;
            //Insert text
            doc.InsertParagraph(textParagraph, true, textParagraphFormat);
            #endregion

            #region three
            //Create a picture
            Xceed.Words.NET.Image img = doc.AddImage(@"1225Logo.jpg");
            Picture pic = img.CreatePicture();

            //Create a new paragraph
            Paragraph par = doc.InsertParagraph("12/25 Publishing Logo. " + Environment.NewLine);

            par.AppendPicture(pic);
            #endregion

            #region four
            //Create Table with 2 rows and 4 columns.
            Table t = doc.AddTable(4, 2);
            t.Alignment = Alignment.left;
            t.Design    = TableDesign.LightList;

            // Fill cells by adding text.
            // First row
            t.Rows[0].Cells[0].Paragraphs.First().Append("Book Name");
            t.Rows[0].Cells[1].Paragraphs.First().Append("Availability");

            // Second row details
            t.Rows[1].Cells[0].Paragraphs.First().Append("Jeremy Brown and The Unorthodox Crown");
            t.Rows[1].Cells[1].Paragraphs.First().Append("Available");
            t.Rows[2].Cells[0].Paragraphs.First().Append("Jeremy Brown, P.I.");
            t.Rows[2].Cells[1].Paragraphs.First().Append("Available Soon");
            doc.InsertTable(t);
            #endregion

            #region five
            // Hyperlink
            Hyperlink url = doc.AddHyperlink(" Tara King", new Uri("http://itstaraking.wordpress.com"));
            Paragraph p1  = doc.InsertParagraph();
            p1.AppendLine("Please visit the author's site ").Bold().AppendHyperlink(url).Color(Color.Blue); // Hyperlink in blue color
            #endregion

            #region part of one
            doc.Save();
            Process.Start("WINWORD.EXE", fileName);
            #endregion
        }
Ejemplo n.º 11
0
        private void InsertPicture(Paragraph paragraphToInsert, ObservableCollection <Picture> pictures)
        {
            Table picTable = paragraphToInsert.InsertTableAfterSelf(1, 2);

            picTable.AutoFit   = AutoFit.Window;
            picTable.Alignment = Alignment.left;

            foreach (var p in pictures)
            {
                p.CreatePicture();
            }

            var i = 0;

            while (i < pictures.Count)
            {
                Xceed.Words.NET.Image   img = _templateDocx.AddImage(pictures[i].FullPath);
                Xceed.Words.NET.Picture p   = img.CreatePicture();

                //非手機圖
                if (!IsCellPhoneScreenshot(pictures[i]))
                {
                    var row = picTable.InsertRow();
                    row.MergeCells(0, 1);

                    var row2 = picTable.InsertRow();
                    row2.MergeCells(0, 1);

                    //按照比例縮小圖片,如圖片不足600寬,則保留原大小
                    ResizePicture(pictures[i], 600, out var width, out var height);
                    p.Width  = width;
                    p.Height = height;

                    //新增table放圖片
                    row.Cells[0].Paragraphs.First().Append(pictures[i].Caption).Font(Font);
                    row2.Cells[0].Paragraphs.First().InsertPicture(p);

                    if (i == pictures.Count - 1)
                    {
                        break;
                    }

                    i++;
                }

                //第一張手機圖
                else
                {
                    //最後一張圖
                    if (i == pictures.Count - 1)
                    {
                        var row = picTable.InsertRow();
                        row.MergeCells(0, 1);

                        var row2 = picTable.InsertRow();
                        row2.MergeCells(0, 1);

                        //按照比例縮小圖片,如圖片不足200寬,則保留原大小
                        ResizePicture(pictures[i], 200, out var width, out var height);
                        p.Width  = width;
                        p.Height = height;

                        //新增table放圖片
                        row.Cells[0].Paragraphs.First().Append(pictures[i].Caption).Font(Font);
                        row2.Cells[0].Paragraphs.First().InsertPicture(p);

                        break;
                    }
                    //下一張不是手機圖
                    if (!IsCellPhoneScreenshot(pictures[i + 1]))
                    {
                        var row = picTable.InsertRow();
                        row.MergeCells(0, 1);

                        var row2 = picTable.InsertRow();
                        row2.MergeCells(0, 1);

                        //按照比例縮小圖片,如圖片不足200寬,則保留原大小
                        ResizePicture(pictures[i], 200, out var width, out var height);
                        p.Width  = width;
                        p.Height = height;

                        //新增table放圖片
                        row2.Cells[0].Paragraphs.First().InsertPicture(p);
                        row.Cells[0].Paragraphs.First().Append(pictures[i].Caption).Font(Font);

                        i++;
                    }

                    //下一張也是手機圖
                    else
                    {
                        Xceed.Words.NET.Image   img2 = _templateDocx.AddImage(pictures[i + 1].FullPath);
                        Xceed.Words.NET.Picture p2   = img2.CreatePicture();

                        var row  = picTable.InsertRow();
                        var row2 = picTable.InsertRow();


                        //按照比例縮小圖片,如圖片不足200寬,則保留原大小
                        ResizePicture(pictures[i], 200, out var width, out var height);
                        p.Width  = width;
                        p.Height = height;

                        ResizePicture(pictures[i + 1], 200, out var width2, out var height2);
                        p2.Width  = width2;
                        p2.Height = height2;

                        //新增table放圖片
                        row.Cells[0].Paragraphs.First().Append(pictures[i].Caption).Font(Font);
                        row2.Cells[0].Paragraphs.First().InsertPicture(p);

                        row.Cells[1].Paragraphs.First().Append(pictures[i + 1].Caption).Font(Font);
                        row2.Cells[1].Paragraphs.First().InsertPicture(p2);

                        i += 2;
                    }
                }
            }
            picTable.RemoveRow(0);
            picTable.InsertParagraphAfterSelf("\r\n");

            foreach (var p in pictures)
            {
                p.ReleasePictureResource();
            }
        }
Ejemplo n.º 12
0
        public void fromvariableCreateDocument(GenericDocumentParameters in_documentArgs, String obtainedPath)
        {
            //prepare important days list
            MainXMLprocessor importantDaysProcessor = new MainXMLprocessor();
            importantdays    alldaysListRaw         = importantDaysProcessor.loadImportantDaysListFromFile(obtainedPath);
            Dictionary <System.DateTime, List <importantday> > importantDaysProcessed = importantDaysProcessor.getDictionaryForProcessing(alldaysListRaw);
            //=========
            DocX document = DocX.Create(in_documentArgs.documentName);

            // https://stackoverflow.com/a/90699/
            ConsoleAppCalendar.Properties.Resources.sunrise1f305.Save("sunrisetmp.png");
            ConsoleAppCalendar.Properties.Resources.sunset1f307.Save("sunsettmp.png");
            // https://xceed.com/wp-content/documentation/xceed-words-for-net/Xceed.Words.NET~Xceed.Words.NET.DocX~AddImage(Stream,String).html
            Xceed.Words.NET.Image imgSunrise = document.AddImage("sunrisetmp.png"); Xceed.Words.NET.Picture picSunrise = imgSunrise.CreatePicture();
            picSunrise.Height = (int)Math.Round(picSunrise.Height * 0.32);
            picSunrise.Width  = (int)Math.Round(picSunrise.Width * 0.32);
            Xceed.Words.NET.Image imgSunset = document.AddImage("sunsettmp.png"); Xceed.Words.NET.Picture picSunset = imgSunset.CreatePicture();
            picSunset.Height = (int)Math.Round(picSunset.Height * 0.38);
            picSunset.Width  = (int)Math.Round(picSunset.Width * 0.38);
            System.DateTime theCurrentDate = date1;
            do
            {
                document.PageHeight = in_documentArgs.pageHeight;
                document.PageWidth  = in_documentArgs.pageWidth;
                float btmMargin = 1.0f; float topMargin = 1.0f; float leftMargin = 1.0f; float rightMargin = 1.0f;
                document.MarginBottom = cmToPoints(btmMargin); document.MarginTop = cmToPoints(topMargin); document.MarginLeft = cmToPoints(leftMargin); document.MarginRight = cmToPoints(rightMargin);
                Table  insertedTable = document.InsertTable(in_documentArgs.numrowsTable, in_documentArgs.numcolsTable);
                Border b             = new Border(BorderStyle.Tcbs_single, BorderSize.one, 0, Color.Blue);
                //calculate each column width
                float bestColumnWidth = cmToPixels(((float)in_documentArgs.pageWidth - (float)(leftMargin + rightMargin)) / (float)(in_documentArgs.numcolsTable));
                float bestRowHeightPt = (((float)in_documentArgs.pageHeight - (float)(topMargin + btmMargin)) / (float)(in_documentArgs.numrowsTable));
                // Set the tables Top, Bottom, Left and Right Borders to b.
                insertedTable.SetBorder(TableBorderType.Top, b);
                insertedTable.SetBorder(TableBorderType.Bottom, b);
                insertedTable.SetBorder(TableBorderType.Left, b);
                insertedTable.SetBorder(TableBorderType.Right, b);
                insertedTable.SetBorder(TableBorderType.InsideH, b);
                insertedTable.SetBorder(TableBorderType.InsideV, b);
                byte currentRow = 0; byte currentCol = 0;
                while ((currentRow < in_documentArgs.numrowsTable) && (currentCol < in_documentArgs.numcolsTable) && (theCurrentDate <= date2))
                {
                    Table internalTable1 = insertedTable.Rows[currentRow].Cells[currentCol].InsertTable(1, 2);
                    internalTable1.SetWidthsPercentage(new float[] { 30.0f, 70.0f }, 100.0f);

                    /*
                     *  Paragraph yearMonthP = insertedTable.Rows[currentRow].Cells[currentCol].InsertParagraph(String.Format("{0:yyyy, MMMM}", theCurrentDate));
                     *  Paragraph dayNumberP = insertedTable.Rows[currentRow].Cells[currentCol].InsertParagraph(String.Format("{0:dd}", theCurrentDate));
                     *  Paragraph weekdayP = insertedTable.Rows[currentRow].Cells[currentCol].InsertParagraph(String.Format("{0:dddd}", theCurrentDate));
                     */
                    Paragraph yearMonthP = internalTable1.Rows[0].Cells[1].InsertParagraph(String.Format("{0:yyyy, MMMM}", theCurrentDate));
                    Paragraph dayNumberP = internalTable1.Rows[0].Cells[1].InsertParagraph(String.Format("{0:dd}", theCurrentDate));
                    Paragraph weekdayP   = internalTable1.Rows[0].Cells[1].InsertParagraph(String.Format("{0:dddd}", theCurrentDate));
                    yearMonthP.Alignment = Alignment.center; yearMonthP.Font("Courier New");
                    dayNumberP.Alignment = Alignment.center; dayNumberP.Font("Courier New"); dayNumberP.FontSize(15); dayNumberP.Bold();
                    weekdayP.Alignment   = Alignment.center; weekdayP.Font("Courier New");

                    Tuple <string, string> sunTimes = getSunsetAndSunRise(true, 2, theCurrentDate, 49.4444, 32.0597);
                    Paragraph sunriseParagraph      = internalTable1.Rows[0].Cells[0].InsertParagraph(String.Format("{0}", sunTimes.Item1));
                    // https://xceed.com/wp-content/documentation/xceed-words-for-net/webframe.html#Xceed.Words.NET~Xceed.Words.NET.Paragraph~InsertPicture.html
                    sunriseParagraph.InsertPicture(picSunrise);
                    Paragraph sunsetParagraph = internalTable1.Rows[0].Cells[0].InsertParagraph(String.Format("{0}", sunTimes.Item2));
                    sunsetParagraph.InsertPicture(picSunset);
                    internalTable1.Rows[0].Cells[1].Paragraphs[0].Remove(false);
                    internalTable1.Rows[0].Cells[0].Paragraphs[0].Remove(false);
                    insertedTable.Rows[currentRow].Cells[currentCol].Paragraphs[0].Remove(false);
                    insertedTable.SetColumnWidth(currentCol, bestColumnWidth);
                    // 100*2/3pt -> 3.53 cm
                    // x  px -> bestRowHeightCm
                    if (importantDaysProcessed.ContainsKey(theCurrentDate))
                    {
                        List <importantday> eventsForCurrentDate = importantDaysProcessed[theCurrentDate];
                        bool holidayDisplayed = false;
                        foreach (importantday specialevent in eventsForCurrentDate)
                        {
                            Paragraph eventParagraph = insertedTable.Rows[currentRow].Cells[currentCol].InsertParagraph("\u25EF " + specialevent.description);
                            eventParagraph.Font("Courier New");
                            if ((specialevent.typeOfDay == "holiday") && (holidayDisplayed == false))
                            {
                                holidayDisplayed = true;
                                Paragraph officialWeekendParagraph = internalTable1.Rows[0].Cells[1].InsertParagraph("/вихідний/");
                                officialWeekendParagraph.Alignment = Alignment.center; officialWeekendParagraph.Font("Courier New"); officialWeekendParagraph.FontSize(7.0); officialWeekendParagraph.Bold();
                            }
                        }
                    }

                    insertedTable.Rows[currentRow].Height = Math.Round(bestRowHeightPt * 0.88);

                    theCurrentDate = theCurrentDate.AddDays(1.0);
                    currentCol++;
                    if ((currentCol >= in_documentArgs.numcolsTable) && (currentRow < in_documentArgs.numrowsTable - 1))
                    {
                        currentCol = 0; currentRow++;
                    }
                }

                if (theCurrentDate <= date2)
                {
                    //document.InsertSectionPageBreak();
                    insertedTable.InsertPageBreakAfterSelf();
                }
            } while (theCurrentDate <= date2);


            //document.InsertTable(in_documentArgs.numrowsTable, in_documentArgs.numcolsTable);
            document.Save();
            System.IO.File.Delete("sunsettmp.png");
            System.IO.File.Delete("sunrise.png");
        }
Ejemplo n.º 13
0
        public static void GenerateRaport(Dictionary <string, string> tags, string originalImagePath, List <Marker> markerList, string analysisResult)
        {
            //try
            //{
            System.IO.Directory.CreateDirectory("Raporty");
            string path = @"Raporty/" + tags["(0010,0010)"] + "_" + String.Format("{0:MM/dd/yyyy/HH/mm/ss}", DateTime.Now) + ".docx";

            using (DocX document = DocX.Create(path))
            {
                Paragraph title = document.InsertParagraph();

                Table tTitle = document.AddTable(1, 4);

                tTitle.SetColumnWidth(0, 2000);
                string logoPath            = System.IO.Directory.GetCurrentDirectory().Substring(0, System.IO.Directory.GetCurrentDirectory().Length - 10);
                Xceed.Words.NET.Image logo = document.AddImage(logoPath + "\\Images\\icon.png");
                Picture logoImage          = logo.CreatePicture();
                logoImage.Height = 60;
                logoImage.Width  = 100;
                tTitle.Rows[0].Cells[0].Paragraphs[0].AppendPicture(logoImage);

                tTitle.SetColumnWidth(1, 5000);
                tTitle.Rows[0].Cells[1].Paragraphs[0].Alignment = Alignment.center;
                tTitle.Rows[0].Cells[1].Paragraphs[0].Append("Stacja komputerowego wspomagania diagnostyki medycznej na podstawie obrazów siatkówki oka")
                .Font("Times New Roman")
                .FontSize(14)
                .Color(Color.Black)
                .Bold();

                tTitle.SetColumnWidth(3, 2000);
                tTitle.Rows[0].Cells[3].Paragraphs[0].Append("\r\n" + String.Format("{0:MM.dd.yyyy r.}", DateTime.Now))
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black);

                title.InsertTableAfterSelf(tTitle);

                Paragraph patientData = document.InsertParagraph();
                patientData.Alignment = Alignment.center;
                patientData.Append("\r\n\r\nDane pacjenta").Font("Times New Roman")
                .FontSize(12)
                .Color(Color.Black).Bold();

                Paragraph patient = document.InsertParagraph();

                Table tPatient = document.AddTable(4, 2);

                tPatient.SetColumnWidth(0, 2000);
                tPatient.SetColumnWidth(1, 5000);

                tPatient.Rows[0].Cells[0].Paragraphs[0].Append("Imię i nazwisko:")
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black)
                .Bold();

                tPatient.Rows[1].Cells[0].Paragraphs[0].Append("Identyfikator:")
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black).Bold();

                tPatient.Rows[2].Cells[0].Paragraphs[0].Append("Data urodzenia:")
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black).Bold();

                tPatient.Rows[3].Cells[0].Paragraphs[0].Append("Płeć:")
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black).Bold();

                tPatient.Rows[1].Cells[1].Paragraphs[0].Append(tags["(0010,0020)"])
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black);

                tPatient.Rows[0].Cells[1].Paragraphs[0].Append(tags["(0010,0010)"])
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black);

                patient.InsertTableAfterSelf(tPatient);

                Paragraph studyData = document.InsertParagraph();
                studyData.Alignment = Alignment.center;
                studyData.Append("Opis badania\r\n").Font("Times New Roman")
                .FontSize(12)
                .Color(Color.Black).Bold();

                Paragraph description = document.InsertParagraph();
                description.Alignment = Alignment.left;
                string desc = tags["(0008,1080)"];
                if (desc == "0")
                {
                    desc = "-";
                }
                description.Append(desc).Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black);

                Paragraph analysisData = document.InsertParagraph();
                analysisData.Alignment = Alignment.center;
                analysisData.Append("Wynik analizy\r\n").Font("Times New Roman")
                .FontSize(12)
                .Color(Color.Black).Bold();

                Paragraph anlysisResult = document.InsertParagraph();
                anlysisResult.Alignment = Alignment.left;
                anlysisResult.Append(analysisResult).Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black);

                Paragraph images = document.InsertParagraph();

                Table tImages = document.AddTable(4, 2);
                tImages.SetColumnWidth(0, 5000);
                tImages.SetColumnWidth(1, 5000);

                tImages.Rows[0].Cells[0].Paragraphs[0].Alignment = Alignment.center;
                tImages.Rows[0].Cells[1].Paragraphs[0].Alignment = Alignment.center;
                tImages.Rows[1].Cells[0].Paragraphs[0].Alignment = Alignment.center;
                tImages.Rows[1].Cells[1].Paragraphs[0].Alignment = Alignment.center;
                tImages.Rows[2].Cells[0].Paragraphs[0].Alignment = Alignment.center;
                tImages.Rows[2].Cells[1].Paragraphs[0].Alignment = Alignment.center;
                tImages.Rows[3].Cells[0].Paragraphs[0].Alignment = Alignment.center;
                tImages.Rows[3].Cells[1].Paragraphs[0].Alignment = Alignment.center;

                tImages.Rows[0].Cells[0].Paragraphs[0].Append("\r\nObraz oryginalny")
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black);
                tImages.Rows[0].Cells[1].Paragraphs[0].Append("\r\nKanał zielony obrazu oryginalnego")
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black);
                tImages.Rows[2].Cells[0].Paragraphs[0].Append("\r\nWysegmentowane naczynia krwionośne\r\n")
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black);
                tImages.Rows[2].Cells[1].Paragraphs[0].Append("\r\nSzkielet naczyń krwionośnych\r\n")
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black);

                Xceed.Words.NET.Image image = document.AddImage(originalImagePath + ".jpg");
                Picture originalImage       = image.CreatePicture();
                originalImage.Height = 250;
                originalImage.Width  = 300;
                tImages.Rows[1].Cells[0].Paragraphs[0].AppendPicture(originalImage);

                Xceed.Words.NET.Image image4 = document.AddImage(originalImagePath + "-1.png");
                Picture greenInameg          = image4.CreatePicture();
                greenInameg.Height = 250;
                greenInameg.Width  = 300;
                tImages.Rows[1].Cells[1].Paragraphs[0].AppendPicture(greenInameg);

                Xceed.Words.NET.Image image2 = document.AddImage(originalImagePath + "-2.png");
                Picture segmentationImage    = image2.CreatePicture();
                segmentationImage.Height = 250;
                segmentationImage.Width  = 300;
                tImages.Rows[3].Cells[0].Paragraphs[0].AppendPicture(segmentationImage);

                Xceed.Words.NET.Image image3 = document.AddImage(originalImagePath + "-3.png");
                Picture skelImage            = image3.CreatePicture();
                skelImage.Height = 250;
                skelImage.Width  = 300;
                tImages.Rows[3].Cells[1].Paragraphs[0].AppendPicture(skelImage);

                images.InsertTableAfterSelf(tImages);

                Paragraph measurments = document.InsertParagraph();

                measurments.Alignment = Alignment.center;
                measurments.Append("Pomiary na obrazie\r\n\r\n").Font("Times New Roman")
                .FontSize(12)
                .Color(Color.Black).Bold();

                Xceed.Words.NET.Image image5 = document.AddImage(originalImagePath + "-0.png");
                Picture measurmentsImage     = image5.CreatePicture();
                measurmentsImage.Height = 450;
                measurmentsImage.Width  = 500;
                measurments.AppendPicture(measurmentsImage);

                int   rows = markerList.Count + 1;
                Table t    = document.AddTable(rows, 2);
                t.SetBorder(TableBorderType.Bottom, new Border(Xceed.Words.NET.BorderStyle.Tcbs_single, BorderSize.one, 1, Color.Black));
                t.SetBorder(TableBorderType.InsideH, new Border(Xceed.Words.NET.BorderStyle.Tcbs_single, BorderSize.one, 1, Color.Black));
                t.SetBorder(TableBorderType.InsideV, new Border(Xceed.Words.NET.BorderStyle.Tcbs_single, BorderSize.one, 1, Color.Black));
                t.SetBorder(TableBorderType.Left, new Border(Xceed.Words.NET.BorderStyle.Tcbs_single, BorderSize.one, 1, Color.Black));
                t.SetBorder(TableBorderType.Right, new Border(Xceed.Words.NET.BorderStyle.Tcbs_single, BorderSize.one, 1, Color.Black));
                t.SetBorder(TableBorderType.Top, new Border(Xceed.Words.NET.BorderStyle.Tcbs_single, BorderSize.one, 1, Color.Black));
                t.Alignment = Alignment.center;

                measurments.Append("\r\n").Font("Times New Roman")
                .FontSize(12)
                .Color(Color.Black).Bold();

                t.Rows[0].Cells[0].Paragraphs[0].Append("L.p.")
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black);
                t.Rows[0].Cells[1].Paragraphs[0].Append("Opis")
                .Font("Times New Roman")
                .FontSize(10)
                .Color(Color.Black);

                for (int r = 1; r < rows; r++)
                {
                    t.Rows[r].Cells[0].Paragraphs[0].Append(markerList[r - 1].Id.ToString())
                    .Font("Times New Roman")
                    .FontSize(10)
                    .Color(Color.Black);
                    t.Rows[r].Cells[1].Paragraphs[0].Append(markerList[r - 1].Description.ToString())
                    .Font("Times New Roman")
                    .FontSize(10)
                    .Color(Color.Black);
                }

                measurments.InsertTableAfterSelf(t);

                document.Save();
            }
            //}
            //catch
            //{
            //    MessageBox.Show("Nie można wydrukować dokumentu", "Błąd");
            //}
        }
Ejemplo n.º 14
0
        public static void SaveAllData(PictureBox pictureBox1, int complexity)
        {
            //Сохранение картинки
            System.Drawing.Rectangle r = pictureBox1.RectangleToScreen(pictureBox1.ClientRectangle);
            Bitmap   b = new Bitmap(r.Width, r.Height);
            Graphics g = Graphics.FromImage(b);

            g.CopyFromScreen(r.Location, new System.Drawing.Point(0, 0), r.Size);
            b.Save(path + "Image.jpg");


            //Сохранение в WORD
            string pathDocument = path + "DragonCurveInfo.docx";
            string pathImage    = path + "Image.jpg";
            DocX   document     = DocX.Create(pathDocument);

            // вставляем параграф и передаём текст
            document.InsertParagraph("Complexity: " + complexity).
            // устанавливаем шрифт
            Font("Calibri").
            // устанавливаем размер шрифта
            FontSize(15).
            // устанавливаем цвет
            Color(Color.Black).
            // делаем текст жирным
            Bold().
            // устанавливаем интервал между символами
            Spacing(5).
            // выравниваем текст по центру
            Alignment = Alignment.left;
            Painter painter = new Painter();

            document.InsertParagraph("X1: " + painter.x1.ToString() +
                                     "\nX2: " + painter.x2.ToString() +
                                     "\nY1: " + painter.y1.ToString() +
                                     "\nY2: " + painter.y2.ToString()).
            Font("Calibri").
            FontSize(15).
            Color(Color.Black).
            Bold().
            Spacing(5).
            Alignment = Alignment.left;

            Xceed.Words.NET.Image image = document.AddImage(pathImage);
            // создание параграфа
            Paragraph paragraph = document.InsertParagraph();

            // вставка изображения в параграф
            paragraph.AppendPicture(image.CreatePicture());
            // выравнивание параграфа по центру
            paragraph.Alignment = Alignment.center;
            // сохраняем документ
            document.Save();

            //Сохранение в EXCEL
            string pathExcel = path + "DragonCurveInfo.xls";

            // Создаём экземпляр нашего приложения
            Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();

            // Создаём экземпляр рабочий книги Excel
            Workbook workBook;
            // Создаём экземпляр листа Excel
            Worksheet workSheet;

            workBook  = excelApp.Workbooks.Add();
            workSheet = (Worksheet)workBook.Worksheets.get_Item(1);

            workSheet.Cells[1, 1] = "Complexity";
            workSheet.Cells[1, 2] = "X1";
            workSheet.Cells[1, 3] = "X2";
            workSheet.Cells[1, 4] = "Y1";
            workSheet.Cells[1, 5] = "Y2";
            workSheet.Cells[2, 1] = complexity.ToString();
            workSheet.Cells[2, 2] = painter.x1.ToString();
            workSheet.Cells[2, 3] = painter.x2.ToString();
            workSheet.Cells[2, 4] = painter.y1.ToString();
            workSheet.Cells[2, 5] = painter.y2.ToString();
            workSheet.Shapes.AddPicture(path + "Image.jpg",
                                        Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, 0, 30, 350, 250);
            //excelApp.Visible = true;
            //excelApp.UserControl = true;

            //excelApp.DefaultSaveFormat = Excel.XlFileFormat.xlExcel9795;
            excelApp.DefaultFilePath = pathExcel;
            excelApp.DisplayAlerts   = false;
            workBook.SaveAs(pathExcel, XlFileFormat.xlWorkbookNormal,
                            Type.Missing,
                            Type.Missing,
                            Type.Missing,
                            Type.Missing,
                            XlSaveAsAccessMode.xlExclusive,
                            Type.Missing,
                            Type.Missing,
                            Type.Missing,
                            Type.Missing,
                            Type.Missing);
            excelApp.Quit();
        }
Ejemplo n.º 15
0
        //public void CreateDocument()
        //{
        //    try
        //    {
        //        //Create an instance for word app
        //        Microsoft.Office.Interop.Word.Application winword = new Microsoft.Office.Interop.Word.Application();

        //        //Set animation status for word application
        //        winword.ShowAnimation = false;

        //        //Set status for word application is to be visible or not.
        //        winword.Visible = false;

        //        //Create a missing variable for missing value
        //        object missing = System.Reflection.Missing.Value;

        //        //Create a new document
        //        Microsoft.Office.Interop.Word.Document document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);

        //        //Add header into the document
        //        foreach (Microsoft.Office.Interop.Word.Section section in document.Sections)
        //        {
        //            //Get the header range and add the header details.
        //            Microsoft.Office.Interop.Word.Range headerRange = section.Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
        //            headerRange.Fields.Add(headerRange, Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage);
        //            headerRange.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
        //            headerRange.Font.ColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdBlue;
        //            headerRange.Font.Size = 10;
        //            headerRange.Text = "Header text goes here";
        //        }

        //        //Add the footers into the document
        //        foreach (Microsoft.Office.Interop.Word.Section wordSection in document.Sections)
        //        {
        //            //Get the footer range and add the footer details.
        //            Microsoft.Office.Interop.Word.Range footerRange = wordSection.Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
        //            footerRange.Font.ColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkRed;
        //            footerRange.Font.Size = 10;
        //            footerRange.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
        //            footerRange.Text = "Footer text goes here";
        //        }

        //        //adding text to document
        //        document.Content.SetRange(0, 0);
        //        document.Content.Text = "This is test document " + Environment.NewLine;

        //        //Add paragraph with Heading 1 style
        //        Microsoft.Office.Interop.Word.Paragraph para1 = document.Content.Paragraphs.Add(ref missing);
        //        object styleHeading1 = "Heading 1";
        //        para1.Range.set_Style(ref styleHeading1);
        //        para1.Range.Text = "Para 1 text";
        //        para1.Range.InsertParagraphAfter();

        //        //Add paragraph with Heading 2 style
        //        Microsoft.Office.Interop.Word.Paragraph para2 = document.Content.Paragraphs.Add(ref missing);
        //        object styleHeading2 = "Heading 2";
        //        para2.Range.set_Style(ref styleHeading2);
        //        para2.Range.Text = "Para 2 text";
        //        para2.Range.InsertParagraphAfter();

        //        //Create a 5X5 table and insert some dummy record
        //        Table firstTable = document.Tables.Add(para1.Range, 5, 5, ref missing, ref missing);

        //        firstTable.Borders.Enable = 1;
        //        foreach (Row row in firstTable.Rows)
        //        {
        //            foreach (Cell cell in row.Cells)
        //            {
        //                //Header row
        //                if (cell.RowIndex == 1)
        //                {
        //                    cell.Range.Text = "Column " + cell.ColumnIndex.ToString();
        //                    cell.Range.Font.Bold = 1;
        //                    //other format properties goes here
        //                    cell.Range.Font.Name = "verdana";
        //                    cell.Range.Font.Size = 10;
        //                    //cell.Range.Font.ColorIndex = WdColorIndex.wdGray25;
        //                    cell.Shading.BackgroundPatternColor = WdColor.wdColorGray25;
        //                    //Center alignment for the Header cells
        //                    cell.VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalCenter;
        //                    cell.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;

        //                }
        //                //Data row
        //                else
        //                {
        //                    cell.Range.Text = (cell.RowIndex - 2 + cell.ColumnIndex).ToString();
        //                }
        //            }
        //        }

        //        //Save the document
        //        object filename = @"c:\temp1.docx";
        //        document.SaveAs2(ref filename);
        //        document.Close(ref missing, ref missing, ref missing);
        //        document = null;
        //        winword.Quit(ref missing, ref missing, ref missing);
        //        winword = null;
        //        MessageBox.Show("Document created successfully !");
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.Message);
        //    }
        //}

        public void CreateDocument2()
        {
            #region one
            string fileName = "exempleWord.docx";
            var    doc      = DocX.Create(fileName);
            #endregion
            //doc.MarginLeft = 1;
            //doc.MarginRight = 1;
            //doc.MarginTop = 1;
            //doc.MarginBottom = 1/2;
            //#region two
            ////Formatting Title
            //string title = "Who is Virat Kohli?";

            ////Formatting Title
            //// like using this we can set font family, font size, position, font color etc

            //Formatting titleFormat = new Formatting();
            ////Specify font family
            //titleFormat.FontFamily = new Xceed.Words.NET.Font("Times new roman");
            ////Specify font size
            //titleFormat.Size = 20D;
            //titleFormat.Position = 40;
            //titleFormat.FontColor = Color.BlueViolet;
            //titleFormat.UnderlineColor = Color.Gray;
            //titleFormat.Italic = true;

            ////Text
            //string textParagraph = "Dear Friends, " + Environment.NewLine +
            //    "Virat Kohli - (born 5 November 1988) is an Indian international cricketer who currently captains the India national team. A right-handed batsman, often regarded as one of the best batsmen in the world. He plays for the Royal Challengers Bangalore in the Indian Premier League (IPL), & has been the team's captain since 2013.";

            ////Formatting Text Paragraph
            //Formatting textParagraphFormat = new Formatting();
            ////font family
            //textParagraphFormat.FontFamily = new Xceed.Words.NET.Font("Century Gothic");
            ////font size
            //textParagraphFormat.Size = 12D;
            ////Spaces between characters
            //textParagraphFormat.Spacing = 2;
            ////Insert title
            //Xceed.Words.NET.Paragraph paragraphTitle = doc.InsertParagraph(title, false, titleFormat);
            //paragraphTitle.Alignment = Alignment.center;
            ////Insert text
            //doc.InsertParagraph(textParagraph, false, textParagraphFormat);
            //#endregion



            #region TestObjective

            doc.InsertParagraph("Test Objective");
            //Create Table with 2 rows and 4 columns.
            Table t = doc.AddTable(2, 3);
            // t.Alignment = Alignment.center;
            //t.Design = TableDesign.ColorfulList;
            //t.Design = TableDesign.ColorfulGridAccent1;
            // Fill cells by adding text.
            // First row

            //Test Objective table
            string scenarioNumber = "15256";

            string title        = "TC_IT03_Member Portal_Submit Invalid data_EIV";
            string testOjective = "What: Verify that the system has the ability to display error messsage to the user when the user submits invalid data in the EIV form.Why: To ensure system can handle the invalid data submitted on the EIV form.";


            t.Rows[0].Cells[0].Paragraphs.First().Append("#");
            t.Rows[0].Cells[1].Paragraphs.First().Append("Title");
            t.Rows[0].Cells[2].Paragraphs.First().Append("Test Objective");

            // Second row details
            t.Rows[1].Cells[0].Paragraphs.First().Append(scenarioNumber);
            t.Rows[1].Cells[1].Paragraphs.First().Append(title);
            t.Rows[1].Cells[2].Paragraphs.First().Append(testOjective);
            doc.InsertTable(t);
            #endregion

            #region Steps To Follow
            doc.InsertParagraph("Steps to Follow");
            //Create Table with 2 rows and 4 columns.
            int   Rows          = 5;
            int   Column        = 3;
            Table stepsToFollow = doc.AddTable(Rows, Column);
            t.Alignment = Alignment.center;
            //t.Design = TableDesign.ColorfulList;
            //t.Design = TableDesign.ColorfulGridAccent1;
            // Fill cells by adding text.

            // First row

            //Test Objective table
            string steps = "1";

            string action         = "Verify that the preconditions are met";
            string expectedResult = "Member should have valid credentials to login to member portal.";

            stepsToFollow.Rows[0].Cells[0].Paragraphs.First().Append("Steps");
            stepsToFollow.Rows[0].Cells[1].Paragraphs.First().Append("Actions");
            t.Rows[0].Cells[2].Paragraphs.First().Append("Expected Result");

            // Second row details
            stepsToFollow.Rows[1].Cells[0].Paragraphs.First().Append(steps);
            stepsToFollow.Rows[1].Cells[1].Paragraphs.First().Append(action);
            stepsToFollow.Rows[1].Cells[2].Paragraphs.First().Append(expectedResult);
            doc.InsertTable(stepsToFollow);
            #endregion


            #region three
            //Create a picture
            Xceed.Words.NET.Image img = doc.AddImage(@"C:/Users/bryar.h.cole/Desktop/AutomationProvjects/NUnit.Tests1/Reports/HippSearch/images/ApplicationSearchPageSucess1.png");
            Picture p = img.CreatePicture();
            //Create a new paragraph
            Paragraph par = doc.InsertParagraph("HIPP Application Search Page");

            p.HeightInches = 3.8;
            p.WidthInches  = 8.5;
            par.AppendPicture(p);
            par.Alignment = Alignment.center;

            #endregion
            #region five
            // Hyperlink
            Xceed.Words.NET.Hyperlink url = doc.AddHyperlink("Ankpro home page", new Uri("http://www.ankpro.com"));
            Paragraph p1 = doc.InsertParagraph();
            p1.AppendLine("Please visit ").Bold().AppendHyperlink(url).Color(Color.Blue); // Hyperlink in blue color
            #endregion

            #region part of one
            doc.Save();
            Process.Start("WINWORD.EXE", fileName);
            #endregion
            MessageBox.Show("The Width of the image is " + p.Width + "\nThe Height is " + p.Height);
        }