I am trying to mess around with some camera related tutorial I found on the Internet. The problem is that most of the tutorials are done in C#, whereas I need it to be in VB.NET . I have tried converting it using online converters, but it doesn't always recognise all the syntax therefore I get errors. How do I convert this into Visual Basic?
Loaded += (_, __) =>
{
Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode =
Microsoft.Phone.Shell.IdleDetectionMode.Disabled;
cam = new VideoCamera();
cam.Initialized += (___, ____) =>
{
cam.LampEnabled = true;
cam.StartRecording();
};
vCam.SetSource(cam);
new Thread(() =>
{
try
{
var isf = IsolatedStorageFile.GetUserStoreForApplication();
var files = isf.GetFileNames();
foreach (var file in files)
{
Debug.WriteLine("Deleting... " + file);
isf.DeleteFile(file);
}
}
catch (Exception ex)
{
Debug.WriteLine("Error cleaning up isolated storage: " + ex);
}
}).Start();
};
This is the code I got from the converter:
Loaded += Function(_, __)
Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode = _
Microsoft.Phone.Shell.IdleDetectionMode.Disabled
cam = New VideoCamera()
cam.Initialized += Function(___, ____)
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()
End Function
Use Roslny . The converter is presented at 00 min 55 secs.
PS: underscores are a bad idea for a variable name.
Your converter doesn't seem to know what to do with the += operator or the underscores in VB. They're wreaking havoc with the compiler.
Change
Loaded += Function(_, __)
Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode = Microsoft.Phone.Shell.IdleDetectionMode.Disabled
to
AddHandler Loaded , Function(x as Object, y as Object)
Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode = _
Microsoft.Phone.Shell.IdleDetectionMode.Disabled
and change
cam.Initialized += Function(___, ____)
to
AddHandler cam.Initialized, Function(xx as Object, yy as Object)
Note you may need to change the Object
signatures in the event handlers to match the actual event signatures, but everything else looks OK at a quick glance.
Use the following (I used Telerik Converter ):
Loaded += Function(_, __) Do
Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode = Microsoft.Phone.Shell.IdleDetectionMode.Disabled
cam = New VideoCamera()
cam.Initialized += Function(___, ____) Do
cam.LampEnabled = True
cam.StartRecording()
End Function
vCam.SetSource(cam)
New Thread(Function() Do
Try
Dim isf = IsolatedStorageFile.GetUserStoreForApplication()
Dim files = isf.GetFileNames()
For Each file As var In files
Debug.WriteLine("Deleting... " + file)
isf.DeleteFile(file)
Next
Catch ex As Exception
Debug.WriteLine("Error cleaning up isolated storage: " + ex)
End Try
End Function).Start()
End Function
I hope this helps :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.