Ejemplo n.º 1
0
        public static DocumentAdv LoadDocumentAdv(List <TextPage> pages)
        {
            var        documentAdv = new DocumentAdv();
            SectionAdv sectionAdv  = new SectionAdv();

            documentAdv.Sections.Add(sectionAdv);

            foreach (var textPage in pages)
            {
                foreach (var paragraph in textPage.Paragraphs)
                {
                    var paragraphAdv = new ParagraphAdv();
                    sectionAdv.Blocks.Add(paragraphAdv);

                    foreach (var line in paragraph.Lines)
                    {
                        foreach (var word in line.Words)
                        {
                            SpanAdv spanAdv = new SpanAdv {
                                Text = word.Word + " "
                            };
                            if (word.Bold)
                            {
                                spanAdv.FontWeight = FontWeights.Bold;
                            }
                            paragraphAdv.Inlines.Add(spanAdv);
                        }
                    }
                }
            }
            return(documentAdv);
        }
Ejemplo n.º 2
0
        public static DocumentAdv ParsowanieHtml(ObservableCollection <DictionaryPasswordElement> dictionaryPasswordElements)
        {
            var documentAdv = new DocumentAdv();
            var sectionAdv  = new SectionAdv();

            documentAdv.Sections.Add(sectionAdv);

            var paragraphPassword = new ParagraphAdv();

            sectionAdv.Blocks.Add(paragraphPassword);

            var paragraphDescryption = new ParagraphAdv();

            sectionAdv.Blocks.Add(paragraphDescryption);

            foreach (var element in dictionaryPasswordElements)
            {
                if (element.Description.Contains("has³o"))
                {
                    var spanAdv = new SpanAdv
                    {
                        Text       = element.Word + " ",
                        Foreground = Color.FromRgb(0, 128, 0),
                        FontSize   = 24,
                    };

                    paragraphPassword.Inlines.Add(spanAdv);
                }
                else if (element.Word.Contains("I,") || element.Word.Contains("II,") || element.Word.Contains("III,") || element.Word.Contains("IV,") ||
                         element.Word.Contains("I ") || element.Word.Contains("II ") || element.Word.Contains("III ") || element.Word.Contains("IV "))
                {
                    var hyperlinkAdv = new HyperlinkAdv
                    {
                        Text          = element.Word + " ",
                        NavigationUrl = @"tabele/meski_" + element.Word.Trim(',') + ".jpg",
                        Foreground    = Colors.DarkBlue
                    };

                    paragraphPassword.Inlines.Add(hyperlinkAdv);
                }
                else if (element.Description.Contains("definicja"))
                {
                    //var hyperlinkAdv = new HyperlinkAdv
                    //{
                    //    Text = element.Word + " \n",
                    //    NavigationUrl = "javascript:alert('" + element.Description + "')",
                    //    Foreground = Colors.Black
                    //};
                    //paragraphDescryption.Inlines.Add(shyperlinkAdv);
                    var spanAdv = new SpanAdv
                    {
                        Text = element.Word + " \n"
                    };
                    paragraphDescryption.Inlines.Add(spanAdv);
                }
                else if (element.Description.Contains("cytat"))
                {
                    var paragraphCitation = new ParagraphAdv
                    {
                        ListType = ListType.Bulleted
                    };
                    sectionAdv.Blocks.Add(paragraphCitation);

                    //var hyperlinkAdv = new HyperlinkAdv
                    //{
                    //    Text = element.Word + " \n",
                    //    NavigationUrl = "javascript:alert('" + element.Description + "')",
                    //    Foreground = Colors.Black
                    //};
                    //paragraphCitation.Inlines.Add(hyperlinkAdv);
                    var spanAdv = new SpanAdv
                    {
                        Text = element.Word + " \n"
                    };
                    paragraphCitation.Inlines.Add(spanAdv);
                }
                else if (element.Description.Contains("wyjaœnienie etymologiczne wyrazu"))
                {
                    var paragraphLatin = new ParagraphAdv();
                    sectionAdv.Blocks.Add(paragraphLatin);
                    //var hyperlinkAdv = new HyperlinkAdv
                    //{
                    //    Text = element.Word + " ",
                    //    NavigationUrl = "javascript:alert('" + element.Description + "')",
                    //    Foreground = Colors.Black
                    //};
                    //paragraphLatin.Inlines.Add(hyperlinkAdv);
                    var spanAdv = new SpanAdv
                    {
                        Text = element.Word + " "
                    };
                    paragraphLatin.Inlines.Add(spanAdv);
                }
                else
                {
                    var spanAdv = new SpanAdv
                    {
                        Text = element.Word + " ",
                    };

                    paragraphPassword.Inlines.Add(spanAdv);
                }
            }

            return(documentAdv);
        }
Ejemplo n.º 3
0
        public static QuoteFormat Create(Quote quote)
        {
            var content = CreateSpan(quote.Content);

            var paragraph = new ParagraphAdv
            {
                ParagraphFormat = new ParagraphFormat
                {
                    StyleName     = Constants.NormalStyleName,
                    LeftIndent    = 25d,
                    BeforeSpacing = 15d,
                    AfterSpacing  = 15d
                }
            };

            paragraph.Inlines.Add(content);

            var cite = CreateSpan(quote.Cite);

            var citeParagraph = new ParagraphAdv
            {
                ParagraphFormat = new ParagraphFormat
                {
                    StyleName     = Constants.NormalStyleName,
                    BeforeSpacing = 15d,
                    AfterSpacing  = 15d,
                    TextAlignment = TextAlignment.Right
                }
            };

            citeParagraph.Inlines.Add(cite);

            if (!(Application.Current.MainWindow is MainWindow window))
            {
                return(null);
            }

            var gray3     = window.FindResource(Constants.MahAppsColorsGray3);
            var gray9     = window.FindResource(Constants.MahAppsColorsGray9);
            var tableCell = new TableCellAdv
            {
                CellFormat = new CellFormat
                {
                    Borders = new Borders
                    {
                        Left = new Border()
                        {
                            LineStyle = LineStyle.Single,
                            LineWidth = 5d,
                            Color     = (System.Windows.Media.Color)gray3
                        }
                    },
                    CellWidth = 640,
                    Shading   = new Shading
                    {
                        BackgroundColor = (System.Windows.Media.Color)gray9
                    }
                }
            };

            tableCell.Blocks.Add(paragraph);
            tableCell.Blocks.Add(citeParagraph);

            var tableRow = new TableRowAdv();

            tableRow.Cells.Add(tableCell);

            var table = new QuoteFormat
            {
                Cite = quote.Cite
            };

            table.Rows.Add(tableRow);

            return(table);
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //Creating new table
            TableAdv table = new TableAdv();

            table.BorderThickness = 0;
            //Creating a row
            TableRowAdv row = new TableRowAdv();
            //Creating cell
            TableCellAdv cell = new TableCellAdv();

            #region Adding the header text
            ParagraphAdv paragraph = new ParagraphAdv();
            paragraph.BeforeSpacing = 5;
            SpanAdv span = new SpanAdv();
            span.FontWeight = FontWeights.Bold;
            span.FontSize   = 10;
            span.Text       = "Contact Id";
            paragraph.Inlines.Add(span);
            cell.Blocks.Add(paragraph);
            row.Cells.Add(cell);

            cell      = new TableCellAdv();
            paragraph = new ParagraphAdv();
            paragraph.BeforeSpacing = 5;
            span            = new SpanAdv();
            span.FontWeight = FontWeights.Bold;
            span.FontSize   = 10;
            span.Text       = "Full Name";
            paragraph.Inlines.Add(span);
            cell.Blocks.Add(paragraph);
            row.Cells.Add(cell);

            cell      = new TableCellAdv();
            paragraph = new ParagraphAdv();
            paragraph.BeforeSpacing = 5;
            span            = new SpanAdv();
            span.FontWeight = FontWeights.Bold;
            span.FontSize   = 10;
            span.Text       = "Age";
            paragraph.Inlines.Add(span);
            cell.Blocks.Add(paragraph);
            row.Cells.Add(cell);

            cell      = new TableCellAdv();
            paragraph = new ParagraphAdv();
            paragraph.BeforeSpacing = 5;
            span            = new SpanAdv();
            span.FontWeight = FontWeights.Bold;
            span.FontSize   = 10;
            span.Text       = "Email Address";
            paragraph.Inlines.Add(span);
            cell.Blocks.Add(paragraph);
            row.Cells.Add(cell);

            cell      = new TableCellAdv();
            paragraph = new ParagraphAdv();
            paragraph.BeforeSpacing = 5;
            span            = new SpanAdv();
            span.FontWeight = FontWeights.Bold;
            span.FontSize   = 10;
            span.Text       = "Phone No";
            paragraph.Inlines.Add(span);
            cell.Blocks.Add(paragraph);
            row.Cells.Add(cell);

            cell      = new TableCellAdv();
            paragraph = new ParagraphAdv();
            paragraph.BeforeSpacing = 5;
            span            = new SpanAdv();
            span.FontWeight = FontWeights.Bold;
            span.FontSize   = 10;
            span.Text       = "Modified Date";
            paragraph.Inlines.Add(span);
            cell.Blocks.Add(paragraph);
            row.Cells.Add(cell);

            table.Rows.Add(row);
            #endregion

            //Reading each rows from the fetched result
            foreach (HiveRecord rows in result)
            {
                //Creating new row
                row = new TableRowAdv();

                //Reading each data from the rows
                foreach (Object fields in rows)
                {
                    //Creating a Cell
                    cell = new TableCellAdv();

                    //Creating a paragraph
                    paragraph = new ParagraphAdv();
                    paragraph.BeforeSpacing = 5;
                    string records = fields.ToString();
                    span = new SpanAdv()
                    {
                        Text = records
                    };
                    span.FontSize = 8;
                    paragraph.Inlines.Add(span);

                    //Adding field value to cell
                    cell.Blocks.Add(paragraph);

                    //Adding the cell to row
                    row.Cells.Add(cell);
                }

                //Adding the row to table
                table.Rows.Add(row);
            }

            //Adding  table to section
            richTextBox1.Document.Sections[0].Blocks.Add(table);
            richTextBox1.UpdateEditorLayout();

            //Adding Scrollbar to RichTextEditor
            richTextBox1.VerticalScrollBarVisibility   = true;
            richTextBox1.HorizontalScrollBarVisibility = true;
        }