2012-03-20 14 views
1

私はインターネット上で見つけたカメラ関連のチュートリアルをいくつか取り上げようとしています。問題は、チュートリアルのほとんどがC#で行われているのに対し、VB.NETにする必要があることです。私はオンラインコンバータを使用して変換しようとしましたが、すべての構文を認識するとは限らないため、エラーが発生します。これをVisual Basicに変換するにはどうすればよいですか?このメソッドをC#からVB.NETに変換する方法

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(); 
    }; 

これは、私は、コンバータからもらったコードです:

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 
+0

Iveはコンバータを使用しており、文字通りどこでもエラーが表示されています。 – Matt9Atkins

+0

コンバータで何が行われたのかをお伝えすることをお勧めします。 –

+0

Iveがコンバーターコード – Matt9Atkins

答えて

0

使用Roslny。コンバータは00分55秒で表示されます。

PS:変数名にはアンダースコアが悪い考えです。

+0

アンダースコアは、決して参照されない関数パラメータに名前を付けるために使われますが、彼はコードを書かなかったので、おそらく名前を付けなかったでしょう。 – Gabe

-1

(私は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 

私はこれが役に立てば幸い:)

+0

Visual Studioでのあらゆる種類のエラー:( – Matt9Atkins

+1

イベントハンドラを追加するときに+ =は動作しないと思われます.AddHandler文を使用する必要があります。 –

0

をあなたのコンバータは+ =演算子またはアンダースコアでで何をすべきかを知っていないようですVB。彼らはコンパイラを混乱させている。

AddHandler Loaded , Function(x as Object, y as Object) 
    Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode = _ 
     Microsoft.Phone.Shell.IdleDetectionMode.Disabled 

AddHandler cam.Initialized, Function(xx as Object, yy as Object) 

cam.Initialized += Function(___, ____) 

を変更する

変更

Loaded += Function(_, __) 
    Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode = Microsoft.Phone.Shell.IdleDetectionMode.Disabled 

実際のイベントシグネチャと一致するようにイベントハンドラ内のObjectシグネチャを変更する必要があるかもしれませんが、他のものはすばやく見えます。

関連する問題