コード例 #1
0
        private bool EnsureSaved()
        {
            if (AppState.Program == null ||
                AppState.Program.IsModified == false)
            {
                return(true);
            }

            string fileName = "Untitled";

            if (AppState.Program != null &&
                !string.IsNullOrEmpty(AppState.Program.FileName))
            {
                fileName = Path.GetFileName(AppState.Program.FileName);
            }

            SavePromptDialog dialog = new SavePromptDialog();

            dialog.Message = string.Format("Do you want to save {0}?", fileName);
            dialog.Owner   = this;
            SavePromptDialogResults result = dialog.ShowDialog();

            if (result == SavePromptDialogResults.Cancel)
            {
                return(false);
            }

            if (result == SavePromptDialogResults.Save)
            {
                if (!Save(true))
                {
                    return(false);
                }

                return(true);
            }

            // Unknown result...
            //
            return(true);
        }
コード例 #2
0
        private bool EnsureSaved()
        {
            if (AppState.Program == null
                || AppState.Program.IsModified == false)
            {
                return true;
            }

            string fileName = "Untitled";
            if (AppState.Program != null
                && !string.IsNullOrEmpty(AppState.Program.FileName))
            {
                fileName = Path.GetFileName(AppState.Program.FileName);
            }

            SavePromptDialog dialog = new SavePromptDialog();
            dialog.Message = string.Format("Do you want to save {0}?", fileName);
            dialog.Owner = this;
            SavePromptDialogResults result = dialog.ShowDialog();

            if (result == SavePromptDialogResults.Cancel)
            {
                return false;
            }

            if (result == SavePromptDialogResults.Save)
            {
                if (!Save(true))
                {
                    return false;
                }

                return true;
            }

            // Unknown result...
            //
            return true;
        }