Пример #1
0
        //Function Button
        #region Function Button
        private Button createButton(Point location, Size size, Color backcolor, Color forecolor, Node n, string label)
        {
            fButton fb = new fButton(location, size, n, label, backcolor, forecolor);

            fb.Tag    = label;
            fb.Click += Fb_Click;
            return(fb);
        }
Пример #2
0
        private void Fb_Click(object sender, EventArgs e)
        {
            fButton fb = (fButton)sender;

            if (this.board.picbox.Controls.Count == 0)
            {
                if ((string)fb.Tag == "Add")
                {
                    Size  nSize     = new Size(180, 100);
                    Point nLocation = new Point(board.Width / 2 - nSize.Width / 2, board.Height / 2 - nSize.Height / 2);
                    path = new mPath(3, M_colorPath, M_stylePath);

                    Node n = createNode(idnode, "Main Topic", nLocation, nSize, M_colorParentNode, Color.White, path, 1, null, 14, M_shapeParentNode);
                    this.board.picbox.Controls.Add(n);
                    idnode++;


                    listNode.Add(n);
                }
                else
                {
                    MessageBox.Show("Vui lòng thêm node mới !");
                }
            }
            else if (node is null)
            {
                MessageBox.Show("Chưa chọn node ! ");
            }
            else
            {
                if ((string)fb.Tag == "Add")
                {
                    Point cLoc = this.node.getChildLocation(this.node.Width);
                    Node  n    = createNode(idnode, "subtopic " + idnode, cLoc, new Size(150, 80), M_colorChildNode, Color.White, this.path, 1, this.node, 12, M_shapeChildNode);
                    this.board.picbox.Controls.Add(n);

                    displayBorderNode(n);
                    idnode++;

                    //Add list
                    listNode.Add(n);
                }
                else if ((string)fb.Tag == "Delete")
                {
                    this.node.drawPath(this.node.Location, this.node.parent.Location, this.board.picbox.BackColor, this.node.path.size + 2);

                    //get out of list
                    foreach (Node n in listNode)
                    {
                        if (this.node.id == n.id)
                        {
                            listNode.Remove(n);
                            removeChildOfNode(n);
                            if (isExisted)
                            {
                                listDelete.Add(n);
                            }
                            break;
                        }
                    }
                    foreach (Node n in listDelete.ToList())
                    {
                        removeChildOfNode(n);
                    }

                    node.Dispose();
                    this.node = null;
                }
                else if ((string)fb.Tag == "Format")
                {
                    if (this.formatTable.isOn == false)
                    {
                        this.board.Size = new Size(this.Width - 300, this.Height - 140);
                        this.Controls.Add(this.formatTable);
                        this.formatTable.isOn = true;
                        this.formatTable.updateFormatTable(this.node.shape, this.node.BackColor, this.node.size, this.node.Font.FontFamily.Name, (int)this.node.Font.Size, this.node.ForeColor, this.node.path);
                    }
                    else
                    {
                        this.board.Size = new Size(this.Width - 20, this.Height - 140);
                        this.Controls.Remove(this.formatTable);
                        this.formatTable.isOn = false;
                    }
                }
            }
        }