コード例 #1
0
ファイル: ProjectManageDlg.cs プロジェクト: renyh1013/dp2
        // 新方案
        private void button_newProject_Click(object sender, System.EventArgs e)
        {
            // 当前所在路径
            string strProjectPath = "";
            string strTempName = "new project 1";

            TreeNode parent = null;

            int nPrefixNumber = -1;	// 1

            // 当前已选择的node
            if (treeView1.SelectedNode == null)
            {
                strProjectPath = "";
            }
            else
            {
                // 如果当前选择的是dir类型节点,就在其下创建新project
                // 否则,就在同一级创建新project
                if (treeView1.SelectedNode.ImageIndex == 0)
                    parent = treeView1.SelectedNode;
                else
                    parent = treeView1.SelectedNode.Parent;

                strProjectPath = parent != null ? parent.FullPath : "";

                strTempName = GetTempProjectName(treeView1,
                    parent,
                    "new project",
                    ref nPrefixNumber);

                scriptManager.Save();

            }

            /*
            StreamReader sr = new StreamReader(strTempName, true);
            string strCode =sr.ReadToEnd();
            sr.Close();
            */

            string strNewLocate = scriptManager.NewProjectLocate(
                "new project",
                ref nPrefixNumber);

            OneProjectDialog dlg = new OneProjectDialog();
            GuiUtil.AutoSetDefaultFont(dlg);

            dlg.HostName = this.HostName;
            dlg.scriptManager = scriptManager;
            dlg.New(strProjectPath,
                strTempName,
                strNewLocate);

            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
                return;

            // 实际插入project参数
            XmlNode projNode = scriptManager.NewProjectNode(
                dlg.ResultProjectNamePath,
                dlg.ResultLocate,
                false);	// false表示不需要创建目录和缺省文件

            // 兑现显示?
            scriptManager.FillOneLevel(treeView1,
                parent,
                projNode.ParentNode);
            TreeViewUtil.SelectTreeNode(treeView1,
                scriptManager.GetNodePathName(projNode),
                '/');

            /*
            if (parent != null) 
            {
                parent.Expand();
            }
            */

            scriptManager.Save();
        }
コード例 #2
0
ファイル: ProjectManageDlg.cs プロジェクト: renyh1013/dp2
        // 修改方案
        private void button_modify_Click(object sender, System.EventArgs e)
        {
            int nRet;
            // 当前已选择的node
            if (treeView1.SelectedNode == null)
            {
                MessageBox.Show(this, "尚未选择方案或者目录");
                return;
            }

            TreeNode node = treeView1.SelectedNode;
            if (node.ImageIndex == 0)
            {
                // 修改目录名
                DirNameDlg namedlg = new DirNameDlg();
                GuiUtil.AutoSetDefaultFont(namedlg);

                namedlg.textBox_dirName.Text = node.Text;
                namedlg.StartPosition = FormStartPosition.CenterScreen;
                namedlg.ShowDialog(this);

                if (namedlg.DialogResult == DialogResult.OK)
                {
                    // return:
                    //	0	not found
                    //	1	found and changed
                    nRet = scriptManager.RenameDir(node.FullPath,
                        namedlg.textBox_dirName.Text);
                    if (nRet == 1)
                    {
                        node.Text = namedlg.textBox_dirName.Text;	// 兑现视觉
                        scriptManager.Save();
                    }
                }

                return;
            }

            string strProjectNamePath = node.FullPath;

            string strLocate = "";

            // 获得方案参数
            // strProjectNamePath	方案名,或者路径
            // return:
            //		-1	error
            //		0	not found project
            //		1	found
            nRet = scriptManager.GetProjectData(
                strProjectNamePath,
                out strLocate);
            if (nRet != 1)
            {
                MessageBox.Show(this, "方案 " + strProjectNamePath + " 在ScriptManager中没有找到");
                return;
            }

            OneProjectDialog dlg = new OneProjectDialog();
            GuiUtil.AutoSetDefaultFont(dlg);

            dlg.HostName = this.HostName;
            dlg.scriptManager = scriptManager;
            dlg.Initial(strProjectNamePath,
                strLocate);

            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);


            if (dlg.DialogResult == DialogResult.OK)
            {
                if (dlg.ResultProjectNamePath != strProjectNamePath)
                {
                    /*
                    // 修改显示的Project名字
                    string strPath;
                    string strName;
                    ScriptManager.SplitProjectPathName(dlg.ResultProjectNamePath,
                        out strPath,
                        out strName);

                    string strError;

                    nRet = scriptManager.ChangeProjectData(strProjectNamePath,
                        strName,
                        null,
                        out strError);
                    if (nRet == -1) 
                    {
                        MessageBox.Show(this, strError);
                    }
                    else 
                    {
                        // 兑现显示?
                    }
                    */
                    // XML DOM已经在ScriptDlg中修改,这里只是兑现显示
                    string strPath;
                    string strName;
                    ScriptManager.SplitProjectPathName(dlg.ResultProjectNamePath,
                        out strPath,
                        out strName);

                    node.Text = strName;

                }

                scriptManager.Save();
            }


        }