void MoveFindDialog(Rectangle selection) { Rectangle r = this.Bounds; if (r.IntersectsWith(selection)) { // find smallest adjustment (left,right,up,down) that still fits on screen. List <Adjustment> list = new List <Adjustment>(); list.Add(new Adjustment(Direction.Up, this, selection)); list.Add(new Adjustment(Direction.Down, this, selection)); list.Add(new Adjustment(Direction.Left, this, selection)); list.Add(new Adjustment(Direction.Right, this, selection)); list.Sort(); Adjustment smallest = list[0]; smallest.AdjustDialog(); return; } }