Ejemplo n.º 1
0
 private void SaveTranslation(FileProperties fileProperties)
 {
     try {
         Base.Document.SaveTranslation(fileProperties);
     }
     catch (Exception exception) {
         FileSaveErrorDialog errorDialog = new FileSaveErrorDialog(fileProperties.Path, exception);
         errorDialog.Show();
         bool toSaveAgain = errorDialog.WaitForResponse();
         if (toSaveAgain)
         {
             TranslationSaveAs();
         }
     }
 }
Ejemplo n.º 2
0
	private void SaveTranslation (FileProperties fileProperties) {
		try {
			Base.Document.SaveTranslation(fileProperties);
		}
		catch (Exception exception) {
			FileSaveErrorDialog errorDialog = new FileSaveErrorDialog(fileProperties.Path, exception);
			errorDialog.Show();
			bool toSaveAgain = errorDialog.WaitForResponse();
	    	if (toSaveAgain)
	    		TranslationSaveAs();
		}
	}
Ejemplo n.º 3
0
        private async Task <bool> Save(ITextEditor textEditor, bool saveAs, bool ignoreUnmodifiedDocument = false, bool rebuildOpenRecentItems = true)
        {
            if (textEditor == null)
            {
                return(false);
            }

            if (ignoreUnmodifiedDocument && !textEditor.IsModified)
            {
                return(true);
            }

            StorageFile file = null;

            try
            {
                if (textEditor.EditingFile == null || saveAs)
                {
                    file = await OpenFileUsingFileSavePicker(textEditor);

                    if (file == null)
                    {
                        return(false);              // User cancelled
                    }
                }
                else
                {
                    file = textEditor.EditingFile;
                }

                bool promptSaveAs = false;
                try
                {
                    await SaveInternal(textEditor, file, rebuildOpenRecentItems);
                }
                catch (UnauthorizedAccessException) // Happens when the file we are saving is read-only
                {
                    promptSaveAs = true;
                }
                catch (FileNotFoundException) // Happens when the file not found or storage media is removed
                {
                    promptSaveAs = true;
                }

                if (promptSaveAs)
                {
                    file = await OpenFileUsingFileSavePicker(textEditor);

                    if (file == null)
                    {
                        return(false);              // User cancelled
                    }
                    await SaveInternal(textEditor, file, rebuildOpenRecentItems);

                    return(true);
                }

                return(true);
            }
            catch (Exception ex)
            {
                var fileSaveErrorDialog = new FileSaveErrorDialog((file == null) ? string.Empty : file.Path, ex.Message);
                await DialogManager.OpenDialogAsync(fileSaveErrorDialog, awaitPreviousDialog : false);

                if (!fileSaveErrorDialog.IsAborted)
                {
                    NotepadsCore.FocusOnSelectedTextEditor();
                }
                return(false);
            }
        }