2012-03-18 51 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中定义,不确定是否需要它。

相关问题