Esempio n. 1
0
        /// <summary>
        /// Saves a GUIProject to disk.
        /// </summary>
        /// <param name="project"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static bool Save(GUIProject project, string filename)
        {
            FileStream fs       = null;
            bool       bSuccess = false;

            try
            {
                fs = new FileStream(filename, FileMode.Create);
                XmlSerializer serializer = new XmlSerializer(typeof(GUIProject));

                // Ensure the project version is set before serialization
                project.Version = Otter.Properties.Settings.Default.ProjectVersion;
                serializer.Serialize(fs, project);

                foreach (GUIProjectEntry entry in project.Entries)
                {
                    entry.Save();
                }

                bSuccess = true;
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException(ex.Message);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }

            return(bSuccess);
        }
Esempio n. 2
0
        /// <summary>
        /// Constructs this sceneView with a list of files for exporting.
        /// </summary>
        /// <param name="filesToExport"></param>
        public AssetExporter(GUIProject project, ArrayList itemsToExport)
        {
            mProject = project;
            mItemsToExport = itemsToExport;

            InitializeComponent();
            
            // Add the platforms to the listbox.
            for (int i = 0; i < mProject.Platforms.Count; i++)
                mPlatformsListBox.Items.Add(mProject.Platforms[i], true);

            // Add the items that we want to export.  Can be of any type.
            for (int i = 0; i < itemsToExport.Count; i++)
                mFilesListBox.Items.Add(itemsToExport[i], true);
        }
Esempio n. 3
0
        /// <summary>
        /// Loads the GUI Project from disk
        /// </summary>
        /// <returns></returns>
        public static GUIProject Load(string filename)
        {
            GUIProject project = null;
            FileStream fs      = null;

            try
            {
                fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
                XmlSerializer serializer = new XmlSerializer(typeof(GUIProject));
                project = serializer.Deserialize(fs) as GUIProject;

                project.ProjectDirectory = System.IO.Path.GetDirectoryName(filename);

                foreach (GUIFont font in project.Fonts)
                {
                    font.Project = project;
                    font.ReloadFont();
                }

                // TODO : Check project version, and perform any fixups necessary

                // Set the project version once all fixups have been performed.
                project.Version = Otter.Properties.Settings.Default.ProjectVersion;

                // Create a "unique" count for each entry upon load.
                uint id = 1000;
                foreach (GUIProjectEntry entry in project.Entries)
                {
                    entry.ID = (id++);
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Exception e:" + ex);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }

            return(project);
        }
Esempio n. 4
0
        /// <summary>
        /// Saves a GUIProject to disk.
        /// </summary>
        /// <param name="project"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static bool Save(GUIProject project, string filename)
        {
            FileStream fs = null;
            bool bSuccess = false;

            try
            {
                fs = new FileStream(filename, FileMode.Create);
                XmlSerializer serializer = new XmlSerializer(typeof(GUIProject));

                // Ensure the project version is set before serialization
                project.Version = Otter.Properties.Settings.Default.ProjectVersion;
                serializer.Serialize(fs, project);

                foreach (GUIProjectEntry entry in project.Entries)
                    entry.Save();

                bSuccess = true;
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException(ex.Message);
            }
            finally
            {
                if (fs != null)
                    fs.Close();
            }

            return bSuccess;
        }