Esempio 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)
        {
            int index = globalIL.Images.IndexOfKey(nodeImagePath);

            if (index < 0)
            {
                index = globalIL.Images.IndexOfKey(nodeType);

                if (index < 0)
                {
                    if (globalIL.Images.Count >= 1)
                    {
                        StringEnumerator keys = globalIL.Images.Keys.GetEnumerator();
                        keys.MoveNext();
                        index = globalIL.Images.IndexOfKey(keys.Current); // 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(labelFontSize, nodeID, linkID, nodeName, nodeType, index, diskPoint);
                    newNode.Functions = nodeFunctions;
                }
                else // not found, use base values
                {
                    newNode = new DiagramNode(labelFontSize, nodeID, linkID, nodeName, nodeType, index, 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(labelFontSize, nodeID, linkID, nodeName, nodeType, index, 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);
        }
Esempio n. 2
0
        // Convert dragged objects into go objects, if applicable
        private GoObject GetGoObjectFromDrag(DragEventArgs evt)
        {
            IDataObject data = evt.Data;
            List<ProcessingNode> treeNodes = (List<ProcessingNode>)data.GetData(typeof(List<ProcessingNode>));
            if (treeNodes != null && treeNodes is List<ProcessingNode>)
            {
                Point screenPnt = new Point(evt.X, evt.Y);
                Point viewPnt = PointToClient(screenPnt);
                PointF convertedForDocument = ConvertViewToDoc(viewPnt);
                docPnt = new Point((int)convertedForDocument.X, (int)convertedForDocument.Y);

                if (treeNodes.Count > 0)
                {
                    ProcessingNode first = treeNodes[0];

                    int imageIndex = this.ImageList.Images.Keys.IndexOf(first.NodeType);
                    if (imageIndex < 0)
                    {
                        imageIndex = this.ImageList.Images.Keys.IndexOf(first.ImageKey);
                        if (imageIndex < 0)
                        {
                            return null;
                        }
                    }

                    DiagramNode node = new DiagramNode(
                        labelFontSize,
                        first.NodeID,
                        first.Name,
                        first.NodeType,
                        imageIndex,
                        //first.TreeView.ImageList,
                        //imageIndex,
                        docPnt);

                    return node;
                }
                return null;
            }
            else return null;
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        private void DeleteDiagramNode(DiagramNode node)
        {
            StreamReader xmlStream = LoadDiagramsXML();

            XmlNode delete = currentDoc.SelectSingleNode(String.Format("/Nodes/Node[@ID='{1}'][@DiagramName='{0}'][@RootID='{2}']", diagramName, node.NodeID, RootID));

            if (delete != null && root != null)
            {
                root.RemoveChild(delete);
            }

            UnloadDiagramsXML(xmlStream, true);
        }