Ejemplo n.º 1
0
        //笔记右击菜单添加标签
        public void contextMenuStripListBoxNote_add_label()
        {
            ((ToolStripDropDownItem)contextMenuStripListBoxNote.Items["标签管理ToolStripMenuItem"]).DropDownItems.Clear();
            MySqlDataReader reader = new Controller.Label().list_label();

            while (reader.Read())
            {
                if (reader.HasRows)
                {
                    ((ToolStripDropDownItem)contextMenuStripListBoxNote.Items["标签管理ToolStripMenuItem"]).DropDownItems.Add(reader.GetString("label_name"));
                }
            }
        }
Ejemplo n.º 2
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.º 3
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.º 4
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();
        }