コード例 #1
0
        /// <summary>
        /// 具体的打开方案类
        /// </summary>
        /// <param name="projectPath">方案文件路径</param>
        private void OpenProject(string projectPath)
        {
            if (searchNodeForm != null)
            {
                searchNodeForm.MustClose();
            }
            searchNodeForm = new SearchNodeForm();
            searchNodeForm.ShowSearchPanel = ShowSearchPanel;
            searchNodeForm.BasePanel       = FlowLayoutPanel_Main;
            this.projectPath = projectPath;
            FlowLayoutPanel_Main.Controls.Clear();
            dialogueConditionFileName = ""; //对话条件文件名
            dialogueValueFileName     = ""; //对话数据文件名
            using (StreamReader fs = new StreamReader(this.projectPath, Encoding.UTF8))
            {
                dialogueConditionFileName = fs.ReadLine();
                dialogueValueFileName     = fs.ReadLine();
            }
            string folderPath           = Path.GetDirectoryName(this.projectPath);
            string dialogueConditionStr = "";
            string dialogueValueStr     = "";

            if (!string.IsNullOrEmpty(dialogueConditionFileName) && File.Exists(folderPath + "\\" + dialogueConditionFileName + ".txt"))
            {
                dialogueConditionStr = File.ReadAllText(folderPath + "\\" + dialogueConditionFileName + ".txt", Encoding.UTF8);
            }
            if (!string.IsNullOrEmpty(dialogueValueFileName) && File.Exists(folderPath + "\\" + dialogueValueFileName + ".txt"))
            {
                dialogueValueStr = File.ReadAllText(folderPath + "\\" + dialogueValueFileName + ".txt", Encoding.UTF8);
            }
            if (!string.IsNullOrEmpty(dialogueConditionFileName) && !string.IsNullOrEmpty(dialogueValueFileName))
            {
                int maxID = dialogueAnalysisData.ReadData(dialogueConditionStr, dialogueValueStr);
                IDCreator.Instance.Init(maxID + 1);
                CreateControlByData();
                添加节点ToolStripMenuItem.Enabled = true;
                除节点ToolStripMenuItem.Enabled  = true;
                保存方案ToolStripMenuItem.Enabled = true;
                搜索节点ToolStripMenuItem.Enabled = true;
                展开节点ToolStripMenuItem.Enabled = true;
                收起节点ToolStripMenuItem.Enabled = true;
            }
        }