using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EyesLib
{
class Class1
{
public void drawEyes(int lookAtX, int lookAtY, int width, int height, Graphics eyeArea)
{
int xleft = 0, yleft = 0, xright = 0, yright = 0, xpleft = 0, ypleft = 0, xpright = 0, ypright = 0, reye = 0, rpupil = 0;
xleft = width/3;
yleft = height/2;
xright = 2 * width/3;
yright = height/2;
reye = width/9;
rpupil = reye/2;
Bitmap bufl = new Bitmap(width, height);
Graphics g = Graphics.FromImage(bufl);
g.FillEllipse(Brushes.White, xleft - reye, yleft - reye, 2 * reye, 2 * reye);
g.FillEllipse(Brushes.White, xright - reye, yright - reye, 2 * reye, 2 * reye);
g.DrawEllipse(Pens.Black, xleft - reye, yleft - reye, 2 * reye, 2 * reye);
g.DrawEllipse(Pens.Black, xright - reye, yright - reye, 2 * reye, 2 * reye);
if ((lookAtX != xleft) || (lookAtY != yleft))
{
xpleft = (int)Math.Round(xleft + (reye - rpupil)/(Math.Sqrt(Math.Pow(lookAtX - xleft, 2) + Math.Pow(lookAtY - yleft, 2))) * (lookAtX - xleft));
ypleft = (int)Math.Round(yleft + (reye - rpupil)/(Math.Sqrt(Math.Pow(lookAtX - xleft, 2) + Math.Pow(lookAtY - yleft, 2))) * (lookAtY - yleft));
}
else
{
xpleft = xleft;
ypleft = yleft;
}
if ((lookAtX != xright) || (lookAtY != yright))
{
xpright = (int)Math.Round(xright + (reye - rpupil)/(Math.Sqrt(Math.Pow(lookAtX - xright, 2) + Math.Pow(lookAtY - yright, 2))) * (lookAtX - xright));
ypright = (int)Math.Round(yright + (reye - rpupil)/(Math.Sqrt(Math.Pow(lookAtX - xright, 2) + Math.Pow(lookAtY - yright, 2))) * (lookAtY - yright));
}
else
{
xpright = xright;
ypright = yright;
}
g.FillEllipse(Brushes.Black, xpleft - rpupil, ypleft - rpupil, 2 * rpupil, 2 * rpupil);
g.FillEllipse(Brushes.Black, xpright - rpupil, ypright - rpupil, 2 * rpupil, 2 * rpupil);
eyeArea.DrawImage(bufl, 0, 0);
g.Dispose();
}
public void closeEyes(int width, int height, Graphics eyeArea)
{
int xleft = 0, yleft = 0, xright = 0, yright = 0, reye = 0, rpupil = 0;
xleft = width/3;
yleft = height/2;
xright = 2 * width/3;
yright = height/2;
reye = width/9;
rpupil = reye/2;
eyeArea.FillEllipse(Brushes.Gray, xleft - reye, yleft - reye, 2 * reye, 2 * reye);
eyeArea.FillEllipse(Brushes.Gray, xright - reye, yright - reye, 2 * reye, 2 * reye);
}
}
}
儘管構建正確,但在引用時它不會被Visual Studio識別。 這也不是一個.NET版本的問題。我嘗試了所有4/4.5 /客戶端配置文件等。我甚至redid該項目,我連接DLL並仍然存在的問題。你能發現這個DLL的任何問題嗎?
請標題相關。 – user2864740