Example #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);
        }
Example #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;
            }
        }
Example #3
0
        private void SaveBlocks(IEnumerable <MyWorkingNode> nodeList)
        {
            MyMemoryBlockSerializer serializer = new MyMemoryBlockSerializer();

            var isFirst = true;

            foreach (MyWorkingNode node in nodeList)
            {
                if (SaveAllNodesData || node.SaveOnStop)
                {
                    foreach (MyAbstractMemoryBlock mb in MyMemoryManager.Instance.GetBlocks(node))
                    {
                        if (mb.Persistable)
                        {
                            if (isFirst)
                            {
                                MyLog.INFO.WriteLine("Saving state to: " + MyMemoryBlockSerializer.GetTempStorage(m_project));
                            }

                            isFirst = false;
                            serializer.SaveBlock(mb);
                        }
                    }
                }
            }
        }
Example #4
0
        private void LoadBlocks(IEnumerable <MyWorkingNode> nodeList)
        {
            MyMemoryBlockSerializer serializer = new MyMemoryBlockSerializer();

            var isFirst = true;

            foreach (MyWorkingNode node in nodeList)
            {
                if (LoadAllNodesData || node.LoadOnStart)
                {
                    foreach (MyAbstractMemoryBlock mb in MyMemoryManager.Instance.GetBlocks(node))
                    {
                        if (mb.Persistable)
                        {
                            if (isFirst)
                            {
                                MyLog.INFO.WriteLine("Loading state from: " + MyMemoryBlockSerializer.GetTempStorage(m_project));
                            }

                            isFirst = false;
                            serializer.LoadBlock(mb, GlobalDataFolder);
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Saves project to given path
 /// </summary>
 /// <param name="path">Path for saving .brain/.brainz file</param>
 public void SaveProject(string path)
 {
     MyLog.INFO.WriteLine("Saving project: " + path);
     try
     {
         string fileContent = Project.Serialize(Path.GetDirectoryName(path));
         ProjectLoader.SaveProject(path, fileContent,
                                   MyMemoryBlockSerializer.GetTempStorage(Project));
     }
     catch (Exception e)
     {
         MyLog.ERROR.WriteLine("Project saving failed: " + e.Message);
         throw;
     }
 }
Example #6
0
        /// <summary>
        /// Saves project to given path
        /// </summary>
        /// <param name="path">Path for saving .brain/.brainz file</param>
        public void SaveProject(string path = null)
        {
            if (!string.IsNullOrEmpty(path))
            {
                Project.FileName = path;
            }

            MyLog.INFO.WriteLine("Saving project: " + Project.FileName);
            try
            {
                string fileContent = Project.Serialize();
                ProjectLoader.SaveProject(Project.FileName, fileContent,
                                          MyMemoryBlockSerializer.GetTempStorage(Project));
            }
            catch (Exception e)
            {
                MyLog.ERROR.WriteLine("Project saving failed: " + e.Message);
                throw;
            }
        }