/// <summary>
        /// Opens a file in preparation for writing a series of image entries
        /// should load the manifest so we can add / remove entries from it
        /// </summary>
        /// <returns></returns>
        public bool OpenSceneFile(string scenefilename) 
        {
            try
            {
                mZip = ZipFile.Read(scenefilename);
                //open the manifest file                
                string xmlname = "manifest.xml";
                ZipEntry manifestentry = mZip[xmlname];
                //get memory stream
                MemoryStream manistream = new MemoryStream();
                //extract the stream
                manifestentry.Extract(manistream);
                //read from stream
                manistream.Seek(0, SeekOrigin.Begin); // rewind the stream for reading
                //create a new XMLHelper to load the stream into
                mManifest = new XmlHelper();
                //load the stream
                mManifest.LoadFromStream(manistream, "manifest");

                return true;
            }
            catch (Exception ex) 
            {
                DebugLogger.Instance().LogError(ex);
            }
            return false;
        }
Example #2
0
 /// <summary>
 /// Load the slice and build profile from a Stream
 /// This is used when we're serializing / deserializing from the 
 /// Memory stream pulled from a zip file
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="filename"></param>
 /// <returns></returns>
 public bool Load(Stream stream, String filename)
 {
     m_filename = filename;
     XmlHelper xh = new XmlHelper();
     bool fileExist = xh.LoadFromStream(stream, "SliceBuildConfig");
     LoadInternal(ref xh);
     return true;
 }
 /// <summary>
 /// This will open the zip file
 /// load the manifest file into this object
 /// and close the zip file
 /// </summary>
 /// <param name="scenefilename"></param>
 /// <returns></returns>
 public bool LoadManifest(string scenefilename)
 {
     try
     {
         using (ZipFile tmpZip = ZipFile.Read(scenefilename))
         {
             //open the manifest file
             string xmlname = "manifest.xml";
             ZipEntry manifestentry = tmpZip[xmlname];
             //get memory stream
             MemoryStream manistream = new MemoryStream();
             //extract the stream
             manifestentry.Extract(manistream);
             //read from stream
             manistream.Seek(0, SeekOrigin.Begin); // rewind the stream for reading
             //create a new XMLHelper to load the stream into
             mManifest = new XmlHelper();
             //load the stream
             mManifest.LoadFromStream(manistream, "manifest");
         } // the end of this using block should close the zip file
         return true;
     }
     catch (Exception ex)
     {
         mManifest = new XmlHelper();
         mManifest.StartNew("", "manifest");
         DebugLogger.Instance().LogError(ex);
     }
     return false;
 }
Example #4
0
        public bool Load(string scenename)
        {
            try
            {
                ZipFile zip = ZipFile.Read(scenename);
                string xmlname = "manifest.xml";
                ZipEntry manifestentry = zip[xmlname];
                //create new manifest xml doc
                XmlHelper manifest = new XmlHelper();
                //get memory stream
                MemoryStream manistream = new MemoryStream();
                //extract the stream
                manifestentry.Extract(manistream);
                //read from stream
                manistream.Seek(0, SeekOrigin.Begin); // rewind the stream for reading
                manifest.LoadFromStream(manistream, "manifest");
                //examine manifest
                //find the node with models
                XmlNode topnode = manifest.m_toplevel;
                XmlNode models = manifest.FindSection(topnode, "Models");
                List<XmlNode> modelnodes = manifest.FindAllChildElement(models, "model");
                foreach (XmlNode nd in modelnodes)
                {
                    string name = manifest.GetString(nd, "name", "noname");
                    string modstlname = name + ".stl";
                    int tag = manifest.GetInt(nd, "tag", 0);
                    ZipEntry modelentry = zip[modstlname]; // the model name will have the _XXXX on the end with the stl extension
                    MemoryStream modstr = new MemoryStream();
                    modelentry.Extract(modstr);
                    //rewind to beginning
                    modstr.Seek(0, SeekOrigin.Begin);
                    //fix the name
                    name = name.Substring(0, name.Length - 5);// get rid of the _XXXX at the end
                    if (tag == Object3d.OBJ_SUPPORT)
                    {
                        Support s = new Support();
                        //load the model
                        s.LoadSTL_Binary(modstr, name);
                        //add to the 3d engine
                        UVDLPApp.Instance().m_engine3d.AddObject(s);
                        //set the tag
                        s.tag = tag;
                        string parent = manifest.GetString(nd, "parent", "noname");
                        s.SetColor(System.Drawing.Color.Yellow);
                        //find and set the parent
                        Object3d tmp = UVDLPApp.Instance().m_engine3d.Find(parent);
                        if (tmp != null)
                        {
                            tmp.AddSupport(s);
                        }
                    }
                    else
                    {
                        //load as normal object
                        Object3d obj = new Object3d();
                        //load the model
                        obj.LoadSTL_Binary((MemoryStream)modstr, name);
                        //add to the 3d engine
                        UVDLPApp.Instance().m_engine3d.AddObject(obj);
                        //set the tag
                        obj.tag = tag;
                    }
                }

                return true;
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex);
                return false;
            }
        }
 public bool Load(MemoryStream ms, string name)
 {
     m_filename = null;
     m_lstMonitorconfigs.Clear(); // clear any previously loaded monitors
     m_name = name;
     bool retval = false;
     XmlHelper xh = new XmlHelper();
     xh.LoadFromStream(ms, "MachineConfig");
     retval = Load(xh);
     return retval;
 }
 /// <summary>
 /// Load the slice and build profile from a Stream
 /// This is used when we're serializing / deserializing from the 
 /// Memory stream pulled from a zip file
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="filename"></param>
 /// <returns></returns>
 public bool Load(Stream stream, String filename)
 {
     m_filename = filename;
     XmlHelper xh = new XmlHelper();
     bool fileExist = xh.LoadFromStream(stream, "SliceBuildConfig");
     LoadInternal(ref xh);
     /*
     if (!fileExist)
     {
         return xh.Save(FILE_VERSION);
     }
     */
     return true;
 }