INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Re: C# Template for an Interface Plugin  (Read 2639 times)

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: C# Template for an Interface Plugin
« on: April 05, 2007, 10:52:48 am »

Quote
PaulSinnema :
Hi ChriZ,

Thanks for the templates. After some struggling got it to work and looks OK. Something is missing though. In the Wiki for VB and C++ a desription can be found on how to create code that reacts to events fired by MC. I can't find anything on how to do that in C#. Got a clue?

Paul.

Hi Paul.
The templates were made around about this time last year,
when MC events were still being developed for the SDK.

The .NET templates use a wrapper to allow them to interact
with the MFC DLL.

As a result the wrapper is still 'wrapping' an older DLL,
so there is no events visible.

It's high on my list of things to get updated. However my time's
really quite fragmented at the moment, so I don't see this
happening within the next week.

If you want something quicker than that, there maybe
some useful information in my top post, where I converted
the VB6 Busy box example to .NET

It's a while since I've looked at it however, and it's
possible I ended up using a different technique for the templates.

I think John Gately also had a go at creating a VB.NET plugin
with events and got them to work.

John Gateley

  • Citizen of the Universe
  • *****
  • Posts: 4957
  • Nice haircut
Re: C# Template for an Interface Plugin
« Reply #1 on: April 05, 2007, 12:04:24 pm »

I think John Gately also had a go at creating a VB.NET plugin
with events and got them to work.

Not me... sorry...

j

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: C# Template for an Interface Plugin
« Reply #2 on: April 05, 2007, 12:15:21 pm »

My mistake, it was PollyQ replying to one of Johns posts,
which wasn't actually related to events what so ever...

In that case I'm not sure anyones actually gone there yet.

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: C# Template for an Interface Plugin
« Reply #3 on: April 05, 2007, 01:58:52 pm »

Hang about... this is much easier than I thought.
I'm over complicating it.

All you need to do is remove the reference to MediaJukebox.
Then add a reference to Media Center 12.tlb
which is in the Media Center folder.

After this you will need to change some (but not all)
references to MediaCenter and MC instead of MJ.

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: C# Template for an Interface Plugin
« Reply #4 on: April 06, 2007, 01:13:07 am »

ChriZ,

Thanks for the replies guys. Can see you're very active here. I'll also try your suggestion to change to MC12. Until now had MC11 installed on my development computer. I'll have to change that to MC12 first.

Paul.
Logged

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: C# Template for an Interface Plugin
« Reply #5 on: April 06, 2007, 01:47:25 am »

ChriZ,

Got it working.



Paul.
Logged

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: C# Template for an Interface Plugin
« Reply #6 on: April 06, 2007, 01:51:47 am »

//Description:
//
//Author:
//
//Plugin Creation Date:
//__/__/____
//Version Number:
//0.0.1
//Template Created by Mr ChriZ


#region Libraries
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using MediaCenter;

#endregion

namespace MC_CSPlugin
{
    #region Interop Program ID Registration
    //The interop services allow the plugin to be registered with a CLSID so Media Center
    //Can find it
    //The Prog ID must match with that in the registry in order for
    //MC to be able to pick up the plugin
    [System.Runtime.InteropServices.ProgId ( "Template_MCPlugin.CSAutoEQ" )]
    #endregion
    public partial class MainInterface : UserControl
    {
        #region Attributes
        //This is the Interface to Media Center
        //This is set when Media Center calls the Init Method       
        private MediaCenter.MCAutomation mediaCenterReference;

        #endregion

        #region Constructor
        /// <summary>
        /// This is the main constructor for the plugin
        /// </summary>
        public MainInterface ()
        {
            InitializeComponent ();
        }
        #endregion

        #region Media Center Initialisation
        /// <summary>
        /// After the plugin has been created Media Center
        /// will call the following method, giving us a reference
        /// to the Media Center interface.
        /// </summary>
        /// <param name="mediaCenterReference">
        /// Media Center Reference
        /// </param>       
        public void Init ( MediaCenter.MCAutomation mediaCenterReference )
        {
            try
            {
                this.mediaCenterReference = mediaCenterReference;
                this.mediaCenterReference.FireMJEvent += new IMJAutomationEvents_FireMJEventEventHandler( MJEvent);
                this.checkBoxEQOnOff.Checked = mediaCenterReference.GetMJMixer ().EQOn;

            }
            catch (Exception e)
            {
                MessageBox.Show ( "A Fatal error has occured while creating plugin:-" + e.Message +
                        "\n The Failure Occured" +
                        "\n In Class Object " + e.Source +
                        "\n when calling Method " + e.TargetSite +
                        "\n \n The following Inner Exception was caused" + e.InnerException +
                        "\n \n The Stack Trace Follows: \n\n" + e.StackTrace );
                this.Enabled = false;
            }
            //Placing anything outside of this
            //try catch may cause MC to fail to open.
            //Play safe and insert it try area!
        }

        #endregion

        private void checkBoxEQOnOff_CheckedChanged ( object sender, EventArgs e )
        {
            IMJMixerAutomation mjMixer;

            mjMixer = mediaCenterReference.GetMJMixer ();

            mjMixer.EQOn = checkBoxEQOnOff.Checked;
        }

        private void MJEvent(String s1 , String s2, String s3 )
        {
            textDebug.Text = s1 + "   " + s2;
        }

    }
}
Logged

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: C# Template for an Interface Plugin
« Reply #7 on: April 06, 2007, 01:54:18 am »

ChriZ,

Now I find out that MC does not send events when the Equalizer is activated or changed and that is exactly what is needed.

Paul.
Logged

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: C# Template for an Interface Plugin
« Reply #8 on: April 06, 2007, 02:22:53 am »

ChriZ,

There are some more issues I can not solve with the EventHandler. They are:
- Volume changes
- Mute changes
- DSP changes

In fact I would like to get events on all changes MC makes so I can react.

Paul.
Logged

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: C# Template for an Interface Plugin
« Reply #9 on: April 09, 2007, 06:34:51 am »

Hi Paul, glad you're getting somewhere.
I've not tried playing around with Events at all,
I'll take a look at them at some point over the next week.

I've just got back from the Lake District after a fairly awesome walk
up Helvelyn, across Striding Edge.  Won't be back at my dev machine
for a couple of days still though.

If there's a definite issue with them though, you made need to point them
out to JRiver, who may sort it out in a later build.

PaulSinnema

  • Galactic Citizen
  • ****
  • Posts: 393
  • You don't know what you're missing until its gone
Re: C# Template for an Interface Plugin
« Reply #10 on: April 09, 2007, 11:30:58 am »

Hi ChriZ,

Events are far from complete. I've been thinking. Maybe I should subclass my window in MC to get the Windows events to my plugin. That way I can react to skin changes.

So you've been walking your butt off huh... Well we've been cycling these last couple of days. We live in Switzerland and I can tell you it's beautifull out here. Enjoyed every minute of it.

See jah, Paul.
Logged
Pages: [1]   Go Up