private void MainScriptingPanel_MouseClick(object sender, MouseEventArgs e) //Show node search bar { if (e.Button == MouseButtons.Right) { if (createNodeSearchBar != null) { createNodeSearchBar.Dispose(); } createNodeSearchBar = new CreateNodeSearchBar(e.Location, this); MainScriptingPanel.Controls.Add(createNodeSearchBar); createNodeSearchBar.partPressed += SpawnNode; firstSelectedNode = null; firstSelectedPin = null; } else { firstSelectedNode = null; firstSelectedPin = null; if (createNodeSearchBar != null) { createNodeSearchBar.Dispose(); } createNodeSearchBar = null; } MainScriptingPanel.Refresh(); }
private void MainScriptingPanel_MouseMove(object sender, MouseEventArgs e) { if (firstSelectedPin != null || firstSelectedNode != null) { MainScriptingPanel.Refresh(); } }
void PinPressed(BasePin _pinPressed) { if (firstSelectedPin == null) { firstSelectedPin = _pinPressed; } else { if (_pinPressed.pinType == firstSelectedPin.pinType && _pinPressed.pinRole != firstSelectedPin.pinRole) { _pinPressed.otherConnectedPin = firstSelectedPin; firstSelectedPin.otherConnectedPin = _pinPressed; firstSelectedPin = null; MainScriptingPanel.Refresh(); } } }
private void MainScriptingPanel_Paint(object sender, PaintEventArgs e) //Paint connections between pins { Graphics g; g = MainScriptingPanel.CreateGraphics(); Pen myPen = new Pen(BasePin.GetPinColor(typeof(ExecutionPin))); myPen.Width = 2; foreach (BaseNode n in currentNodes) //Painting lines { foreach (BasePin p in n.inputPins) //Paint from input { if (p.otherConnectedPin != null) { myPen.Color = BasePin.GetPinColor(p.pinType); Point pLoc = MainScriptingPanel.PointToClient(n.PointToScreen(p.Location)); Point oLoc = MainScriptingPanel.PointToClient(p.otherConnectedPin.Parent.PointToScreen(p.otherConnectedPin.Location)); g.DrawLine(myPen, pLoc.X, pLoc.Y, oLoc.X, oLoc.Y); } } } if (firstSelectedPin != null) //Draw line if second pin not selected { myPen.Color = BasePin.GetPinColor(firstSelectedPin.pinType); Point pLoc = MainScriptingPanel.PointToClient(firstSelectedPin.Parent.PointToScreen(firstSelectedPin.Location)); Point mLoc = MainScriptingPanel.PointToClient(Control.MousePosition); g.DrawLine(myPen, pLoc.X, pLoc.Y, mLoc.X, mLoc.Y); } if (firstSelectedNode != null) //Moving node { firstSelectedNode.Location = MainScriptingPanel.PointToClient(Control.MousePosition); } g.Dispose(); myPen.Dispose(); }
private void StartMovingNode(object sender, MouseEventArgs e) //Start moving node { firstSelectedNode = (BaseNode)sender; MainScriptingPanel.Refresh(); }
private void StopMovingNode(object sender, MouseEventArgs e) //Stop moving node { firstSelectedNode = null; MainScriptingPanel.Refresh(); }