예제 #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
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellViewModel"/> class.
        /// </summary>
        public ShellViewModel()
        {
            this.Model = new AutoSquirrelModel();

            this.UserPreference = PathFolderHelper.LoadUserPreference();

            var last = this.UserPreference.LastOpenedProject.LastOrDefault();

            if (!string.IsNullOrEmpty(last) && File.Exists(last))
            {
                OpenProject(last);
            }
        }
예제 #3
0
        private void AddLastProject(string filePath)
        {
            var existing = UserPreference.LastOpenedProject.Where(p => p.ToLower() == filePath.ToLower()).ToList();

            foreach (var fp in existing)
            {
                UserPreference.LastOpenedProject.Remove(fp);
            }

            UserPreference.LastOpenedProject.Add(filePath);

            PathFolderHelper.SavePreference(UserPreference);
        }
예제 #4
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;
            }
        }