public void DrawCloseTo(object sender, RectangleSelectedEventArgs args) { var actionBoxWidth = Width; var actionBoxHeight = Height; var roomAboveSelection = args.Selection.Y; var x = args.Selection.Right - actionBoxWidth; if (roomAboveSelection >= actionBoxHeight) { var y = args.Selection.Y - actionBoxHeight; Location = new Point(x, y); Visible = true; return; } var roomBelowSelection = args.CanvasSize.Height - args.Selection.Bottom; if (roomBelowSelection >= actionBoxHeight) { var y = args.Selection.Bottom; Location = new Point(x, y); Visible = true; } }