MediaPortal Forums HTPC/MediaCenter

Go Back   MediaPortal Forum » MediaPortal 1 » Community Skins and Plugins » Plugins


Plugins Plugins developed and maintained by users. Want to create your own plugin? Start a thread in here.

Reply
 
Thread Tools Display Modes
Old 2005-02-27, 20:50   #1 (permalink)
Portal Member
 
Join Date: Dec 2004
Location: Germany
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts


Default WindowsProgressDialog in process plugin

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:

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:


Quote:
Dim dlgProgress As MediaPortal.Dialogs.GUIDialogProgress = CType(MediaPortal.GUI.Library.GUIWindowManager.Get Window(CType(MediaPortal.GUI.Library.GUIWindow.Win dow.WINDOW_DIALOG_PROGRESS, Integer)), MediaPortal.Dialogs.GUIDialogProgress)
What's wrong?

Thanks!!
__________________

HTPC:
P3-S 1133@1133@1,1V passiv
ASUS TUSL2-M
Skystar 2
Creative Soundblaster
nVidia FX5200
120G Samsung SV1204
Toshiba SD-M1712 (Silent Firmware)
--------------------------------------------
PVR Scheduler with MediaPortal Plugin
http://www.pvr-scheduler.de
STSC is offline   Reply With Quote
Old 2005-02-28, 14:31   #2 (permalink)
Portal Member
 
Join Date: Dec 2004
Location: Germany
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts


Default

Ok,

I also wrote it in C#. I guess that this is better.

Code:
using System;
using System.Collections;
using System.Threading;
using System.Windows.Forms;
using MediaPortal.GUI.Library;
using MediaPortal.Util;
using MediaPortal.Dialogs;

namespace MPProgressPlugin
{
	/// <summary>
	/// Zusammenfassung für Class1.
	/// </summary>
	public class ProgressPlugin: IPlugin, ISetupForm
	{
		public ProgressPlugin()
		{
			//
			// TODO: Fügen Sie hier die Konstruktorlogik hinzu
			//
		}


		public void Start()
		{
			ProgressDialog();
		}

		void ProgressDialog()
		{
			try
			{
				GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);
				if (dlgProgress != null)
				{
					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);
				}

			}
			catch(Exception e)
			{			
				MessageBox.Show(e.ToString(), "Error",
					MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				Log.Write(e.ToString());
			}


		}

		public void Stop()
		{	
		}

		#region ISetupForm Members

		public bool CanEnable()
		{
			return true;
		}

		public string PluginName()
		{
			return "Progress Dialog";
		}

		public bool HasSetup()
		{
			return true;
		}
		public bool DefaultEnabled()
		{
			return true;
		}

		public int GetWindowId()
		{
			return 23002;
		}

		public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage)
		{
			strButtonText = "Progress Dialog";
			strButtonImage = "";
			strButtonImageFocus = "";
			strPictureImage = "";
			return false;
		}

		public string Author()
		{
			return "STSC";
		}

		public string Description()
		{
			return "Progress Dialog";
		}

		public void ShowPlugin() // show the setup dialog
		{
		}		

		#endregion
	}
}
But this line

Code:
GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);
still causes an System.InvalidCastException?

@Frodo: Do you know why it doesn't work?
__________________

HTPC:
P3-S 1133@1133@1,1V passiv
ASUS TUSL2-M
Skystar 2
Creative Soundblaster
nVidia FX5200
120G Samsung SV1204
Toshiba SD-M1712 (Silent Firmware)
--------------------------------------------
PVR Scheduler with MediaPortal Plugin
http://www.pvr-scheduler.de
STSC is offline   Reply With Quote
Old 2005-02-28, 14:48   #3 (permalink)
Portal Member
 
Smirnuff's Avatar
 
Join Date: Dec 2004
Location: United Kingdom
Posts: 630
Thanks: 0
Thanked 2 Times in 1 Post

My System

Default

I've just pasted your code into one of my process plugins and it ran okay, no exception was thrown. I used the C# version. :?
Smirnuff is offline   Reply With Quote
Old 2005-02-28, 15:59   #4 (permalink)
Portal Member
 
Join Date: Dec 2004
Location: Germany
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts


Default

Hi,

thank you! You are right, it also works now, too. Another assembly was causing trouble.
__________________

HTPC:
P3-S 1133@1133@1,1V passiv
ASUS TUSL2-M
Skystar 2
Creative Soundblaster
nVidia FX5200
120G Samsung SV1204
Toshiba SD-M1712 (Silent Firmware)
--------------------------------------------
PVR Scheduler with MediaPortal Plugin
http://www.pvr-scheduler.de
STSC is offline   Reply With Quote
Reply

Bookmarks

Tags
plugin, process, windowsprogressdialog

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exiting Fullscreen in My TV crashes MP ddahlstrom The old Bugreport Forum 5 2006-10-23 06:23
Window plugin showing up as process Hesse Plugins 8 2006-08-31 05:34
Process Plugin Public Void Start() Flipit General Development (no feature request here!) 4 2006-08-14 18:50
Gathering topical infos about plugins (To: authors & use tomtom21000 Plugins 2 2006-02-05 00:20


All times are GMT +1. The time now is 06:16.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 Protected by Akismet Blog with WordPress
Advertisement System V2.6 By   Branden