コード例 #1
0
        /// <summary>
        /// Remove the Link with the given Index from the File
        /// </summary>
        /// <param name="index">The index of the Element</param>
        /// <returns>true if the link was removed</returns>
        /// <remarks>
        /// A Link will not be removed, if it is still referenced
        /// in one or more Groups!
        /// </remarks>
        public bool RemoveLink(int index)
        {
            foreach (GmdcGroup g in groups)
            {
                if (g.LinkIndex == index)
                {
                    return(false);
                }
            }

            GmdcLink l = links[index];

            foreach (GmdcGroup g in groups)
            {
                if (g.LinkIndex > index)
                {
                    g.LinkIndex--;
                }
            }

            for (int i = 0; i < l.ReferencedElement.Count; i++)
            {
                int n = l.ReferencedElement[i];
                l.ReferencedElement[i] = -1;                 //make sure the reference is removed first
                RemoveElement(n);
            }
            links.RemoveAt(index);
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Unserializes a BinaryStream into the Attributes of this Instance
        /// </summary>
        /// <param name="reader">The Stream that contains the FileData</param>
        public override void Unserialize(System.IO.BinaryReader reader)
        {
            tried   = false;
            version = reader.ReadUInt32();

            string name = reader.ReadString();
            uint   myid = reader.ReadUInt32();

            sgres.Unserialize(reader);
            sgres.BlockID = myid;

            if (Parent.Fast)
            {
                elements.Clear();
                links.Clear();
                groups.Clear();
                joints.Clear();
                return;
            }

            int count = reader.ReadInt32();

            elements.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcElement e = new GmdcElement(this);
                e.Unserialize(reader);
                elements.Add(e);
            }

            count = reader.ReadInt32();
            links.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcLink l = new GmdcLink(this);
                l.Unserialize(reader);
                links.Add(l);
            }

            count = reader.ReadInt32();
            groups.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcGroup g = new GmdcGroup(this);
                g.Unserialize(reader);
                groups.Add(g);
            }

            model.Unserialize(reader);

            count = reader.ReadInt32();
            joints.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcJoint s = new GmdcJoint(this);
                s.Unserialize(reader);
                joints.Add(s);
            }
        }