Example #1
0
        /// <summary>
        /// 在编辑窗体中打开脚本文件
        /// </summary>
        /// <param name="fileName">文件路径</param>
        /// <param name="requireProcessFileName">是否需要处理文件名</param>
        /// <returns>是否打开成功</returns>
        private EditForm OpenFileInEditor(string fileName, bool requireProcessFileName)
        {
            EditForm editForm = null;    
            string filePath = fileName.Replace(Helper.ClientPath, "").TrimStart(new char[] { '\\', '/' });

            foreach (EditForm eForm in this.MdiChildren)
            {
                string editorFileName = eForm.FileName;

                if (requireProcessFileName)
                {
                    editorFileName = ProcessFileName(editorFileName);
                }

                if (editorFileName == filePath)
                {
                    SelectEditForm(eForm);
                    return eForm;                    
                }
            }

            string content = Helper.FileToString(fileName);

            if (!string.IsNullOrEmpty(content))
            {
                editForm = new EditForm("localFile");
                editForm.ID = "0";

                // InitEditForm(editForm, content, filePath);                
                InitEditForm(editForm, content, fileName);
                editForm.Show();
                SelectEditForm(editForm);
            }

            return editForm;
        }
Example #2
0
        /// <summary>
        /// 双击树结点
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void treePh_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeNode currentNode = treePh.SelectedNode;

            if (currentNode.Tag == null)
            {
                return;
            }

            Hashtable infoTable = currentNode.Tag as Hashtable;

            if (infoTable["type"] as string == "folder")
            {
                return;
            }

            string scriptType = infoTable["scriptType"] as string;

            if (scriptType == "databaseFile") // 打开数据库里的脚本文件
            {
                string id = infoTable["id"] as string;
                EditForm editForm = null;

                foreach (EditForm eForm in this.MdiChildren)
                {
                    if (eForm.ID == id)
                    {
                        editForm = eForm;
                    }
                }

                if (editForm == null)
                {
                    editForm = new EditForm("databaseFile");
                    editForm.ID = id;
                    DataBaseManager dbm = DataBaseManager.GetDataBaseManager();
                    string strCode = dbm.GetScriptData(id);

                    if (strCode == null)
                    {
                        MessageBox.Show("加载脚本失败!", "加载脚本", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    InitEditForm(editForm, strCode, currentNode.FullPath);
                    editForm.Show();
                }

                SelectEditForm(editForm);
            }
            else if (scriptType == "localFile") // 打开本地的脚本文件
            {
                string filePath = infoTable["filePath"] as string;
                filePath = Path.Combine(Helper.ClientPath, filePath);
                OpenFileInEditor(filePath, false);
            }
        }