/// <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); }
private void ctmSceneNode_Reload_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("重新载入将关闭当前处于打开状态的所有文件,是否确定?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Cancel) { return; } string filename = GxEnvManager.getEnv(GxEnvVarType.GXENV_PROJECT_PATH); closeCurrentProject(); loadProject(filename); }