//判断控件内按钮点击 public void MyControlButtonClick(object sender, EventArgs e) { if (sender.GetType().ToString() == "System.Windows.Forms.Button") { Button bt = (Button)sender; //当前点击的按钮 if (bt.Tag.ToString() == "0") //文件 { NoteForm file = new NoteForm(bt.Text, this); //弹出记事本窗口 file.Show(); } else if (bt.Tag.ToString() == "1") //文件夹 { currentRoot = category.search(rootNode, bt.Text, 1); //更改当前根节点 nowPath = nowPath + "> " + bt.Text; //更改当前路径 fileFormInit(currentRoot); //更新界面元素 } } else { string filename = fileWindow.contextMenuStrip_FileChoose.SourceControl.Text; string type = fileWindow.contextMenuStrip_FileChoose.SourceControl.Tag.ToString(); if (((ToolStripMenuItem)sender).Name == "打开ToolStripMenuItem") { if (type == "0") //文件 { NoteForm file = new NoteForm(filename, this); file.Show(); } else if (type == "1")//文件夹 { currentRoot = category.search(rootNode, filename, 1); nowPath = nowPath + "> " + filename; fileFormInit(currentRoot); } } else if (((ToolStripMenuItem)sender).Name == "删除ToolStripMenuItem") { if (type == "0") { delete(filename, 0); } else if (type == "1") { delete(filename, 1); } } } }