Пример #1
0
        public static void OnInsertTable(object sender, ExecutedRoutedEventArgs e)
        {
            RichTextEditor control     = (RichTextEditor)sender;
            RichTextBox    richTextBox = control.RichTextBox;

            if (!richTextBox.Selection.IsEmpty)
            {
                richTextBox.Selection.Text = String.Empty;
            }

            TextPointer insertionPosition = richTextBox.Selection.Start;
            Paragraph   paragraph         = insertionPosition.Paragraph;

            // Split current paragraph at insertion position
            //   insertionPosition = insertionPosition.InsertParagraphBreak();
            //   paragraph = insertionPosition.Paragraph;

            TablePropertiesDialog tablePropertiesDialog = new TablePropertiesDialog(null);

            tablePropertiesDialog.ShowDialog();
            if (true == tablePropertiesDialog.DialogResult)
            {
                //Table table = Helper.BuildTable(/*rows*/2, /*columns*/5);
                Table table = Helper.BuildTable(tablePropertiesDialog.Rows,
                                                tablePropertiesDialog.Columns,
                                                tablePropertiesDialog.TableBorderBrush,
                                                tablePropertiesDialog.TableBorderThickness,
                                                tablePropertiesDialog.TableCellWidth,
                                                tablePropertiesDialog.TableType);
                //table.LineHeight = tablePropertiesDialog.CellWidth;
                //table.Margin = new Thickness(30,30,30,30);
                paragraph.SiblingBlocks.InsertBefore(paragraph, table);
            }
        }
Пример #2
0
        public static void OnEditTableProperties(object sender, ExecutedRoutedEventArgs e)
        {
            RichTextEditor control     = (RichTextEditor)sender;
            RichTextBox    richTextBox = control.RichTextBox;

            TextPointer textPosition = richTextBox.Selection.Start;

            Table table = Helper.GetTableAncestor(textPosition);

            if (null != table)
            {
                TablePropertiesDialog tablePropertiesDialog = new TablePropertiesDialog(table);
                tablePropertiesDialog.ShowDialog();
                if (true == tablePropertiesDialog.DialogResult)
                {
                    Helper.UpdateTable(table,
                                       tablePropertiesDialog.Rows,
                                       tablePropertiesDialog.Columns,
                                       tablePropertiesDialog.TableBorderBrush,
                                       tablePropertiesDialog.TableBorderThickness,
                                       tablePropertiesDialog.TableCellWidth,
                                       tablePropertiesDialog.TableType);
                }
            }
        }