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(); }
void backgroundWorker_Completed(object sender, RunWorkerCompletedEventArgs e) { isRoutingInProgress = false; sourceNode = null; destinationNode = null; updateRoutingButton(); }
public void addNode(NodeButton node) { if (nodeData == null) { nodeData = new List <NodeButton>(); } nodeData.Add(node); }
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(); }
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); } }
// 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(); }
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(); } }); }
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); }
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); } }
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; } } }
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; } }
public virtual void OnMouseExit() { clearChildHighlights(); prev = null; }
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)); }
private void OnManualStep(NodeButton node, PacketClass packet) { sourceNode = node; this.packet = packet; }