public MindMap(Color colorBoard, Color colorParent, Color colorChild, Color colorPath, string shapeParent, string shapeChild, string style) { InitializeComponent(); int width = Screen.PrimaryScreen.WorkingArea.Width; int height = Screen.PrimaryScreen.WorkingArea.Height; this.Width = width; this.Height = height; this.listNode = new List <Node>(); this.M_colorBoard = colorBoard; this.M_colorChildNode = colorChild; this.M_colorParentNode = colorParent; this.M_colorPath = colorPath; this.M_shapeChildNode = shapeChild; this.M_shapeParentNode = shapeParent; this.M_stylePath = style; Timer timer = new Timer(); timer.Interval = 1000; timer.Tick += Timer_Tick; timer.Enabled = true; idnode = TOPICcontroller.getID(); formatTable = new FormatTable(new Point(this.Width - 300, 100), new Size(290, this.Height - 100), Color.FromArgb(225, 225, 225), Color.Black, this); this.Controls.Add(createToolPanel()); this.Controls.Add(createBoardAndMainNode()); }
//Tools Panel & Board #region Panel & Board public Board createBoardAndMainNode() { Board board = new Board(-1, M_colorBoard, new Point(0, 100), new Size(this.Width - 20, this.Height - 140)); this.board = board; 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(4, M_colorPath, M_stylePath); idnode = TOPICcontroller.getID(); Node n = createNode(idnode, "Main Topic", nLocation, nSize, M_colorParentNode, Color.White, path, 1, null, 14, M_shapeParentNode); board.picbox.Controls.Add(n); displayBorderNode(n); idnode++; isExisted = false; listNode.Clear(); //Add List listNode.Add(n); return(board); }
private void btnDetele_Click(object sender, EventArgs e) { if (name == "") { MessageBox.Show("Choose a name, please !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { int idboard = STORAGEcontroller.getIDBoard(name); if (TOPICcontroller.deleteNode(idboard) && BOARDcontroller.deleteBoardAndStorage(idboard)) { showStorageOnListView(); mindmap.board.Dispose(); mindmap.Controls.Add(mindmap.createBoardAndMainNode()); MessageBox.Show("Remove successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Remove failure!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private List <Node> addNodeToBoard(BOARD board) { mindmap.createBoard(board); List <Node> listNode = new List <Node>(); List <int> idParents = new List <int>(); foreach (TOPIC topic in TOPICcontroller.getListTopic(board.ID)) { Color bcolor = ColorTranslator.FromHtml(topic.BACKCOLOR); Color fcolor = ColorTranslator.FromHtml(topic.FORECOLOR); Color pcolor = ColorTranslator.FromHtml(topic.COLOR_PATH); mPath path = new mPath(topic.SIZE_PATH, pcolor, topic.STYLE_PATH); bool flag = false; foreach (Node n in listNode) { if (topic.ID_PARENT == n.id) { Node node = mindmap.createNode(topic.ID, topic.LABEL_TP, new Point(topic.POS_X, topic.POS_Y), new Size(topic.WIDTH, topic.HEIGHT), bcolor, fcolor, path, (float)topic.SIZE, n, topic.TEXT_SIZE, topic.SHAPE, topic.FONT); mindmap.board.picbox.Controls.Add(node); listNode.Add(node); flag = true; break; } } if (!flag) { Node node = mindmap.createNode(topic.ID, topic.LABEL_TP, new Point(topic.POS_X, topic.POS_Y), new Size(topic.WIDTH, topic.HEIGHT), bcolor, fcolor, path, (float)topic.SIZE, null, topic.TEXT_SIZE, topic.SHAPE, topic.FONT); mindmap.board.picbox.Controls.Add(node); listNode.Add(node); } } return(listNode); }
public void update() { //storage STORAGE storage = new STORAGE(); storage.ID_BOARD = mindmap.board.id; storage.NAME_S = STORAGEcontroller.getNameStorage(storage.ID_BOARD); storage.DATE_MODIFIED = DateTime.Now; //board BOARD board = new BOARD(); board.ID = storage.ID_BOARD; board.WIDTH = mindmap.board.picbox.Width; board.HEIGHT = mindmap.board.picbox.Height; board.COLOR = HexConverter(mindmap.board.picbox.BackColor); //node TOPICcontroller.removeNode(convertNodeToTopic(board, mindmap.listDelete)); mindmap.listDelete.Clear(); List <TOPIC> existTopics = new List <TOPIC>() { }; existTopics = TOPICcontroller.getListTopic(board.ID); List <TOPIC> updateTopics = new List <TOPIC>(); List <TOPIC> newTopics = new List <TOPIC>(); newTopics = convertNodeToTopic(board, this.listNode); foreach (TOPIC topic in newTopics.ToList()) { foreach (TOPIC etopic in existTopics.ToList()) { if (topic.ID == etopic.ID) { updateTopics.Add(topic); newTopics.Remove(topic); } } } TOPICcontroller.updateListTopic(updateTopics); TOPICcontroller.addListTopic(newTopics, board.ID); BOARDcontroller.updateBoard(board); if (STORAGEcontroller.updateStorage(storage)) { MessageBox.Show("saved successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void saveListNode(BOARD board) { TOPICcontroller.addListTopic(convertNodeToTopic(board, this.listNode)); }