Example #1
0
        //双击目录树结点打开文件或者文件夹
        private void treeView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            TreeNode tn = treeView.SelectedNode;

            if (tn.Tag.ToString() == "1") //打开文件夹
            {
                Stack <TreeNode> s = new Stack <TreeNode>();
                s.Push(tn);
                currentRoot = category.search(rootNode, tn.Text, FCB.FOLDER);

                //更新路径
                nowPath = "";
                while (tn.Parent != null)
                {
                    s.Push(tn.Parent);
                    tn = tn.Parent;
                }
                nowPath = "";
                while (s.Count() != 0)
                {
                    nowPath += "> " + s.Pop().Text;
                }
                textBoxSearch.Text = nowPath;

                //刷新新目录下的界面
                fileFormInit(currentRoot);
            }
            else if (tn.Tag.ToString() == "0") //打开文件
            {
                NoteForm file = new NoteForm(tn.Text.Replace(".txt", ""), this);
                file.Show();
            }
        }
Example #2
0
 //判断控件内按钮点击
 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);
             }
         }
     }
 }