Exemple #1
0
        /// <summary>
        /// Opens from a project save file (.lum)
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static Project OpenProjectDirectory(string file)
        {
            Project    proj       = null;
            Stream     stream     = File.Open(file, FileMode.Open);
            IFormatter bFormatter = new XmlFormatter(typeof(Project));

            try
            {
                proj = (Project)bFormatter.Deserialize(stream);
            }
            catch (Exception ex)
            {
                try
                {
                    MessageBox.Show("Failed opening XML format, trying binary - " + ex.Message, "Error opening file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    stream.Close();

                    bFormatter = new BinaryFormatter();
                    stream     = File.Open(file, FileMode.Open);
                    proj       = (Project)bFormatter.Deserialize(stream);
                }
                catch (Exception ex2)
                {
                    MessageBox.Show(ex2.Message, "Error opening file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            stream.Close();
            return(proj);
        }
Exemple #2
0
        /// <summary>
        /// Creates a project directory save file (.lum)
        /// </summary>
        /// <param name="proj"></param>
        public static void CreateProjectDirectory(Project proj)
        {
            //Create the project file
            Stream     stream     = File.Open(proj.mDiectory + "\\" + proj.mName + ".lum", FileMode.Create);
            IFormatter bFormatter = new XmlFormatter(typeof(Project));

            bFormatter.Serialize(stream, proj);
            stream.Close();
        }