2012-03-18 50 views
0

喜的LED手電筒/手電筒應用程序我想要使用相機的LED不斷的應用程序。我見過一些這樣做的例子,但我無法讓他們工作,因爲我需要他們在VB中。我願意轉換自己的C#代碼。另外我知道你需要windows.phone.media.extended.dll程序集。我已經設法轉儲emulater圖像,但我不確定程序集是否可以工作。我如何使用反射?如何使Windows手機(Visual Studio中)


如何將以下代碼轉換爲vb?

private void VideoCamera_Initialized(object sender, object eventArgs) 
{ 
    if (Initialized != null) 
    { 
     Initialized.Invoke(this, new EventArgs()); 
    } 
} 

public bool LampEnabled 
{ 
    get { return (bool)_videoCameraLampEnabledPropertyInfo.GetGetMethod().Invoke(_videoCamera, new object[0]); } 
    set { _videoCameraLampEnabledPropertyInfo.GetSetMethod().Invoke(_videoCamera, new object[] { value }); } 
} 
+0

它是一個學習項目的一部分 – Matt9Atkins 2012-03-18 00:24:27

+0

好吧,你見過這個職位?你已經找到的樣品有什麼問題? – 2012-03-18 00:28:02

+1

好吧,我下載了本教程的源代碼 - http://www.locked.nl/wp7-flashlight-getting-started - 我嘗試在VB中編寫它,但有一些錯誤,但現在它的錯誤是免費的,但它不工作。嘗試轉換時顯然有些問題。這是我爲什麼我找對VB – Matt9Atkins 2012-03-18 00:32:47

回答

0

這裏是你粘貼轉換爲VB代碼,不知道這是100%正確的

Private Sub VideoCamera_Initialized(sender As Object, eventArgs As Object) 
If Initialized IsNot Nothing Then 
    Initialized.Invoke(Me, New EventArgs()) 
End If 
End Sub 

Public Property LampEnabled() As Boolean 
Get 
    Return CBool(_videoCameraLampEnabledPropertyInfo.GetGetMethod().Invoke(_videoCamera, New Object(-1) {})) 
End Get 
Set 
    _videoCameraLampEnabledPropertyInfo.GetSetMethod().Invoke(_videoCamera, New Object() {value}) 
End Set 
End Property 

下面是一些代碼,我從一個樣品拿到並將其轉化

Dim cam As VideoCamera = Nothing 
cam = New VideoCamera() 
cam.Initialized += Function(s,e) 
    cam.LampEnabled = True 
    cam.StartRecording() 
End Function 

vCam.SetSource(cam) 

New Thread(Function() 
    Try 
    Dim isf = IsolatedStorageFile.GetUserStoreForApplication() 
    Dim files = isf.GetFileNames() 
    For Each file As var In files 
    Debug.WriteLine("Deleting... " & Convert.ToString(file)) 
    isf.DeleteFile(file) 
    Next 
    Catch ex As Exception 
    Debug.WriteLine("Error cleaning up isolated storage: " & ex) 
    End Try 
End Function).Start() 

cam.StartRecording() 

VCAM在xaml中定義,不確定是否需要它。

相關問題