예제 #1
0
        /// <summary>
        ///     Loads ConfigFileStruct FileStruct from XML file.
        ///     If reading fails, return false and write to debug log
        /// </summary>
        private void LoadConfig()
        {
            if (!File.Exists(FilePath))
            {
                Debug.Log("No XML config file existing!");
            }

            try
            {
                // Read object from XML
                Config = _xmlDeSerializer.DeserializeData(FilePath);
            }
            catch (Exception e)
            {
                Debug.Log("Loading XML config file failed: " + e.Message);
            }
        }
예제 #2
0
        /// <summary>
        ///     Load all project data into the local ProjectSpace instance
        /// </summary>
        /// <param name="projectPath">Path to the project directory</param>
        /// <returns>A success flag and a message in case of an error.</returns>
        public (bool, string) LoadProject(string projectPath)
        {
            // Check if the directory path is valid
            if (projectPath.Equals("") || !Path.IsPathRooted(projectPath))
            {
                return(false, "The given directory path is invalid!");
            }

            // Check if the project config file exists
            var projectConfigFile = Path.Combine(projectPath, ProjectConfigFile);

            if (!File.Exists(projectConfigFile))
            {
                return(false, "Project doesn't contain \n a config file!");
            }

            // Check if the project model file exists
            if (!File.Exists(projectConfigFile))
            {
                return(false, "Project doesn't contain \n a model file!");
            }

            try
            {
                // Load the project configuration from XML (excluding 3D model)
                CurrentProject    = _xmlDeSerializer.DeserializeData(projectConfigFile);
                CurrentProjectDir = projectPath;

                // Check if the project model file exists
                return(!File.Exists(projectConfigFile)
                    ? (false, "Project doesn't contain \n an object file!")
                    : (true, ""));
            }
            catch (Exception)
            {
                return(false, "The project couldn't \n be loaded!");
            }
        }