private bool addSceneDirectory() { GxTreeNode selectedNode = (GxTreeNode)tvwSceneList.SelectedNode; if (selectedNode == null) { return(false); } if (selectedNode == null) { Logger.Error("parentNode null."); return(false); } if (selectedNode.getGxNodeType() != GXNodeType.GX_NODE_TYPE_DIRECTORY && selectedNode.getGxNodeType() != GXNodeType.GX_NODE_TYPE_PROJECT) { Logger.Error("invalid node type."); return(false); } GxProject project = GlobalObj.getOpenningProject(); project.createNewDirectory(selectedNode); return(true); }
//================================================================ // ● 外部调用方法 //================================================================ /// <summary> /// 关闭当前工程 /// </summary> public void closeCurrentProject() { //卸载工程 GxProject project = GlobalObj.getOpenningProject(); project.unload(); Logger.Debug("Unloaded openning project."); //清除节点数据 _projectNode = null; tvwSceneList.Nodes.Clear(); Logger.Debug("Cleared all project nodes."); }
/// <summary> /// 加载工程 /// </summary> /// <param name="filename"></param> /// <returns></returns> public bool loadProject(string filename) { Logger.Debug("Loading Project, Path = " + filename); if (File.Exists(filename) == false) { Logger.Error("Failed to load project : file not found."); MessageBox.Show(string.Format("{0}\n\n工程文件不存在或文件路径错误。", filename), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } //关闭当前已打开的工程 GxProject project = GlobalObj.getOpenningProject(); if (project.isLoaded() == true) { closeCurrentProject(); } //取得传入文件的全路径 //filename = Path.GetFullPath(filename); //加载工程文件 if (project.load(filename) == false) { Logger.Error("load project [" + filename + "] failed."); return(false); } Logger.Debug("Project is loaded."); //加载场景树 GxTreeNode projectNode = new GxTreeNode(); projectNode.setGxNodeType(GXNodeType.GX_NODE_TYPE_PROJECT); projectNode.Text = string.Format("{0} [已加载]", GxEnvManager.getEnv(GxEnvVarType.GXENV_PROJECT_NAME)); projectNode.Tag = project; projectNode.ImageIndex = 0; projectNode.SelectedImageIndex = 0; _projectNode = projectNode; string sceneDirPath = GxEnvManager.getEnv(GxEnvVarType.GXENV_PROJECT_SCENE_DIR); //traversalSceneList(sceneDirPath, projectNode); GxTreeNode projectTreeNode = project.getProjectNode(); tvwSceneList.Nodes.Add(projectTreeNode); tvwSceneList.ExpandAll(); return(true); }