Exemple #1
0
 private void canvas_MouseDown(object sender, MouseEventArgs e)
 {
     if (selectedNode != null)
     {
         updateNode();
         updateConnectionLine();
     }
     originalX    = mouseX;
     originalY    = mouseY;
     isMouseDown  = true;
     selectedNode = null;
     for (int i = nodeList.Count; i > 0; i--)
     {
         if (hasClickedNode(nodeList[i].XPosition, nodeList[i].YPosition, nodeList[i].Size, mouseX, mouseY))
         {
             if (DEBUG)
             {
                 Console.WriteLine("Node with id " + nodeList[i].getId() + " selected.");
             }
             selectedNode = nodeList[i];
             selectNode(selectedNode);
             break;
         }
     }
 }
Exemple #2
0
 public void selectNode(BubbleMapNode node)
 {
     selectedNodeBox.Visible    = true;
     captionTextbox.Text        = node.Caption;
     sizeTextbox.Value          = node.Size;
     bgColorPreview.BackColor   = ColorTranslator.FromHtml(node.BackgroundColor);
     textSizeTextbox.Value      = node.TextSize;
     textColorPreview.BackColor = ColorTranslator.FromHtml(node.TextColor);
 }
Exemple #3
0
 private void addChildNodeButton_Click(object sender, EventArgs e)
 {
     if (selectedNode != null)
     {
         BubbleMapNode newNode = new BubbleMapNode(nodeList.Count + 1, "New Node", 0, 0, nodeList.Count, 150, "#333333", "#ffffff", 12);
         nodeList.Add(nodeList.Count + 1, newNode);
         NodeConnection newConnection = new NodeConnection(nodeConnectionList.Count + 1, selectedNode.getId(), newNode.getId(), (int)connectionLineWidthTextbox.Value, ColorTranslator.ToHtml(lineColorPreview.BackColor));
         nodeConnectionList.Add(newConnection.getId(), newConnection);
         selectNode(newNode);
     }
     canvas.Invalidate();
 }
Exemple #4
0
        private void cloneNodeButton_Click(object sender, EventArgs e)
        {
            BubbleMapNode newNode = new BubbleMapNode(nodeList.Count + 1, selectedNode.Caption, selectedNode.XPosition + 50, selectedNode.YPosition + 50, nodeList.Count, selectedNode.Size, selectedNode.BackgroundColor, selectedNode.TextColor, selectedNode.TextSize);

            nodeList.Add(nodeList.Count + 1, newNode);
            selectNode(newNode);
            if (DEBUG)
            {
                Console.WriteLine("New node added, " + nodeList.Count + " in the node list.");
            }
            updateNode();
            updateConnectionLine();
            canvas.Invalidate();
        }
Exemple #5
0
        private void addNodeButton_Click(object sender, EventArgs e)
        {
            if (DEBUG)
            {
                Console.WriteLine("Adding a new node.");
            }
            //nodeList.Add(new BubbleMapNode(nodeList.Count + 1, "New Node", 0, 0, nodeList.Count, 200, "#333333", "#ffffff", 12));
            BubbleMapNode newNode = new BubbleMapNode(nodeList.Count + 1, "New Node", 0, 0, nodeList.Count, 150, "#333333", "#ffffff", 12);

            nodeList.Add(nodeList.Count + 1, newNode);
            selectNode(newNode);
            if (DEBUG)
            {
                Console.WriteLine("New node added, " + nodeList.Count + " in the node list.");
            }
            showConnectionLineBox();
            canvas.Invalidate();
        }
Exemple #6
0
 private void deleteNodeButton_Click(object sender, EventArgs e)
 {
     if (selectedNode != null)
     {
         for (int i = selectedNode.getId(); i <= nodeList.Count; i++)
         {
             if (nodeList.ContainsKey(i + 1))
             {
                 nodeList[i] = nodeList[i + 1];
                 nodeList[i].setId(i);
             }
             else
             {
                 nodeList.Remove(i);
             }
         }
         List <int> connectionsToDelete = new List <int>();
         foreach (NodeConnection connection in nodeConnectionList.Values)
         {
             if (connection.getParentNodeId() == selectedNode.getId() || connection.getChildNodeId() == selectedNode.getId())
             {
                 connectionsToDelete.Add(connection.getId());
                 continue;
             }
             if (connection.getParentNodeId() > selectedNode.getId())
             {
                 connection.setParentNodeId(connection.getParentNodeId() - 1);
             }
             if (connection.getChildNodeId() > selectedNode.getId())
             {
                 connection.setChildNodeId(connection.getChildNodeId() - 1);
             }
         }
         foreach (int id in connectionsToDelete)
         {
             nodeConnectionList.Remove(id);
         }
         selectedNode            = null;
         selectedNodeBox.Visible = false;
     }
     showConnectionLineBox();
     canvas.Invalidate();
 }
Exemple #7
0
        private void canvas_Paint(object sender, PaintEventArgs e)
        {
            // Initialize the graphics and set the smoothing mode to HQ
            Graphics g = e.Graphics;

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            SolidBrush brush;
            Pen        pen;

            // Draw node connections
            foreach (NodeConnection connection in nodeConnectionList.Values)
            {
                Color nodeConnectionColor = ColorTranslator.FromHtml(connection.Color);
                brush = new SolidBrush(nodeConnectionColor);
                pen   = new Pen(brush, connection.Size);
                BubbleMapNode parentNode      = nodeList[connection.getParentNodeId()];
                BubbleMapNode childNode       = nodeList[connection.getChildNodeId()];
                Point         parentNodePoint = new Point(parentNode.XPosition + parentNode.Size / 2, parentNode.YPosition + parentNode.Size / 2);
                Point         childNodePoint  = new Point(childNode.XPosition + childNode.Size / 2, childNode.YPosition + childNode.Size / 2);
                g.DrawLine(pen, parentNodePoint, childNodePoint);
            }

            // Draw nodes
            foreach (BubbleMapNode node in nodeList.Values)
            {
                // Draw the shape of the node itself
                //if (DEBUG) Console.WriteLine(node.ToString());
                Color nodeBackgroundColor = ColorTranslator.FromHtml(node.BackgroundColor);
                brush = new SolidBrush(nodeBackgroundColor);
                g.FillEllipse(brush, node.XPosition, node.YPosition, (node.Size), (node.Size));

                // Draw the caption inside of the node
                Color nodeTextColor = ColorTranslator.FromHtml(node.TextColor);
                brush = new SolidBrush(nodeTextColor);
                Font         captionFont = new Font("Arial", node.TextSize, FontStyle.Regular, GraphicsUnit.Point);
                StringFormat sf          = new StringFormat();
                sf.LineAlignment = StringAlignment.Center;
                sf.Alignment     = StringAlignment.Center;
                RectangleF textRect = new RectangleF(node.XPosition, node.YPosition, node.Size, node.Size);
                g.DrawString(node.Caption, captionFont, brush, textRect, sf);
            }
        }