Ejemplo n.º 1
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.º 2
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;
        }