public static void Display(Window owner) { var dialog = new RecentFilesDialog { Owner = owner }; dialog.ShowDialog(); }
private bool Save() { try { File.WriteAllText(FileName, Text); RecentFilesDialog.UpdateRecentFiles(FileName, EditBox.SelectionStart); Settings.Default.LastOpenFile = FileName.AddOffsetToFileName(EditBox.SelectionStart); IsModified = false; return(true); } catch (Exception e) { MessageBox.Show(e.Message, App.Title, MessageBoxButton.OK, MessageBoxImage.Error); return(false); } }
public bool LoadFile(string file) { try { if (string.IsNullOrWhiteSpace(file)) { NewFile(); return(true); } var parts = file.Split(new[] { '|' }, 2); var filename = parts[0] ?? ""; var offset = ConvertToOffset(parts.Length == 2 ? parts[1] : "0"); var isWordDoc = Path.GetExtension(filename).Equals(".docx", StringComparison.OrdinalIgnoreCase); if (isWordDoc) { NewFile(); EditBox.Text = ConvertText.FromMicrosoftWord(filename); return(true); } EditBox.Text = File.ReadAllText(filename); if (App.UserSettings.EditorOpenLastCursorPosition) { EditBox.ScrollToLine(EditBox.Document.GetLineByOffset(offset)?.LineNumber ?? 0); EditBox.SelectionStart = offset; } else { EditBox.ScrollToHome(); } Settings.Default.LastOpenFile = file; RecentFilesDialog.UpdateRecentFiles(filename, offset); IsModified = false; FileName = filename; return(true); } catch (Exception e) { MessageBox.Show(e.Message, App.Title, MessageBoxButton.OK, MessageBoxImage.Error); return(false); } }
private void ExecuteRecentFiles(object sender, ExecutedRoutedEventArgs e) => RecentFilesDialog.Display(this);
public static void Display(Window owner) { var dialog = new RecentFilesDialog {Owner = owner}; dialog.ShowDialog(); }