public void PropertyChangedEventTest() { var viewModel = Container.GetExportedValue<RichTextViewModel>(); RichTextDocumentType documentType = new RichTextDocumentType(); RichTextDocument document = new RichTextDocument(documentType); viewModel.Document = document; Assert.AreEqual(document, viewModel.Document); AssertHelper.PropertyChangedEvent(viewModel, x => x.IsBold, () => viewModel.IsBold = true); Assert.IsTrue(viewModel.IsBold); AssertHelper.PropertyChangedEvent(viewModel, x => x.IsItalic, () => viewModel.IsItalic = true); Assert.IsTrue(viewModel.IsItalic); AssertHelper.PropertyChangedEvent(viewModel, x => x.IsUnderline, () => viewModel.IsUnderline = true); Assert.IsTrue(viewModel.IsUnderline); AssertHelper.PropertyChangedEvent(viewModel, x => x.IsNumberedList, () => viewModel.IsNumberedList = true); Assert.IsTrue(viewModel.IsNumberedList); AssertHelper.PropertyChangedEvent(viewModel, x => x.IsBulletList, () => viewModel.IsBulletList = true); Assert.IsTrue(viewModel.IsBulletList); AssertHelper.PropertyChangedEvent(viewModel, x => x.IsSpellCheckEnabled, () => viewModel.IsSpellCheckEnabled = true); Assert.IsTrue(viewModel.IsSpellCheckEnabled); }
protected override IDocument NewCore() { RichTextDocument document = new RichTextDocument(this); document.FileName = string.Format(CultureInfo.CurrentCulture, Resources.DocumentFileName, ++documentCount, FileExtension); return document; }
protected override IDocument NewCore() { RichTextDocument document = new RichTextDocument(this); document.FileName = string.Format(CultureInfo.CurrentCulture, Resources.DocumentFileName, ++documentCount, FileExtension); return(document); }
protected override IDocument OpenCore(string fileName) { FlowDocument flowDocument = new FlowDocument(); TextRange range = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd); using (FileStream stream = new FileStream(fileName, FileMode.Open)) { range.Load(stream, DataFormats.Rtf); } RichTextDocument document = new RichTextDocument(this, flowDocument); documentCount++; return document; }
protected override IDocument OpenCore(string fileName) { var flowDocument = new FlowDocument(); var range = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd); using (var stream = new FileStream(fileName, FileMode.Open)) { range.Load(stream, DataFormats.Rtf); } var document = new RichTextDocument(this, flowDocument); documentCount++; return(document); }
protected override void SaveCore(IDocument document, string fileName) { // We have to clone the FlowDocument before we use different pagination settings for the export. RichTextDocument richTextDocument = (RichTextDocument)document; FlowDocument clone = richTextDocument.CloneContent(); clone.ColumnWidth = double.PositiveInfinity; using (Package package = Package.Open(fileName, FileMode.Create)) using (XpsDocument xpsDocument = new XpsDocument(package, CompressionOption.Maximum)) { XpsSerializationManager serializer = new XpsSerializationManager(new XpsPackagingPolicy(xpsDocument), false); DocumentPaginator paginator = ((IDocumentPaginatorSource)clone).DocumentPaginator; serializer.SaveAsXaml(paginator); } }