コード例 #1
0
        private void m_gameDocumentRegistry_DocumentRemoved(object sender, ItemRemovedEventArgs <IGameDocument> e)
        {
            IGameDocument document = e.Item;

            document.DirtyChanged -= m_document_DirtyChanged;
            document.UriChanged   -= m_document_UriChanged;

            IGame game = document.Cast <IGame>();

            if (document == m_designView.Context.Cast <IGameDocument>())
            {// master document.
                IGrid        grid       = document.As <IGame>().Grid;
                GridRenderer gridRender = grid.Cast <GridRenderer>();
                gridRender.DeleteVertexBuffer();
                m_designView.Context = null;
                GameEngine.DestroyObject(game.Cast <NativeObjectAdapter>());
                GameEngine.Clear();
            }
            else
            {// sub document.
                DomNode masterNode            = m_gameDocumentRegistry.MasterDocument.As <DomNode>();
                DomNode rooFolderNode         = game.RootGameObjectFolder.Cast <DomNode>();
                NativeGameWorldAdapter gworld = masterNode.Cast <NativeGameWorldAdapter>();
                gworld.Remove(masterNode, rooFolderNode, masterNode.Type.GetChildInfo("gameObjectFolder"));
            }
        }