/// <summary> /// 编辑面板关闭 /// </summary> /// <param name="sender">事件发送者</param> /// <param name="e">事件参数</param> private void frmEdit_FormClosing(object sender, FormClosingEventArgs e) { if (IsChanged) { if (MessageBox.Show(string.Format(" 内容已改变是否保存?", m_filename), "保存脚本", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { // 保存前查错 MainForm mainForm = this.MdiParent as MainForm; string strOut = mainForm.ScriptCheck(luaEditBox.Text); if (strOut != null) { strOut = strOut.TrimEnd('\n'); } if (!string.IsNullOrEmpty(strOut)) { MessageBox.Show(string.Format("{0} 脚本中包含错误:\r\n{1}", m_filename, strOut), "脚本检查", MessageBoxButtons.OK, MessageBoxIcon.Question); TreePhOpera.SetNodeColorByID(mainForm.treePh, this.ID, Color.Red); } else { TreePhOpera.SetNodeColorByID(mainForm.treePh, this.ID, Color.Black); } // 保存 DoSave(); } else { // 不保存 DataBaseManager databaseManager = DataBaseManager.GetDataBaseManager(); databaseManager.UnLockScript(this.ID); this.isLocked = false; } } }
/// <summary> /// 加载数据库脚本树 /// </summary> private void LoadDataBaseScriptTree() { treePh.Nodes.Clear(); // 加载数据库脚本 TreePhOpera tpo = new TreePhOpera(); Hashtable htable = new Hashtable(); DataBaseManager dbm = DataBaseManager.GetDataBaseManager(); treePh.Tag = dbm.GetScriptInformation(); htable["dtable"] = dbm.GetScriptInformation(); htable["pop_folder"] = popTreePh_Folder; htable["pop_file"] = popTreePh_File; htable["scriptType"] = "databaseFile"; foreach (TreeNode tn in tpo.LoadTreeNodeCollection(htable)) { treePh.Nodes.Add(tn); tn.Expand(); } // 增加本地文件结点 Hashtable infoTable = new Hashtable(); infoTable["type"] = "folder"; localFileRootNode = TreePhOpera.CreateNode("本地文件", "folder", popTreePh_LocalFileRoot, infoTable); treePh.Nodes.Add(localFileRootNode); }
/// <summary> /// 加载本地脚本树 /// </summary> private void LoadLocalScriptTree() { // 读取配置文件 List<string> fileNameList = LoadLocalFileList(); localFileList = fileNameList; // 加载数据库脚本 TreePhOpera tpo = new TreePhOpera(); Hashtable infoTable = new Hashtable(); DataTable treeTable = new DataTable(); DataColumn idColumn = new DataColumn("id"); DataColumn pathColumn = new DataColumn("path"); treeTable.Columns.Add(idColumn); treeTable.Columns.Add(pathColumn); foreach (string s in fileNameList) { DataRow newRow = treeTable.NewRow(); newRow["id"] = "0"; newRow["path"] = s; treeTable.Rows.Add(newRow); } infoTable["dtable"] = treeTable; ArrayList icoList = new ArrayList(); icoList.Add("folder"); icoList.Add("file"); infoTable["icolist"] = icoList; infoTable["pop_folder"] = popTreePh_LocalFolder; infoTable["pop_file"] = popTreePh_LocalFile; infoTable["scriptType"] = "localFile"; foreach (TreeNode tn in tpo.LoadTreeNodeCollection(infoTable)) { localFileRootNode.Nodes.Add(tn); tn.Expand(); } }