【问题标题】:How to make an led torch/flashlight app for windows phone (Visual Studio)如何为 Windows 手机制作 LED 手电筒/手电筒应用程序(Visual Studio)
【发布时间】:2012-03-18 00:09:30
【问题描述】:

您好,我想制作一个不断使用相机 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】:

这是您粘贴的转换为 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 中定义的,不确定是否需要。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-17
    • 1970-01-01
    • 2021-08-28
    • 1970-01-01
    • 2016-12-13
    • 2021-11-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多