public static bool CanMove(Components.Component c, Vector2 pos) { if (c == null) return false; var s = c.Graphics.GetSizeRotated(c.ComponentRotation); Rectangle r1 = new Rectangle((int)pos.X, (int)pos.Y, (int)s.X, (int)s.Y); r1.Inflate(8, 8); Rectangle r2 = new Rectangle(); var j = c.getJoints(); if (j == null) return false; List<int> jcw = new List<int>();//joints connected wires for (int i = 0; i < j.Length; i++) { var a = Components.ComponentsManager.GetComponent(j[i]) as Components.Joint; if (a != null) { for (int jj = 0; jj < a.ConnectedWires.Count; jj++) { jcw.Add(a.ConnectedWires[jj].ID); } } } bool b; foreach (var c2 in Components.ComponentsManager.Components) { if (c2 == c || c2 == null || c2 is Components.EmptyComponent) continue; if (!c2.Graphics.Visible) continue; for (int i = 0; i < j.Length; i++) if (c2.ID == j[i]) goto EndCheck; for (int i = 0; i < jcw.Count; i++) if (c2.ID == jcw[i]) goto EndCheck; if (c2 is Components.Wire) if ((c2.Graphics as Components.Graphics.WireGraphics).Intersects(r1)) return false; s = c2.Graphics.GetSizeRotated(c.ComponentRotation); r2 = new Rectangle((int)c2.Graphics.Position.X, (int)c2.Graphics.Position.Y, (int)s.X, (int)s.Y); b = r2.Contains(r1); if (b && !(c2 is Components.Properties.IContainer)) return false; if (!b && r1.Intersects(r2)) return false; if (r1.Contains(r2)) return false; EndCheck: ; } return true; }