public Pair <int, int> GraphToScreen(FDGVector2 iPos) { Pair <int, int> retPair = new Pair <int, int>(); retPair.first = (int)(iPos.x + (((float)(panelRight - panelLeft)) / 2.0f)); retPair.second = (int)(iPos.y + (((float)(panelBottom - panelTop)) / 2.0f)); return(retPair); }
public FDGVector2 ScreenToGraph(Pair <int, int> iScreenPos) { FDGVector2 retVec = new FDGVector2(); retVec.x = ((float)iScreenPos.first) - (((float)(panelRight - panelLeft)) / 2.0f); retVec.y = ((float)iScreenPos.second) - (((float)(panelBottom - panelTop)) / 2.0f); return(retVec); }
private void pDrawPanel_MouseMove(object sender, MouseEventArgs e) { if (clickedNode != null) { FDGVector2 vec = ScreenToGraph(new Pair <int, int>(e.Location.X, e.Location.Y)); clickedNode.Pinned = true; m_fdgPhysics.GetPoint(clickedNode).position = vec; } else { foreach (KeyValuePair <Node, GridBox> keyPair in m_fdgBoxes) { if (keyPair.Value.boxRec.IntersectsWith(new Rectangle(e.Location, new Size(1, 1)))) { keyPair.Value.boxType = BoxType.Pinned; } else { keyPair.Value.boxType = BoxType.Normal; } } } }