Exemplo n.º 1
0
        public static bool SaveAs(Window window, DesktopDocument document)
        {
            string         filename = FileSupport.MakeValidFileName(document.Title);
            SaveFileDialog fd       = new SaveFileDialog
            {
                InitialDirectory = DesktopApp.Instance.Settings.DocumentFolder,
                FileName         = filename,
                Filter           = BaseDocument.GetFilterString(true, document.DocType),
                FilterIndex      = 0,
            };

            if (fd.ShowDialog(window) == true)
            {
                string path = fd.FileName;
                if (File.Exists(path) && path != document.Path)
                {
                    if (MessageBox.Show(window, "File '" + path + "' exists.  Overwrite?", "Save Document",
                                        MessageBoxButton.OKCancel, MessageBoxImage.Exclamation) == MessageBoxResult.OK)
                    {
                        return(document.Save(path, true));
                    }

                    return(false);
                }
                else if (path == document.Path)
                {
                    return(document.Save());
                }
                else
                {
                    return(document.Save(path, false));
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        public static bool Save(Window window, DesktopDocument document)
        {
            if (document != null)
            {
                if (document.IsDirty)
                {
                    if (String.IsNullOrEmpty(document.Path))
                    {
                        return(SaveAs(window, document));
                    }

                    return(document.Save());
                }

                return(true);
            }

            return(false);
        }