您好我想制作一款不断使用相机LED的应用。我已经看到了一些这样做的例子,但我无法让它们工作,因为我需要它们在VB中。我对C#代码持开放态度,我将自己转换。另外我知道你需要windows.phone.media.extended.dll程序集。我已设法转储仿真器图像,但我不确定程序集是否有效。我怎样才能使用反射?
如何将以下代码转换为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 :(得分: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中定义,不确定是否需要它。