如何制作Windows手机的led手电筒/手电筒应用程序(Visual Studio)

问题描述 投票:0回答:1

嗨,我想制作一个不断使用相机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 }); }
}
c# vb.net windows-phone-7 video video-capture
1个回答
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中定义,不确定是否需要它。

© www.soinside.com 2019 - 2024. All rights reserved.