Beispiel #1
0
        private void SaveProjectAs()
        {
            if (saveFileDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            string newName = saveFileDialog.FileName;

            string oldProjectDataPath = MyMemoryBlockSerializer.GetTempStorage(Project);
            string newProjectDataPath = MyMemoryBlockSerializer.GetTempStorage(MyProject.MakeNameFromPath(newName));

            if (newProjectDataPath != oldProjectDataPath)
            {
                CopyDirectory(oldProjectDataPath, newProjectDataPath);
            }
            else
            {
                MyLog.WARNING.WriteLine("Projects with the same filename share the same temporal folder where the state is saved.");
            }

            Project.FileName = newName;  // Also sets the name;

            SaveProject();
            m_recentMenu.AddFile(newName);
        }
Beispiel #2
0
        /// <summary>
        /// Loads project from file
        /// </summary>
        /// <param name="path">Path to .brain/.brainz file</param>
        public void OpenProject(string path)
        {
            MyLog.INFO.WriteLine("Loading project: " + path);

            string content;

            try
            {
                string newProjectName = MyProject.MakeNameFromPath(path);

                content = ProjectLoader.LoadProject(path,
                                                    MyMemoryBlockSerializer.GetTempStorage(newProjectName));

                using (MyMemoryManager.Backup backup = MyMemoryManager.GetBackup())
                {
                    Project = MyProject.Deserialize(content, Path.GetDirectoryName(path));
                    backup.Forget();
                }

                Project.FileName = path;
            }
            catch (Exception e)
            {
                MyLog.ERROR.WriteLine("Project loading failed: " + e.Message);
                throw;
            }
        }