|
|
(10 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
− | == Prerequisites ==
| + | {{stub}} |
− | * Media Center 12 or higher
| |
| | | |
− | == Create a new plugin ==
| + | [[Programming Plugins in C#.Net]] - Gives a (small) description on how to program a plugin in C# |
− | Use the description of Mr ChriZ to create a new Plugin.
| |
− | http://yabb.jriver.com/interact/index.php?topic=32294.0
| |
| | | |
− | == Autoresizing of plugin ==
| + | [[MC Plugin Template for Visual Studio]] - Instructions on how to use the MC Plugin Template |
− | Draw a Panel upon the UserControl and do the following:<br>
| |
− | * Set 'Dock' Property to 'Fill'.<br>
| |
− | * Set 'Autosize' Property to 'False'<br>
| |
| | | |
− | Your Panel will now automatically be resized to fit into the MC Plugin Area. Anything you put upon the Panel can scale to the size of the Panel using the 'Anchor' or 'Dock' Properties. Don't use the 'Autosize' Property!
| + | [http://msdn2.microsoft.com/en-us/library/ms364046(VS.80).aspx Create you own Visual Studio Templates] |
| | | |
− | == Registering the Event handler ==
| + | [[How to use MC methods in .Net projects]] |
− | C# Example: Registering the MJEvent handler
| |
| | | |
− | public void Init ( MediaCenter.MCAutomation mcRef )
| + | [[Category:Developer]] |
− | {
| |
− | try
| |
− | {
| |
− | this.mcRef = mcRef;
| |
− | // This tells MC to also call our MJEvent method
| |
− | this.mcRef.FireMJEvent += new IMJAutomationEvents_FireMJEventEventHandler ( MJEvent );
| |
− | }
| |
− | catch (Exception e)
| |
− | {
| |
− | errorHandler ( e );
| |
− | }
| |
− | //Placing anything outside of this
| |
− | //try catch may cause MC to fail to open.
| |
− | //Play safe and insert it try area!
| |
− | }
| |
− |
| |
− | private void errorHandler (Exception e)
| |
− | {
| |
− | MessageBox.Show ( "A Fatal error has occured:-" + 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;
| |
− | }
| |
− | | |
− | == Handling an event ==
| |
− | C# Example: handle events fired by MC.
| |
− | | |
− | private void MJEvent(String s1 , String s2, String s3 )
| |
− | {
| |
− | switch (s1)
| |
− | {
| |
− | case "MJEvent type: MCCommand":
| |
− | switch (s2)
| |
− | {
| |
− | case "MCC: NOTIFY_TRACK_CHANGE":
| |
− | // Your code here
| |
− | break;
| |
− |
| |
− | case "MCC: NOTIFY_PLAYLIST_ADDED":
| |
− | // Your code here
| |
− | break;
| |
− |
| |
− | case "MCC: NOTIFY_PLAYLIST_INFO_CHANGED":
| |
− | // Your code here
| |
− | break;
| |
− |
| |
− | case "MCC: NOTIFY_PLAYLIST_FILES_CHANGED":
| |
− | // Your code here
| |
− | break;
| |
− |
| |
− | case "MCC: NOTIFY_PLAYLIST_REMOVED":
| |
− | // Your code here
| |
− | break;
| |
− |
| |
− | case "MCC: NOTIFY_PLAYLIST_COLLECTION_CHANGED":
| |
− | // Your code here
| |
− | break;
| |
− |
| |
− | case "MCC: NOTIFY_PLAYLIST_PROPERTIES_CHANGED":
| |
− | // Your code here
| |
− | break;
| |
− |
| |
− | default:
| |
− | // Unknown (new?) event
| |
− | break;
| |
− | }
| |
− |
| |
− | break;
| |
− |
| |
− | default:
| |
− | // Unknown (new?) type
| |
− | break;
| |
− | }
| |
− | }
| |