Beispiel #1
0
 private Settings LoadSettings()
 {
     _file = ManagedFile.Create(_settingsPath);
     if (_file.Load().Length > 0)
     {
         return(_file.Load <Settings>());
     }
     else
     {
         var settings = new Settings();
         _file.Save <Settings>(Settings);
         return(settings);
     }
 }
        /// <summary>
        /// Loads a SKY file.
        /// </summary>
        /// <param name="FilePath">Absolute path to SKY??.DAT file</param>
        /// <param name="Usage">Specify if file will be accessed from disk, or loaded into RAM.</param>
        /// <param name="ReadOnly">File will be read-only if true, read-write if false.</param>
        /// <returns>True if successful, otherwise false.</returns>
        public override bool Load(string FilePath, FileUsage Usage, bool ReadOnly)
        {
            // Exit if this file already loaded
            if (ManagedFile.FilePath == FilePath)
            {
                return(true);
            }

            // Validate filename
            FilePath = FilePath.ToUpper();
            string fn = Path.GetFileName(FilePath);

            if (!fn.StartsWith("SKY") && !fn.EndsWith(".DAT"))
            {
                return(false);
            }

            // Load file
            if (!ManagedFile.Load(FilePath, Usage, ReadOnly))
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Loads a CIF or RCI file.
        /// </summary>
        /// <param name="FilePath">Absolute path to *.CIF or *.RCI file</param>
        /// <param name="Usage">Specify if file will be accessed from disk, or loaded into RAM.</param>
        /// <param name="ReadOnly">File will be read-only if true, read-write if false.</param>
        /// <returns>True if successful, otherwise false.</returns>
        public override bool Load(string FilePath, FileUsage Usage, bool ReadOnly)
        {
            // Exit if this file already loaded
            if (ManagedFile.FilePath == FilePath)
            {
                return(true);
            }

            // Validate filename
            FilePath = FilePath.ToUpper();
            if (!FilePath.EndsWith(".CIF") && !FilePath.EndsWith(".RCI"))
            {
                return(false);
            }

            // Load file
            if (!ManagedFile.Load(FilePath, Usage, ReadOnly))
            {
                return(false);
            }

            // Read file
            if (!Read())
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Loads a texture file.
        /// </summary>
        /// <param name="FilePath">Absolute path to TEXTURE.* file</param>
        /// <param name="Usage">Specify if file will be accessed from disk, or loaded into RAM.</param>
        /// <param name="ReadOnly">File will be read-only if true, read-write if false.</param>
        /// <returns>True if successful, otherwise false.</returns>
        public override bool Load(string FilePath, FileUsage Usage, bool ReadOnly)
        {
            // Exit if this file already loaded
            if (ManagedFile.FilePath == FilePath)
            {
                return(true);
            }

            // Validate filename
            FilePath = FilePath.ToUpper();
            string fn = Path.GetFileName(FilePath);

            if (!fn.StartsWith("TEXTURE."))
            {
                return(false);
            }

            // Handle unsupported files
            if (!IsFilenameSupported(fn))
            {
                Console.WriteLine(string.Format("{0} is unsupported.", fn));
                return(false);
            }

            // Handle solid types
            if (fn == "TEXTURE.000")
            {
                SolidType = SolidTypes.SolidColoursA;
            }
            else if (fn == "TEXTURE.001")
            {
                SolidType = SolidTypes.SolidColoursB;
            }
            else
            {
                SolidType = SolidTypes.None;
            }

            // Load file
            if (!ManagedFile.Load(FilePath, Usage, ReadOnly))
            {
                return(false);
            }

            // Read file
            if (!Read())
            {
                return(false);
            }

            return(true);
        }
Beispiel #5
0
 public CodeEditorViewModel(ManagedFile file)
 {
     SystemLog.Instance.LogInfo($"Opening file...{file.FileName}");
     _file = file;
     if (_file != null)
     {
         Document.Text      = _file.Load();
         Title              = _file.FileName;
         ContentId          = $"file://{_file.FullPath}";
         SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(
             _file.Extension
             );
         Title       = _file.FileName + $" - ({SyntaxHighlighting.Name})";
         initialLoad = true;
     }
 }
        /// <summary>
        /// Loads an IMG file.
        /// </summary>
        /// <param name="FilePath">Absolute path to *.IMG file</param>
        /// <param name="Usage">Specify if file will be accessed from disk, or loaded into RAM.</param>
        /// <param name="ReadOnly">File will be read-only if true, read-write if false.</param>
        /// <returns>True if successful, otherwise false.</returns>
        public override bool Load(string FilePath, FileUsage Usage, bool ReadOnly)
        {
            // Exit if this file already loaded
            if (ManagedFile.FilePath == FilePath)
            {
                return(true);
            }

            // Validate filename
            FilePath = FilePath.ToUpper();
            string fn = Path.GetFileName(FilePath);

            if (!fn.EndsWith(".IMG"))
            {
                return(false);
            }

            // Handle unsupported files
            if (!IsFilenameSupported(fn))
            {
                Console.WriteLine(string.Format("{0} is unsupported.", fn));
                return(false);
            }

            // Load file
            if (!ManagedFile.Load(FilePath, Usage, ReadOnly))
            {
                return(false);
            }

            // Read file
            if (!Read())
            {
                return(false);
            }

            return(true);
        }
Beispiel #7
0
 private static void LoadState()
 {
     _stateInstance = _stateFile.Load <SystemState>();
 }