Пример #1
0
        public void OpenProject()
        {
            try
            {
                var ofd = new System.Windows.Forms.OpenFileDialog
                {
                    AddExtension = true,
                    DefaultExt   = PathFolderHelper.ProjectFileExtension,
                    Filter       = PathFolderHelper.FileDialogName
                };

                var iniDir = PathFolderHelper.GetMyDirectory(MyDirectory.Project);
                if (!string.IsNullOrWhiteSpace(iniDir))
                {
                    ofd.InitialDirectory = iniDir;
                }

                var o = ofd.ShowDialog();

                if (o != System.Windows.Forms.DialogResult.OK || !File.Exists(ofd.FileName))
                {
                    return;
                }

                OpenProject(ofd.FileName);

                //Save last folder path
            }
            catch (Exception exception)
            {
                MessageBox.Show("Loading File Error, file no more supported", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error, MessageBoxResult.None);
            }
        }
Пример #2
0
        public void SaveAs()
        {
            var previousFilePath = FilePath;

            try
            {
                var saveFileDialog = new System.Windows.Forms.SaveFileDialog
                {
                    DefaultExt   = PathFolderHelper.ProjectFileExtension,
                    AddExtension = true,
                    Filter       = PathFolderHelper.FileDialogName,
                };

                // todo : usare cartella di salvataggio.
                var iniDir = PathFolderHelper.GetMyDirectory(MyDirectory.Project);

                if (!string.IsNullOrWhiteSpace(iniDir))
                {
                    saveFileDialog.InitialDirectory = iniDir;
                }

                if (saveFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                //Singleton.Preference.DefaultProjectDir = Path.GetDirectoryName(saveFileDialog.FileName);

                //Singleton.SavePreference();

                FilePath = saveFileDialog.FileName;

                Save();

                //return true;
            }
            catch (Exception)
            {
                MessageBox.Show("Error on saving");

                FilePath = previousFilePath;

                //return false;
            }
        }