检查Visual Studio中的位置是否空闲

时间:2018-03-11 21:13:33

标签: visual-studio c++-cli

我设法创建了一个图片框数组。

private: static array<System::Windows::Forms::PictureBox^>^ pictures = (gcnew array<System::Windows::Forms::PictureBox^>(64));

现在,如果某个位置(coordX,coordY)是空闲的,我想生成一个Picture Box。有没有办法做到这一点?

1 个答案:

答案 0 :(得分:0)

你需要一个矩形交叉算法然后你做这样的事情

var desiredX = ?;
var desiredY = ?;
var desiredW = ?;
var desiredH = ?;
var intersect = false;

foreach(var picture in pictures){
   if(picture intersect(desiredX, desiredY, desiredW, desiredH)){
     intersect = true;
     break;
   }
}

if(!intersect){
  //add new picture here
  pictures.add(newPicture);
}

For intersect algoritm you can look here