Exemple #1
0
        ////////////////////////////////////////////////////////////////////////////////
        //////////
        ////////// Bundle Related Methods
        //////////
        /////
        ///// Methods that change the state of the program by manipulating the Bundle
        ///// directly.
        /////
        ////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Saves the currently loaded bundle to the given path on disk
        /// </summary>
        /// <param name="savePath">The path to save the currently bundle to</param>
        public void SaveBundle(string savePath)
        {
            CurrentBundle.SaveFile = savePath;
            PixelariaSaverLoader.SaveBundleToDisk(CurrentBundle, savePath);

            MarkUnsavedChanges(false);
        }
Exemple #2
0
        /// <summary>
        /// Opens a loaded bundle from the given path on disk
        /// </summary>
        /// <param name="savePath">The path to load the bundle from</param>
        public void LoadBundleFromFile(string savePath)
        {
            PixelariaFile file = PixelariaSaverLoader.LoadFileFromDisk(savePath);

            if (file == null)
            {
                MessageBox.Show(Resources.ErrorLoadingFile, Resources.Error_AlertTile, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Dispose of the current bundle if it's present
            if (CurrentBundle != null)
            {
                CloseBundle(CurrentBundle);
            }

            Bundle newBundle = file.LoadedBundle;

            newBundle.SaveFile = savePath;

            LoadBundle(newBundle);

            // Store the file now
            CurrentRecentFileList.StoreFile(savePath);
            _mainForm.UpdateRecentFilesList();
        }
Exemple #3
0
        public void TestPersistenceClass()
        {
            // Generate a dummy file name
            _testFilePath = Path.GetTempFileName();

            Bundle originalBundle = BundleGenerator.GenerateTestBundle(0);

            // Test new file format saving and loading
            PixelariaSaverLoader.SaveBundleToDisk(originalBundle, _testFilePath);
            Bundle newBundle = PixelariaSaverLoader.LoadBundleFromDisk(_testFilePath);

            Assert.AreEqual(originalBundle, newBundle, "After persisting a new (>= v8) file to disk and loading it back up again, the bundles must be equal");

            // Test old file format loading
            SaveBundle(originalBundle, _testFilePath);
            newBundle = PixelariaSaverLoader.LoadBundleFromDisk(_testFilePath);

            Assert.AreEqual(originalBundle, newBundle, "After loading a legacy (< v8) file to disk and loading it back up again, the bundles must be equal");

            // Now load the bundle using the LoadFileFromDisk
            newBundle = PixelariaSaverLoader.LoadFileFromDisk(_testFilePath).LoadedBundle;
            Assert.AreEqual(originalBundle, newBundle, "After loading a legacy (< v8) file to disk and loading it back up again, the bundles must be equal");
        }