private void SetupDocument() { if (_state.CurrentBook == null) { return; } var text = File.ReadAllText(_state.CurrentBook.FilePath); var bytes = Encoding.UTF8.GetBytes(text); text = Encoding.UTF8.GetString(bytes); var paragraph = new Paragraph(); paragraph.Inlines.Add(text); var document = new FlowDocument(paragraph); DocumentReader.SetDocument(document); DocumentReader.FlowDocument.PagePadding = _state.Margin; document.ColumnWidth = 2000; document.TextAlignment = TextAlignment.Center; if (_state.NightMode) { DocumentReader.SetNightMode(); } else { DocumentReader.SetDayMode(); } _mainWindowViewModel.NightMode = _state.NightMode; foreach (var mark in _state.CurrentBook.Marks) { DocumentReader.RestoreMark(mark, _state.NightMode); } }