Пример #1
0
        private void buttonSaveMergedDocument_Click(object sender, RoutedEventArgs e)
        {
            TextRange textRange = new TextRange(richTextBoxMerged.Document.ContentStart, richTextBoxMerged.Document.ContentEnd);

            String[]     pureContent    = textRange.Text.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
            FlowDocument mergedDocument = new FlowDocument();

            foreach (String s in pureContent)
            {
                Paragraph p = new Paragraph(new Run(s));
                mergedDocument.Blocks.Add(p);
            }

            controller.SaveMergedDocument(mergedDocument);
            richTextBox.Document = mergedDocument;

            richTextBox.Width            = double.NaN;
            richTextBoxMerged.Visibility = Visibility.Hidden;
            Grid.SetRow(richTextBox, 0);
            Grid.SetRow(richTextBoxMerged, 0);
            richTextBox.IsReadOnly = false;

            labelMerge.Visibility  = Visibility.Hidden;
            labelServer.Visibility = Visibility.Hidden;

            buttonSaveDocument.Click  -= buttonSaveMergedDocument_Click;
            buttonSaveDocument.Click  += new RoutedEventHandler(buttonSaveDocument_Click);
            buttonSaveDocument.Content = "Save document";
        }