Пример #1
0
        /// <summary>
        /// Read from binary archive
        /// </summary>
        public bool ReadDocument(BinaryArchiveReader archive)
        {
            var rc = false;

            if (null != archive)
            {
                try
                {
                    int major, minor;
                    archive.Read3dmChunkVersion(out major, out minor);
                    if (major == MAJOR && minor == MINOR)
                    {
                        var count = archive.ReadInt();
                        for (var i = 0; i < count; i++)
                        {
                            var data = new SampleCsSimpleDocumentData();
                            if (data.Read(archive))
                            {
                                Add(data);
                            }
                        }
                        rc = archive.ReadErrorOccured;
                    }
                }
                catch
                {
                    // ignored
                }
            }
            return(rc);
        }
        public bool Read(BinaryArchiveReader archive)
        {
            var rc = false;

            if (null != archive)
            {
                // Read and verify chunk version
                int major, minor;
                archive.Read3dmChunkVersion(out major, out minor);
                if (1 == major && 0 == minor)
                {
                    try
                    {
                        // Read this object
                        var bytes     = archive.ReadByteArray();
                        var stream    = new MemoryStream(bytes);
                        var formatter = new BinaryFormatter();
                        var data      = formatter.Deserialize(stream) as SampleCsCustomClass;
                        Create(data);

                        // Verify reading
                        rc = archive.ReadErrorOccured;
                    }
                    catch
                    {
                        // TODO
                    }
                }
            }
            return(rc);
        }
        protected override bool Read(BinaryArchiveReader archive)
        {
            int major, minor;

            archive.Read3dmChunkVersion(out major, out minor);
            if (1 == major && 0 == minor)
            {
                Data.Read(archive);
            }
            return(!archive.ReadErrorOccured);
        }
        /// <summary>
        /// Reads the content of this data from a stream archive.
        /// </summary>
        protected override bool Read(BinaryArchiveReader archive)
        {
            int major, minor;

            archive.Read3dmChunkVersion(out major, out minor);
            if (1 == major && 0 == minor)
            {
                Plane      = archive.ReadPlane();
                ViewportId = archive.ReadGuid();
                Enabled    = archive.ReadBool();
            }
            return(!archive.ReadErrorOccured);
        }
        /// <summary>
        /// Read from binary archive
        /// </summary>
        public void ReadDocument(BinaryArchiveReader archive)
        {
            int major, minor;

            archive.Read3dmChunkVersion(out major, out minor);
            if (MAJOR == major && MINOR == minor)
            {
                var string_table = archive.ReadStringArray();
                if (null != string_table)
                {
                    m_string_table.AddRange(string_table);
                }
            }
        }
Пример #6
0
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            int major, minor;

            archive.Read3dmChunkVersion(out major, out minor);
            byte[] data = archive.ReadByteArray();
            if (!archive.ReadErrorOccured && data != null)
            {
                Host.EnsureInitialisation(true);
                ModelDocument mDoc = Document.FromBinary <ModelDocument>(data);
                Core.Instance.ActiveDocument = mDoc;
            }
            base.ReadDocument(doc, archive, options);
        }
        /// <summary>
        /// Called whenever a Rhino document is being loaded and plug-in user data was
        /// encountered written by a plug-in with this plug-in's GUID.
        /// </summary>
        public void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            int major = 0;
            int minor = 0;

            archive.Read3dmChunkVersion(out major, out minor);
            if (MAJOR == major && MINOR == minor)
            {
                // Always read user data even though you might not use it...
                string[] strings = archive.ReadStringArray();
                if (null != strings && !options.ImportMode && !options.ImportReferenceMode)
                {
                    m_strings.AddRange(strings);
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Read from binary archive
        /// </summary>
        public bool Read(BinaryArchiveReader archive)
        {
            var rc = false;

            if (null != archive)
            {
                try
                {
                    int major, minor;
                    archive.Read3dmChunkVersion(out major, out minor);
                    if (major == MAJOR && minor == MINOR)
                    {
                        Value = archive.ReadInt();
                        rc    = archive.ReadErrorOccured;
                    }
                }
                catch
                {
                    // ignored
                }
            }
            return(rc);
        }
        /// <summary>
        /// Called whenever a Rhino document is being loaded and plug-in user data was
        /// encountered written by a plug-in with this plug-in's GUID.
        /// </summary>
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            int major, minor;

            archive.Read3dmChunkVersion(out major, out minor);
            if (MAJOR == major && MINOR == minor)
            {
                // Always read user data even though you might not use it.

                var string_table = new SampleCsStringDocumentData();
                string_table.ReadDocument(archive);

                var simple_table = new SampleCsSimpleDocumentDataTable();
                simple_table.ReadDocument(archive);

                var dictionary = archive.ReadDictionary();

                if (!options.ImportMode && !options.ImportReferenceMode)
                {
                    if (string_table.Count > 0)
                    {
                        StringDocumentDataTable.AddRange(string_table.ToArray());
                    }

                    if (simple_table.Count > 0)
                    {
                        SimpleDocumentDataTable.AddRange(simple_table.ToArray());
                    }

                    if (null != dictionary && dictionary.Count > 0)
                    {
                        Dictionary = dictionary;
                    }
                }
            }
        }