예제 #1
0
 public LoadSystemPageViewModel()
 {
     // Loadable Files is given by the file strings of loadable files casted to load file view models
     _LoadableSaveFiles = new List <LoadFileViewModel>(
         SystemFileParser.GetReadableSaveFiles().Select((FileString) => new LoadFileViewModel(FileString))
         );
 }
예제 #2
0
        /// <summary>
        /// Save the current system with the typed save name.
        /// </summary>
        private void save()
        {
            // Set the current system's save name to the typed in the control.
            // and save to a new file
            CanvasPageViewModel.Instance.System.SystemSaveName = SaveNameText;
            SystemFileParser.SaveNewSystemFile(CanvasPageViewModel.Instance.System);

            // Hide the save box and navigate back to the main menu
            HideBox();
            MasterViewModel.Instance.NavigatePage(ApplicationPage.StartMenu);
        }
예제 #3
0
        /// <summary>
        /// Save the current simulation to file.
        /// </summary>
        private void Save()
        {
            // Get the current system from CPVM instance
            InterstellaSystem SystemToSave = CanvasPageViewModel.Instance.System;

            // If the system has no save name it has not been saved
            if (SystemToSave.SystemSaveName == "")
            {
                // If system has never been saved,Open New Enter Save Name Box
                OpenEnterSaveNameBox();
            }
            else
            {
                bool FoundSystemFile = false;
                // If the system has a save name, attempt to find its save file by comparing against each avaliable save file
                foreach (var SaveFile in SystemFileParser.GetReadableSaveFiles())
                {
                    // Get the path the file would be saved as.
                    string SystemToSaveFilePath = $"{SystemFileParser.ExecutingDomainFilePath}{SystemToSave.SystemSaveName}OSSaveFile.txt";

                    // If A save File is found. overwrite this file
                    if (SaveFile == SystemToSaveFilePath)
                    {
                        SystemFileParser.OverWriteSystemFile(SystemToSave, SaveFile);
                        FoundSystemFile = true;
                    }
                }
                if (FoundSystemFile)
                {
                    // If a save file has been found and saved to, return to main menu
                    NavigateToMenu();
                }
                else
                {
                    // No save file found, must have been deleted or moved.
                    // Ask for a new save name and save to a new file.
                    OpenEnterSaveNameBox();
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Delete a save file.
 /// </summary>
 /// <param name="fileString"></param>
 public void DeleteSave(string fileString)
 {
     // Attempt to remove the file and notify the view a file has been deleted
     SystemFileParser.DeleteSaveFile(fileString);
     NotifyPropertyChanged(this, nameof(LoadableSaveFiles));
 }
예제 #5
0
        /// <summary>
        /// Load a logical system from a save file and display it to canvas page
        /// </summary>
        /// <param name="fileString">Path of system file to load</param>
        public void LoadSystem(string fileString)
        {
            loadSystem(SystemFileParser.ReadSystemFile(fileString));

            //UpdateSystemPannelObjects();
        }