Hi,
does anybody know how to call a WindowsProgressDialog in a process plugin?
I always get this error: System.InvalidCastException: Specified cast is not valid.
Here is my code:
It seeme that this line causes trouble:
What's wrong?
Thanks!!
does anybody know how to call a WindowsProgressDialog in a process plugin?
I always get this error: System.InvalidCastException: Specified cast is not valid.
Here is my code:
Code:
Imports MediaPortal.Dialogs
Public Class DialogProgressPlugin
Implements MediaPortal.GUI.Library.IPlugin, MediaPortal.GUI.Library.ISetupForm
Public Const WINDOW_DialogProgressPLUGIN = 6202 'a window ID shouldn't be needed when a non visual plugin ?!
Private EPGTimer As System.Threading.Timer
Public Sub Start() Implements MediaPortal.GUI.Library.IPlugin.Start
Dim timerDelegate As System.Threading.TimerCallback = AddressOf WindowsProgressDialog
EPGTimer = New System.Threading.Timer(timerDelegate, Nothing, 500, 15000)
End Sub
Public Sub WindowsProgressDialog(ByVal stateInfo As Object)
'Create dialog to show progress
Try
Dim dlgProgress As MediaPortal.Dialogs.GUIDialogProgress = CType(MediaPortal.GUI.Library.GUIWindowManager.GetWindow(CType(MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_DIALOG_PROGRESS, Integer)), MediaPortal.Dialogs.GUIDialogProgress)
If (Not dlgProgress Is Nothing) Then
dlgProgress.SetHeading("DialogHeading")
dlgProgress.SetLine(1, "DialogLine1")
dlgProgress.SetLine(2, "DialogLine2")
dlgProgress.SetLine(3, "DialogLine3")
dlgProgress.StartModal(MediaPortal.GUI.Library.GUIWindowManager.ActiveWindow)
dlgProgress.SetPercentage(0)
dlgProgress.Progress()
dlgProgress.ShowProgressBar(True)
End If
Dim iCounter As Integer = 0
While iCounter <= 100
dlgProgress.SetPercentage(iCounter)
Threading.Thread.Sleep(100)
iCounter += 1
End While
dlgProgress.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Public Sub [Stop]() Implements MediaPortal.GUI.Library.IPlugin.Stop
End Sub
Public Function Author() As String Implements MediaPortal.GUI.Library.ISetupForm.Author
Return "STSC"
End Function
Public Function CanEnable() As Boolean Implements MediaPortal.GUI.Library.ISetupForm.CanEnable
Return True
End Function
Public Function DefaultEnabled() As Boolean Implements MediaPortal.GUI.Library.ISetupForm.DefaultEnabled
Return True
End Function
Public Function Description() As String Implements MediaPortal.GUI.Library.ISetupForm.Description
Return "DialogProgress"
End Function
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 = "DialogProgress"
strButtonImage = ""
strButtonImageFocus = ""
strPictureImage = ""
Return False
End Function
Public Function GetWindowId() As Integer Implements MediaPortal.GUI.Library.ISetupForm.GetWindowId
Return WINDOW_DialogProgressPLUGIN
End Function
Public Function HasSetup() As Boolean Implements MediaPortal.GUI.Library.ISetupForm.HasSetup
Return False
End Function
Public Function PluginName() As String Implements MediaPortal.GUI.Library.ISetupForm.PluginName
Return "DialogProgress"
End Function
Public Sub ShowPlugin() Implements MediaPortal.GUI.Library.ISetupForm.ShowPlugin
'no setup form, therefore nothing to do
End Sub
End Class
It seeme that this line causes trouble:
Dim dlgProgress As MediaPortal.Dialogs.GUIDialogProgress = CType(MediaPortal.GUI.Library.GUIWindowManager.GetWindow(CType(MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_DIALOG_PROGRESS, Integer)), MediaPortal.Dialogs.GUIDialogProgress)
What's wrong?
Thanks!!