Ejemplo n.º 1
0
        public Word.Paragraph GenerateParagraph(string val, bool bold = false, string sz = "12", string s = "style22", string f = "Courier New", Word.JustificationValues align = Word.JustificationValues.Left)
        {
            Word.ParagraphStyleId pstyle = new Word.ParagraphStyleId {
                Val = s
            };
            Word.Justification jut = new Word.Justification {
                Val = new EnumValue <Word.JustificationValues>(align)
            };
            Word.ParagraphProperties pprop = new Word.ParagraphProperties(pstyle, jut);

            Word.RunProperties rprop = new Word.RunProperties(
                new Word.RunFonts {
                Ascii = f, ComplexScript = f, HighAnsi = f
            },
                new Word.Bold {
                Val = new OnOffValue(bold)
            },
                new Word.BoldComplexScript {
                Val = new OnOffValue(bold)
            },
                new Word.FontSize {
                Val = sz
            });

            Word.Text text = new Word.Text(val);
            Word.Run  run  = new Word.Run(rprop, text);

            return(new Word.Paragraph(pprop, run));
        }
Ejemplo n.º 2
0
        public Models.Parts.Paragraphs.Style.Justification ParseJustification(DocumentFormat.OpenXml.Wordprocessing.Justification justification)
        {
            if (justification == null || justification.Val == null || !justification.Val.HasValue)
            {
                return(Models.Parts.Paragraphs.Style.Justification.Justified);
            }

            switch (justification.Val.Value)
            {
            case JustificationValues.Both:
                return(Models.Parts.Paragraphs.Style.Justification.Justified);

            case JustificationValues.Center:
                return(Models.Parts.Paragraphs.Style.Justification.Center);

            case JustificationValues.Left:
                return(Models.Parts.Paragraphs.Style.Justification.Left);

            case JustificationValues.Right:
                return(Models.Parts.Paragraphs.Style.Justification.Right);

            default:
                return(Models.Parts.Paragraphs.Style.Justification.Other);
            }
        }
Ejemplo n.º 3
0
        public Paragraph(uint leftIntendation = 0, uint rightIntendation = 0, JUSTIFICATION justification = JUSTIFICATION.NONE)
        {
            _Paragraph = new Wp.Paragraph()
            {
                RsidParagraphMarkRevision = "00297913",
                RsidParagraphAddition     = "00297913",
                RsidParagraphProperties   = "00297913",
                RsidRunAdditionDefault    = "0074062A",
                ParagraphId = "29551F12",
                TextId      = "11181D94"
            };

            Wp.ParagraphProperties _pp = new Wp.ParagraphProperties();
            Wp.Indentation         _i  = new Wp.Indentation()
            {
                Left  = leftIntendation.ToString(),
                Right = rightIntendation.ToString()
            };
            _pp.Append(_i);

            if (justification.Equals(JUSTIFICATION.NONE) is false)
            {
                Wp.Justification _j;
                if (justification.Equals(JUSTIFICATION.CENTER) is true)
                {
                    _j = new Wp.Justification()
                    {
                        Val = Wp.JustificationValues.Center
                    }
                }
                ;
                else if (justification.Equals(JUSTIFICATION.LEFT) is true)
                {
                    _j = new Wp.Justification()
                    {
                        Val = Wp.JustificationValues.Left
                    }
                }
                ;
                else
                {
                    _j = new Wp.Justification()
                    {
                        Val = Wp.JustificationValues.Right
                    }
                };

                _pp.Append(_j);
            }

            _Paragraph.Append(_pp);
        }
Ejemplo n.º 4
0
        public static LineAlignment GetLinesAlignment(
            this Word.Justification justification,
            LineAlignment ifNull)
        {
            if (justification == null)
            {
                return(ifNull);
            }

            return(justification.Val.Value switch
            {
                Word.JustificationValues.Right => LineAlignment.Right,
                Word.JustificationValues.Center => LineAlignment.Center,
                Word.JustificationValues.Both => LineAlignment.Justify,
                _ => LineAlignment.Left,
            });
Ejemplo n.º 5
0
        public static Wordprocessing.TableCell AddCell(this Wordprocessing.TableRow tableRow, string value)
        {
            Wordprocessing.TableCell tableCell = new Wordprocessing.TableCell();
            Wordprocessing.Paragraph par = new Wordprocessing.Paragraph();
            Wordprocessing.ParagraphProperties parprop = new Wordprocessing.ParagraphProperties();
            Wordprocessing.Justification justification1 = new Wordprocessing.Justification() { Val = Wordprocessing.JustificationValues.Center };
            Wordprocessing.SpacingBetweenLines spacingBetweenLines2 = new Wordprocessing.SpacingBetweenLines() { After = "0"};
            parprop.Append(spacingBetweenLines2);
            parprop.Append(justification1);
            par.Append(parprop);

            Wordprocessing.Run run = new Wordprocessing.Run() ;
            Wordprocessing.Text text = new Wordprocessing.Text(value);
            run.Append(text);
            par.Append(run);
            tableCell.Append(par);
            tableRow.Append(tableCell);

            return tableCell;
        }
Ejemplo n.º 6
0
        private Paragraph ExamTitleHeader()
        {
            var paragraphWithExamTitle = new Paragraph();

            var run = new Run();
            var paragraphProperties = new ParagraphProperties();
            var justification       = new Justification()
            {
                Val = JustificationValues.Center
            };

            paragraphProperties.Append(justification);

            run.Append(new Text($"Exam: {exam.Subject}"));
            run.Append(new Break());
            run.Append(new Text($"Teacher: {exam.Teacher}"));

            paragraphWithExamTitle.Append(paragraphProperties);
            paragraphWithExamTitle.Append(run);

            return(paragraphWithExamTitle);
        }
Ejemplo n.º 7
0
        public Wordprocessing.Body insertinform()
        {
            Wordprocessing.Body body = new Wordprocessing.Body();
            //Параграф1
            Wordprocessing.Paragraph paragraph1 = new Wordprocessing.Paragraph();
            Wordprocessing.ParagraphProperties paragraphProperties1 = new Wordprocessing.ParagraphProperties();
            Wordprocessing.SpacingBetweenLines spacingBetweenLines1 = new Wordprocessing.SpacingBetweenLines() { After = "0" };
            Wordprocessing.Justification justification1 = new Wordprocessing.Justification() { Val = Wordprocessing.JustificationValues.Center };
            paragraphProperties1.Append(spacingBetweenLines1);
            paragraphProperties1.Append(justification1);
            Wordprocessing.Run run1 = new Wordprocessing.Run();
            Wordprocessing.RunProperties runProperties1 = new Wordprocessing.RunProperties();
            Wordprocessing.RunFonts runFonts2 = new Wordprocessing.RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
            Wordprocessing.Bold bold2 = new Wordprocessing.Bold();
            Wordprocessing.FontSize fontSize2 = new Wordprocessing.FontSize() { Val = "24" };
            runProperties1.Append(runFonts2);
            runProperties1.Append(bold2);
            runProperties1.Append(fontSize2);
            Wordprocessing.Text text1 = new Wordprocessing.Text();
            text1.Text = "ФГБОУВПО \"ПЕРМСКИЙ ГОСУДАРСТВЕННЫЙ НАЦИОНАЛЬНЫЙ ИССЛЕДОВАТЕЛЬСКИЙ УНИВЕРСИТЕТ\"";
            run1.Append(runProperties1);
            run1.Append(text1);
            paragraph1.Append(paragraphProperties1);
            paragraph1.Append(run1);

            //Параграф2
            Wordprocessing.Paragraph paragraph2 = new Wordprocessing.Paragraph();

            Wordprocessing.ParagraphProperties paragraphProperties2 = new Wordprocessing.ParagraphProperties();
            Wordprocessing.SpacingBetweenLines spacingBetweenLines2 = new Wordprocessing.SpacingBetweenLines() { After = "0" };
            Wordprocessing.Justification justification2 = new Wordprocessing.Justification() { Val = Wordprocessing.JustificationValues.Center };
            paragraphProperties2.Append(spacingBetweenLines2);
            paragraphProperties2.Append(justification2);
            Wordprocessing.Run run2 = new Wordprocessing.Run();

            Wordprocessing.RunProperties runProperties2 = new Wordprocessing.RunProperties();
            Wordprocessing.RunFonts runFonts4 = new Wordprocessing.RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
            Wordprocessing.FontSize fontSize4 = new Wordprocessing.FontSize() { Val = "24" };

            runProperties2.Append(runFonts4);
            runProperties2.Append(fontSize4);
            Wordprocessing.Text text2 = new Wordprocessing.Text();
            text2.Text = "Механико-математический факультет ";

            run2.Append(runProperties2);
            run2.Append(text2);

            Wordprocessing.Run run3 = new Wordprocessing.Run();

            Wordprocessing.RunProperties runProperties3 = new Wordprocessing.RunProperties();
            Wordprocessing.RunFonts runFonts5 = new Wordprocessing.RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
            Wordprocessing.FontSize fontSize5 = new Wordprocessing.FontSize() { Val = "24" };
            runProperties3.Append(runFonts5);
            runProperties3.Append(fontSize5);
            Wordprocessing.Break break1 = new Wordprocessing.Break();
            Wordprocessing.Text text3 = new Wordprocessing.Text();
            text3.Text = "очная форма обучения";

            run3.Append(runProperties3);
            run3.Append(break1);
            run3.Append(text3);

            paragraph2.Append(paragraphProperties2);
            paragraph2.Append(run2);
            paragraph2.Append(run3);

            //Параграф2
            Wordprocessing.Paragraph paragraph3 = new Wordprocessing.Paragraph() { RsidParagraphAddition = "004D49E1", RsidParagraphProperties = "004D49E1", RsidRunAdditionDefault = "004D49E1" };

            Wordprocessing.ParagraphProperties paragraphProperties3 = new Wordprocessing.ParagraphProperties();
            Wordprocessing.SpacingBetweenLines spacingBetweenLines3 = new Wordprocessing.SpacingBetweenLines() { After = "0" };
            Wordprocessing.Justification justification3 = new Wordprocessing.Justification() { Val = Wordprocessing.JustificationValues.Center };
            paragraphProperties3.Append(spacingBetweenLines3);
            paragraphProperties3.Append(justification3);
            Wordprocessing.Run run4 = new Wordprocessing.Run();

            Wordprocessing.RunProperties runProperties4 = new Wordprocessing.RunProperties();
            Wordprocessing.RunFonts runFonts7 = new Wordprocessing.RunFonts() { Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
            Wordprocessing.Bold bold4 = new Wordprocessing.Bold();

            runProperties4.Append(runFonts7);
            runProperties4.Append(bold4);
            Wordprocessing.Text text4 = new Wordprocessing.Text();
            text4.Text = "ЭКЗАМЕНАЦИОННАЯ ВЕДОМОСТЬ";
            run4.Append(runProperties4);
            run4.Append(text4);

            Wordprocessing.Run run5 = new Wordprocessing.Run();
            Wordprocessing.Break break2 = new Wordprocessing.Break();
            run5.Append(break2);

            paragraph3.Append(paragraphProperties3);
            paragraph3.Append(run4);
            paragraph3.Append(run5);

            body.Append(paragraph1);
            body.Append(paragraph2);
            body.Append(paragraph3);
            return body;
        }