C# 从C到VB.NET的转换
试图将第一个测试代码翻译成VB.NET,但它不起作用。它可以编译,但不能按计划工作 我猜它与Implements语句有关,或者与类如何处理接口有关。作为一个全新的.NET程序员,我真的需要你的帮助,找出它为什么不工作。下面是经过转换和编辑的代码:C# 从C到VB.NET的转换,c#,vb.net,C#,Vb.net,试图将第一个测试代码翻译成VB.NET,但它不起作用。它可以编译,但不能按计划工作 我猜它与Implements语句有关,或者与类如何处理接口有关。作为一个全新的.NET程序员,我真的需要你的帮助,找出它为什么不工作。下面是经过转换和编辑的代码: Imports System Imports System.Windows.Forms Imports MediaPortal.GUI.Library Imports MediaPortal.Dialogs Namespace OurPlugin
Imports System
Imports System.Windows.Forms
Imports MediaPortal.GUI.Library
Imports MediaPortal.Dialogs
Namespace OurPlugin
Public Class Class1
#Region "ISetupForm Members"
Inherits GUIWindow
Implements ISetupForm
Public Sub New()
End Sub
' Returns the name of the plugin which is shown in the plugin menu
Public Function PluginName() As String Implements MediaPortal.GUI.Library.ISetupForm.PluginName
Return "MyFirstPlugin"
End Function
' Returns the description of the plugin is shown in the plugin menu
Public Function Description() As String Implements MediaPortal.GUI.Library.ISetupForm.Description
Return "My First Plugin"
End Function
' Returns the author of the plugin which is shown in the plugin menu
Public Function Author() As String Implements MediaPortal.GUI.Library.ISetupForm.Author
Return "YourNameHere"
End Function
' show the setup dialog
Public Sub ShowPlugin() Implements MediaPortal.GUI.Library.ISetupForm.ShowPlugin
MessageBox.Show("Nothing to configure, this is just an example")
End Sub
' Indicates whether plugin can be enabled/disabled
Public Function CanEnable() As Boolean Implements MediaPortal.GUI.Library.ISetupForm.CanEnable
Return True
End Function
' Get Windows-ID
Public Function GetWindowId() As Integer Implements MediaPortal.GUI.Library.ISetupForm.GetWindowId
' WindowID of windowplugin belonging to this setup
' enter your own unique code
Return 5678
End Function
' Indicates if plugin is enabled by default;
Public Function DefaultEnabled() As Boolean Implements MediaPortal.GUI.Library.ISetupForm.DefaultEnabled
Return True
End Function
' indicates if a plugin has it's own setup screen
Public Function HasSetup() As Boolean Implements MediaPortal.GUI.Library.ISetupForm.HasSetup
Return True
End Function
''' <summary>
''' If the plugin should have it's own button on the main menu of MediaPortal then it
''' should return true to this method, otherwise if it should not be on home
''' it should return false
''' </summary>
''' <param name="strButtonText">text the button should have</param>
''' <param name="strButtonImage">image for the button, or empty for default</param>
''' <param name="strButtonImageFocus">image for the button, or empty for default</param>
''' <param name="strPictureImage">subpicture for the button or empty for none</param>
''' <returns>true : plugin needs it's own button on home
''' false : plugin does not need it's own button on home</returns>
Public Function GetHome(ByRef strButtonText As String, ByRef strButtonImage As String, ByRef strButtonImageFocus As String, ByRef strPictureImage As String) As Boolean Implements MediaPortal.GUI.Library.ISetupForm.GetHome
strButtonText = [String].Empty
strButtonImage = [String].Empty
strButtonImageFocus = [String].Empty
strPictureImage = [String].Empty
Return False
End Function
' With GetID it will be an window-plugin / otherwise a process-plugin
' Enter the id number here again
Public Overloads Overrides Property GetID() As Integer
Get
Return 5678
End Get
Set(ByVal value As Integer)
End Set
End Property
#End Region
End Class
End Namespace
[编辑]
我只是想澄清一下。从上面粘贴的URL中,我注意到我的锚不正确。我不是在测试完整的源代码,而是仅测试此URL中的第一个测试代码:
我遇到的问题是,它不会作为插件显示在MediaPortal中。C语言中的示例工作得非常好。感觉在进入GUI部分之前,我需要完成这项工作。我不知道如何对此进行错误测试,因为它需要作为插件加载到MediaPortal中,以查看它是否正常工作。快速比较说明: 您没有定义buttonOne或buttonTwo 代码中缺少整个Init方法 我不知道GetID是5678是否有意义,但在你这方面值得做更多的研究
它到底能做什么,或者不能做什么,这正是你所期待的?C中的类是什么样的?