Exemplo n.º 1
0
        public void LoadNode(int nodeID, int linkID, String nodeName, String nodeType, List<Function> nodeFunctions, String nodeImagePath, Boolean xyFromDB, ref int startX, ref int startY, Dictionary<int, DiagramNode> docNodes)
        {
            //Bitmap image = null;

            //if (nodeImages.ContainsKey(nodeImagePath))
            //{
            //    image = nodeImages[nodeImagePath];
            //}
            //else if (nodeImages.Count >= 1)
            //{
            //    IEnumerator keys = nodeImages.Keys.GetEnumerator();
            //    keys.MoveNext();
            //    image = nodeImages[keys.Current.ToString()]; // just use first key
            //}
            //else
            //{
            //    // replace with debug logging log4net
            //    MessageBox.Show("Could not load image at: " + nodeImagePath + "Diagram.cs line 499");
            //    return;
            //}

            DiagramNode newNode = null;

            if (xyFromDB == false)
            {
                Point diskPoint = this.GetPoint(nodeID);

                if (diskPoint != Point.Empty) // XY is from disk
                {
                    newNode = new DiagramNode(nodeID, linkID, nodeName, nodeType, nodeImagePath, diskPoint);
                    newNode.Functions = nodeFunctions;
                }
                else // not found, use base values
                {
                    newNode = new DiagramNode(nodeID, linkID, nodeName, nodeType, nodeImagePath, new PointF(startX, startY));
                    newNode.Functions = nodeFunctions;

                    SaveNode(newNode, false); // save to diagram XML
                    startX += 40; // and increment the base start
                }
            }
            else  // XY id from DB
            {
                // use transform
                startX = (int)m_coordinateTransformer.RetrieveX(startX);
                startY = (int)m_coordinateTransformer.RetrieveY(startY);

                newNode = new DiagramNode(nodeID, linkID, nodeName, nodeType, nodeImagePath, new PointF(startX, startY));
                newNode.Functions = nodeFunctions;
            }

            // set tooltip to help with user input
            newNode.ToolTipText = "To link:  Click and drag on a node's image to another image" + '\n' + "To move: Click and drag on a node's text label";

            docNodes.Add(nodeID, newNode);

            this.Document.Add(newNode);
        }
Exemplo n.º 2
0
        private void SaveNode(DiagramNode dgNode, Boolean parameterUpdateAfterMoveFunction)
        {
            String newX = ((int)dgNode.Location.X).ToString();
            String newY = ((int)dgNode.Location.Y).ToString();

            RecordXYToXML(dgNode.NodeID, dgNode.Functions, newX, newY, parameterUpdateAfterMoveFunction);
        }