コード例 #1
0
        /// <summary>
        /// Save the text to persistent storage.
        /// </summary>
        /// <returns>False if processing was canceled by the user.</returns>
        public async Task <bool> SavePendingChangesAsync()
        {
            if (IsModified)
            {
                var dialogResult = await DialogBox.ConfirmSaveChangesDialogAsync();

                if (dialogResult == MessageBox.Result.Cancel)
                {
                    return(false);
                }

                else if (dialogResult == MessageBox.Result.No)
                {
                    return(true);
                }

                else if (dialogResult == MessageBox.Result.Yes)
                {
                    var path = await SaveAsync();

                    if (path == null)
                    {
                        return(false);
                    }

                    Path     = path;
                    Filename = Path.Name;
                }

                return(true);
            }

            return(true);
        }