Ejemplo n.º 1
0
        private void 设置为默认笔记本ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNodeTag treenodenotebooktag = treeview_nav.SelectedNode.Tag as TreeNodeTag;
            int         nodeno = treenodenotebooktag.no;

            Controller.Notebook notebookno = new Controller.Notebook();
            notebookno.setDefault(nodeno);
            treeview_nav.Nodes.Clear();
            this.Load_treeview();
        }
Ejemplo n.º 2
0
        //新建笔记
        private void 新建笔记ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBoxTitle.Text = "无标题笔记";
            textBoxEdit.Text  = "";
            TreeNodeTag treenodetag = treeview_nav.SelectedNode.Tag as TreeNodeTag;

            new Note().newNote(treenodetag.no);
            Load_note_list(treenodetag.no);
            toolStripStatusLabelTip.Text = "笔记新建成功";
        }
Ejemplo n.º 3
0
        //删除标签
        private void  除ToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            //创建tag对象
            TreeNodeTag treenodelabeltag = treeview_nav.SelectedNode.Tag as TreeNodeTag;
            //取值
            string nodename = treenodelabeltag.name;
            int    nodeno   = treenodelabeltag.no;

            //用控制器删掉
            Controller.Label label = new Controller.Label();
            label.deleteLabel(nodeno);
            //刷新
            treeview_nav.Nodes.Clear();
            this.Load_treeview();
        }
Ejemplo n.º 4
0
 ///////////////////////////笔记本右击菜单&左键选中/////////////////////////////////
 private void treeview_nav_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         //右击获取焦点
         treeview_nav.SelectedNode = treeview_nav.GetNodeAt(e.X, e.Y);
     }
     if (e.Button == MouseButtons.Left)
     {
         //左击显示列表
         treeview_nav.SelectedNode = treeview_nav.GetNodeAt(e.X, e.Y);
         if (treeview_nav.SelectedNode != null)
         {
             TreeNodeTag treenodetag = treeview_nav.SelectedNode.Tag as TreeNodeTag;
             if (treenodetag != null)
             {
                 if (treenodetag.node_type == "label")
                 {
                     int nodeLabelNo = treenodetag.no;
                     Load_label_list(nodeLabelNo);
                 }
                 else if (treenodetag.node_type == "notebook")
                 {
                     int nodeNotebookNo = treenodetag.no;
                     Load_note_list(nodeNotebookNo);
                 }
                 else if (treenodetag.node_type == "favourite_root")
                 {
                     int nodeNotebookNo = treenodetag.no;
                     Load_favourite_list();
                 }
                 else if (treenodetag.node_type == "trash_root")
                 {
                     int nodeNotebookNo = treenodetag.no;
                     Load_trash_list();
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
        //删除笔记本
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
            DialogResult      dr         = MessageBox.Show("删除笔记本将会同时删除笔记本内所有笔记,确认删除?", "删除笔记本", messButton);

            if (dr == DialogResult.OK)//如果点击“确定”按钮
            {
                //创建tag对象
                TreeNodeTag treenodenotebooktag = treeview_nav.SelectedNode.Tag as TreeNodeTag;
                //取值
                string nodename = treenodenotebooktag.name;
                int    nodeno   = treenodenotebooktag.no;
                //用控制器删掉
                Controller.Notebook notebookno = new Controller.Notebook();
                notebookno.deleteNotebook(nodeno);
                //刷新
                treeview_nav.Nodes.Clear();
                this.Load_treeview();
            }
            else//如果点击“取消”按钮
            {
            }
        }
Ejemplo n.º 6
0
        private void treeview_nav_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            string newtext = e.Label;     //获取新文本
            string oldtext = e.Node.Text; //获取原来的文本

            newtext = oldtext;
            if (newtext != oldtext)
            {
                Console.WriteLine("不一样");
                TreeNodeTag treenodenotebooktag = treeview_nav.SelectedNode.Tag as TreeNodeTag;
                //获得节点信息
                string nodename = treenodenotebooktag.name;
                int    nodeno   = treenodenotebooktag.no;
                //判断类型
                string nodetype = treenodenotebooktag.node_type;
                if (nodetype == "notebook")
                {
                    Controller.Notebook notebookno = new Controller.Notebook();
                    notebookno.renameNotebook(nodeno, newtext);
                }
                else if (nodetype == "label")
                {
                    Controller.Label label = new Controller.Label();
                    label.renameLabel(nodeno, newtext);
                }
                //刷新
                treeview_nav.Nodes.Clear();
                this.Load_treeview();
                treeview_nav.LabelEdit = false;
            }
            else
            {
                Console.WriteLine("一样的");
                treeview_nav.LabelEdit = false;
            }
        }
Ejemplo n.º 7
0
        //加载左侧导航栏
        public void Load_treeview()
        {
            //添加顶级节点
            TreeNodeTag treenodenotebookroottag = new TreeNodeTag();
            TreeNode    notebook_root           = new TreeNode("笔记本");

            notebook_root.Name                = "notebook_root";
            notebook_root.ContextMenuStrip    = contextMenuStrip_notebook_root;
            treenodenotebookroottag.node_type = "notebook_root";
            notebook_root.Tag = treenodenotebookroottag;
            this.treeview_nav.Nodes.Add(notebook_root);

            TreeNodeTag treenodelabelroottag = new TreeNodeTag();
            TreeNode    label_root           = new TreeNode("标签");

            label_root.Name = "label_root";
            treenodelabelroottag.node_type = "label_root";
            label_root.Tag = treenodelabelroottag;
            this.treeview_nav.Nodes.Add(label_root);

            TreeNodeTag treenodefavouriteroottag = new TreeNodeTag();
            TreeNode    facourite_root           = new TreeNode("收藏夹");

            facourite_root.Name = "favourite_root";
            treenodefavouriteroottag.node_type = "favourite_root";
            facourite_root.Tag = treenodefavouriteroottag;
            this.treeview_nav.Nodes.Add(facourite_root);

            TreeNodeTag treenodetrashroottag = new TreeNodeTag();
            TreeNode    trash_root           = new TreeNode("垃圾篓");

            trash_root.Name = "trash_root";
            treenodetrashroottag.node_type = "trash_root";
            trash_root.Tag = treenodetrashroottag;
            trash_root.ContextMenuStrip = contextMenuStrip_trash;
            this.treeview_nav.Nodes.Add(trash_root);

            //添加笔记本
            Notebook        notebook        = new Notebook();
            MySqlDataReader reader_notebook = notebook.listNotebook();

            while (reader_notebook.Read())
            {
                if (reader_notebook.HasRows)
                {
                    //创建新节点对象
                    TreeNode    newnode             = new TreeNode(reader_notebook.GetString(1));
                    TreeNodeTag treenodenotebooktag = new TreeNodeTag();
                    treenodenotebooktag.no         = reader_notebook.GetInt32("notebook_no");
                    treenodenotebooktag.name       = reader_notebook.GetString("notebook_name");
                    treenodenotebooktag.is_default = reader_notebook.GetInt32("notebook_default");
                    treenodenotebooktag.node_type  = "notebook";
                    newnode.Tag = treenodenotebooktag;
                    newnode.ContextMenuStrip = contextMenuStrip_notebook;
                    //找到父节点
                    if (treenodenotebooktag.is_default == 1)
                    {
                        newnode.ForeColor = Color.Red;
                    }
                    TreeNode tnParent = treeview_nav.Nodes["notebook_root"];
                    //添加到父节点
                    tnParent.Nodes.Add(newnode);
                    //Console.WriteLine("编号:" + reader_notebook.GetInt32(0) + "|姓名:" + reader_notebook.GetString(1));
                }
            }
            //添加标签
            Controller.Label label        = new Controller.Label();
            MySqlDataReader  reader_label = label.list_label();

            while (reader_label.Read())
            {
                if (reader_label.HasRows)
                {
                    TreeNode    newnode          = new TreeNode(reader_label.GetString(1));
                    TreeNodeTag treenodelabeltag = new TreeNodeTag();
                    treenodelabeltag.no        = reader_label.GetInt32("label_no");
                    treenodelabeltag.name      = reader_label.GetString("label_name");
                    treenodelabeltag.node_type = "label";
                    newnode.Tag = treenodelabeltag;
                    newnode.ContextMenuStrip = contextMenuStrip_label;
                    TreeNode tnParent = treeview_nav.Nodes["label_root"];
                    tnParent.Nodes.Add(newnode);
                }
            }
            treeview_nav.ExpandAll();
        }