Exemplo n.º 1
0
        private void initWebRegister()
        {
            //Initializing nodes and adding buttons accordingly

            List <AddressClass> nodeAddresses = returnNodeAddresses();

            int nodeID = 0;

            register = new WebRegister();

            foreach (AddressClass address in nodeAddresses)
            {
                NodeButton node = new NodeButton(nodeID, address, this.panel1);

                node.OnPacketReachingDestination += OnPacketReachingDestination;
                node.OnManualStep += OnManualStep;
                node.Click        += new EventHandler(node_Click);

                nodeID++;

                register.addNode(node);
            }

            findNeighbouringNodes();
        }
Exemplo n.º 2
0
        void backgroundWorker_Completed(object sender, RunWorkerCompletedEventArgs e)
        {
            isRoutingInProgress = false;
            sourceNode          = null;
            destinationNode     = null;

            updateRoutingButton();
        }
Exemplo n.º 3
0
        public void addNode(NodeButton node)
        {
            if (nodeData == null)
            {
                nodeData = new List <NodeButton>();
            }

            nodeData.Add(node);
        }
Exemplo n.º 4
0
        private void BtnReset_Click(object sender, EventArgs e)
        {
            //Clear drawing and controls
            this.panel1.Controls.Clear();
            this.panel1.Invalidate();

            isRoutingInProgress = false;
            sourceNode          = null;
            destinationNode     = null;

            initWebRegister();
            updateRoutingButton();
        }
Exemplo n.º 5
0
    private void PopulateListNode()
    {
        for (int i = 0; i < listNodes.Count; i++)
        {
            GameObject newObject = Instantiate(buttonsPrefabs[0], panelNode.transform);
            NodeButton pointer   = newObject.GetComponent <NodeButton>();

            pointer.SetController(gameObject.GetComponent <EditorController>());
            pointer.SetNode(listNodes[i]);
            pointer.SetIndex(i);

            nodeButtonList.Add(newObject);
        }
    }
Exemplo n.º 6
0
        // Node events
        private void node_Click(object sender, EventArgs e)
        {
            NodeButton node = sender as NodeButton;

            if (sourceNode == null)
            {
                sourceNode           = node;
                sourceNode.BackColor = Color.LightSteelBlue;
            }
            else if (destinationNode == null)
            {
                destinationNode           = node;
                destinationNode.BackColor = Color.LightSteelBlue;
            }

            updateRoutingButton();
        }
Exemplo n.º 7
0
        private void OnPacketReachingDestination(NodeButton node, PacketClass packet)
        {
            // Its another thread so invoke back to UI thread
            base.Invoke((Action) delegate
            {
                node.BackColor = Color.LightGreen;
                node.Text      = packet.message;

                if (GlobalVariable.IsManual && packet.packetType == PacketClass.PacketType.Acknowledgement_Type)
                {
                    isRoutingInProgress = false;
                    sourceNode          = null;
                    destinationNode     = null;

                    updateRoutingButton();
                }
            });
        }
Exemplo n.º 8
0
        public static void DrawArrow(Graphics g, Control startControl, Control endControl, Point distance, TableLayout tableLayout)
        {
            if (startControl == null || endControl == null)
            {
                return;
            }

            NodeButton btnStart = (NodeButton)startControl;
            NodeButton btnEnd   = (NodeButton)endControl;

            Point point1  = GetMiddlePoint(startControl, true);
            Point point2  = GetMiddlePoint(endControl, false);
            Pen   drawPen = btnStart.Selected && btnEnd.Selected ? _selectedPen : _regularPen;

            GraphicsPath gPath = new GraphicsPath();

            gPath.AddLine(point1, point2);
            g.FillPath(drawPen.Brush, gPath);
            g.DrawPath(drawPen, gPath);
            DirectLine dLine = new DirectLine();

            dLine.Path = gPath;
            //if (((btnEnd.Tag as IGraphItem).Parent as IGraphPath).DirectFlow[0].ID != (btnStart.Tag as GraphItem).ID)
            //{
            NodeButton btn = new NodeButton();

            btn.Text = btnStart.Text;
            btn.TableLayoutInstance = tableLayout;
            btn.StartNodeItem       = btnStart.Tag as GraphItem;
            btn.EndNodeItem         = btnEnd.Tag as GraphItem;
            btn.Tag      = GetNodeByStartEndItems(tableLayout.Graph.Paths, btnStart.Tag as GraphItem, btnEnd.Tag as GraphItem); //btnStart.Tag;
            btn.Click   += tableLayout.ChangeSelectedFileHandler;
            btn.Click   += tableLayout.PathItemClick;
            dLine.button = btn;
            //}
            //else
            //{
            //    dLine.button = btnEnd;
            //}
            gPathList.Add(dLine);

            DrawArrow(g, drawPen, point2);
        }
Exemplo n.º 9
0
 public bool UpdateNodeButton(List <int> nodeIdList, List <int> buttonIdList)
 {
     try
     {
         foreach (var NodeId in nodeIdList)
         {
             var removeList = _context.NodeButton.Where(c => c.NodeId == NodeId && !buttonIdList.Contains(c.ButtonId ?? 0)).ToList();
             if (removeList != null && removeList.Count > 0)
             {
                 _context.NodeButton.RemoveRange(removeList);
             }
             foreach (var ButtonId in buttonIdList)
             {
                 var query = _context.NodeButton.AsQueryable().FirstOrDefault(c => c.NodeId == NodeId && c.ButtonId == ButtonId);
                 if (query == null)
                 {
                     var item = new NodeButton();
                     item.NodeId      = NodeId;
                     item.ButtonId    = ButtonId;
                     item.OperateDate = DateTime.Now;
                     _context.NodeButton.Add(item);
                 }
                 //else
                 //{
                 //    query.OperateDate = DateTime.Now;
                 //}
             }
         }
         _context.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         MessageLog.WriteLog(new LogParameterModel()
         {
             ClassName  = this.GetType().ToString(),
             MethodName = "UpdateNodeButton",
             LogLevel   = ELogLevel.Warn,
             Message    = ex.Message
         });
         return(false);
     }
 }
Exemplo n.º 10
0
    public void OnMouseUpAsButton()
    {
        if (!isShown)
        {
            return;
        }

        RaycastHit2D[] hits = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

        foreach (RaycastHit2D hit in hits)
        {
            GameObject obj    = hit.collider.gameObject;
            NodeButton button = obj.GetComponent <NodeButton>();
            if (button != null)
            {
                button.OnMouseUpAsButton();
                return;
            }
        }
    }
Exemplo n.º 11
0
    public void OnMouseOver()
    {
        if (!isShown)
        {
            return;
        }

        // Transfer relevant events to buttons
        RaycastHit2D[] hits = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

        foreach (RaycastHit2D hit in hits)
        {
            GameObject obj    = hit.collider.gameObject;
            NodeButton button = obj.GetComponent <NodeButton>();
            if (button != null)
            {
                if (prev == button)
                {
                    return;
                }

                if (prev != null)
                {
                    prev.OnMouseExit();
                }
                button.OnMouseEnter();
                prev = button;
                return;
            }
        }

        // No button is being hovered over
        if (prev != null)
        {
            prev.GetComponent <NodeButton>().OnMouseExit();
            prev = null;
        }
    }
Exemplo n.º 12
0
 public virtual void OnMouseExit()
 {
     clearChildHighlights();
     prev = null;
 }
Exemplo n.º 13
0
        public bool AddOrUpdate(NodeButton item)
        {
            var szServices = new DbHelperEfSql <NodeButton>();

            return(item.NodeButtonId <= 0 ? szServices.Add(item) : szServices.Update(item, c => c.NodeButtonId == item.NodeButtonId));
        }
Exemplo n.º 14
0
 private void OnManualStep(NodeButton node, PacketClass packet)
 {
     sourceNode  = node;
     this.packet = packet;
 }