我想知道如何为以下结构定义架构:
PixelSearch()
到目前为止,我有:
private void btnLogin_Click(object sender, EventArgs e)
{
// takes a snapshot of the screen
Bitmap bmpScreenshot = Screenshot();
// makes the background of the form a screenshot of the screen
this.BackgroundImage = bmpScreenshot;
// find the login button and check if it exists
Point location;
bool success = FindBitmap(Properties.Resources.pictureWhichIamSearching, bmpScreenshot, out location);
// check if it found the bitmap
if (success == false)
{
MessageBox.Show("Couldn't find the login button");
return;
}
// move the mouse to login button
//location = ;
Cursor.Position = location;
// click
MouseClick();
}
private void MouseClick()
{
mouse_event((uint)MouseEventFlags.LEFTDOWN, 0, 0, 0, 0);
//Thread.Sleep((new Random()).Next(20, 30));
mouse_event((uint)MouseEventFlags.LEFTUP, 0, 0, 0, 0);
}
private Bitmap Screenshot()
{
// this is where we will store a snapshot of the WHOLE screen
Bitmap bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
// creates a graphics object so we can draw the screen in the bitmap (bmpScreenshot)
Graphics g = Graphics.FromImage(bmpScreenshot);
// copy from screen into the bitmap we created
g.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size);
// return the screenshot
return bmpScreenshot;
}
private bool FindBitmap(Bitmap bmpNeedle, Bitmap bmpHaystack, out Point location)
{
for (int outerX = 0; outerX < bmpHaystack.Width - bmpNeedle.Width; outerX++)
{
for (int outerY = 0; outerY < bmpHaystack.Height - bmpNeedle.Height; outerY++)
{
for (int innerX = 0; innerX < bmpNeedle.Width; innerX++)
{
for (int innerY = 0; innerY < bmpNeedle.Height; innerY++)
{
Color cNeedle = bmpNeedle.GetPixel(innerX, innerY);
Color cHaystack = bmpHaystack.GetPixel(innerX + outerX, innerY + outerY);
if (cNeedle.R != cHaystack.R || cNeedle.G != cHaystack.G || cNeedle.B != cHaystack.B)
{
goto notFound;
}
}
}
location = new Point(outerX + 95, outerY);
return true;
notFound:
continue;
}
}
location = Point.Empty;
return false;
}
entity2a和entity2b都遵循相同的架构,但是具有不同的对象名称,entity1可以包含除entity2值对象以外的其他字段。
我的entity1正常化了,但是我没有得到任何entity2,它们仍然嵌套在我的entity1下。我是否正确定义了架构?