2015-01-07 23 views
-2
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的任何問題嗎?

+3

請標題相關。 – user2864740

回答

5

是的。你的班級不公開。試着讓Class1公開,我覺得它會解決你的問題。至於爲什麼,如果你沒有明確提供一個訪問修飾符,一個類將默認爲內部。由於您在外部程序集中引用了您的類,因此Intellisense無法幫助您找到它,因爲您的外部調用程序實際上無法訪問它。

+0

非常感謝! – user4421334

+0

@ user4421334我的榮幸。我更新了我的答案,給你更多的背景。如果它解決了你的問題,選擇正確的答案將不勝感激:) –

相關問題