コード例 #1
0
        public static void Display(Window owner)
        {
            var dialog = new RecentFilesDialog {
                Owner = owner
            };

            dialog.ShowDialog();
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
ファイル: Editor.xaml.cs プロジェクト: hotfix/Markdown-Edit
        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);
            }
        }
コード例 #4
0
 private void ExecuteRecentFiles(object sender, ExecutedRoutedEventArgs e) => RecentFilesDialog.Display(this);
コード例 #5
0
 public static void Display(Window owner)
 {
     var dialog = new RecentFilesDialog {Owner = owner};
     dialog.ShowDialog();
 }