Beispiel #1
0
        void MergeFrame(odfFrame newFrame, int destParentIdx)
        {
            odfFrame srcParent = new odfFrame(new ObjectName("A new frame", null), ObjectID.INVALID, 1);

            srcParent.AddChild(newFrame);

            odfFrame destParent;

            if (destParentIdx < 0)
            {
                destParent = new odfFrame(new ObjectName("Another new frame", null), ObjectID.INVALID, 1);
                destParent.AddChild(Parser.FrameSection.RootFrame);
            }
            else
            {
                destParent = Frames[destParentIdx];
            }

            MergeFrame(srcParent, destParent);

            if (destParentIdx < 0)
            {
                Parser.FrameSection.RootFrame = srcParent[0];
                srcParent.RemoveChild(0);
            }

            Frames.Clear();
            InitFrames(Parser.FrameSection.RootFrame);
        }
Beispiel #2
0
        void MergeFrame(odfFrame srcParent, odfFrame destParent)
        {
            for (int i = 0; i < destParent.Count; i++)
            {
                var dest = destParent[i];
                for (int j = 0; j < srcParent.Count; j++)
                {
                    var src = srcParent[j];
                    if (src.Name.ToString() == dest.Name.ToString())
                    {
                        MergeFrame(src, dest);

                        srcParent.RemoveChild(j);
                        if (dest.MeshId != null && (int)dest.MeshId != 0)
                        {
                            odfMesh mesh = odf.FindMeshListSome(dest.MeshId, Parser.MeshSection);
                            odf.RemoveMesh(Parser, mesh, dest, false);
                        }
                        destParent.RemoveChild(i);
                        destParent.InsertChild(i, src);
                        break;
                    }
                }
            }

            if (srcParent.Name.ToString() == destParent.Name.ToString())
            {
                while (destParent.Count > 0)
                {
                    var dest = destParent[0];
                    destParent.RemoveChild(0);
                    srcParent.AddChild(dest);
                }
            }
            else
            {
                while (srcParent.Count > 0)
                {
                    var src = srcParent[0];
                    srcParent.RemoveChild(0);
                    destParent.AddChild(src);
                }
            }
        }