示例#1
0
 private void Save()
 {
     if (SaveFileService.ShowDialog(Application.Current.MainWindow) == true)
     {
         using (var fileStream = new FileStream(SaveFileService.FileName, FileMode.Create))
         {
             var modelSaver = new XmlModelSerializer(fileStream);
             modelSaver.Serialize(this.Document);
         }
     }
 }
示例#2
0
        private void SaveFile()
        {
            SaveFileService.AddExtension     = true;
            SaveFileService.DefaultExtension = ".rtf";
            SaveFileService.Filter           = "Documento de texto enriquecido (*.rtf)|*.rtf|Documento de texto (*.txt)|*.txt";
            SaveFileService.FilterIndex      = 1;
            SaveFileService.Title            = "Guardar archivo";

            if (SaveFileService.ShowDialog() == true && SaveFileService.FileName.Length > 0)
            {
                if (SaveFileService.FilterIndex == 1)
                {
                    RichEdit.Document.SaveFile(SaveFileService.FileName, TextOpenSaveOptions.RTF);
                }
                else
                {
                    RichEdit.Document.SaveFile(SaveFileService.FileName, TextOpenSaveOptions.PlainText);
                }
                MainWindow.Title = $"{Path.GetFileName(RichEdit.Document.Name)} - ";
            }
        }