/// <summary> /// 从文件中读取合成结构数据 /// </summary> /// <param name="must">是否必须读取</param> public void ReadSynthesisStructData(bool must = false) { if (synthesisDataAnalysis == null || must) { TextAsset synthesisTextAsset = Resources.Load <TextAsset>("Data/Synthesis/Synthesis"); if (synthesisTextAsset != null) { synthesisDataAnalysis.ReadData(synthesisTextAsset.text); } } }
/// <summary> /// 打开方案 /// </summary> /// <param name="fileName"></param> private void OpenProject(string fileName) { startID = 0; this.fileName = fileName; InitTreeView(); //读取数据 string valueStr = File.ReadAllText(this.fileName); synthesisDataAnalysis.ReadData(valueStr); int[] ids = synthesisDataAnalysis.IDArray; if (ids.Length > 0) { startID = ids.Max() + 1; } SynthesisDataStruct[] synthesisDataStructs = ids.Select(temp => synthesisDataAnalysis.GetDataByID(temp)).ToArray(); foreach (SynthesisDataStruct synthesisDataStruct in synthesisDataStructs) { TreeNode synthesisTypeNode = TreeView_Main.Nodes.Find(synthesisDataStruct.synthesisType.ToString(), false).FirstOrDefault(); if (synthesisTypeNode != null) { TreeNode synthesisItemNode = synthesisTypeNode.Nodes.Find(synthesisDataStruct.synthesisItem.ToString(), false).FirstOrDefault(); if (synthesisItemNode != null) { TreeNode dataNode = new TreeNode(); dataNode.Name = synthesisDataStruct.id.ToString(); dataNode.Text = synthesisDataStruct.ToStringSimple(); dataNode.Tag = synthesisDataStruct; synthesisItemNode.Nodes.Add(dataNode); } } } //使控件可用 添加节点ToolStripMenuItem.Enabled = true; 除节点ToolStripMenuItem.Enabled = true; 保存方案ToolStripMenuItem.Enabled = true; }