private void BrowseRequest(object sender, BrowseRequestEventArgs args)
        {
            ScreenSaverActive = false;

            switch (args.Request.ItemType)
            {
                case "Genre":
                    Logger.ReportInfo("Navigating to genre {0} by request from remote client", args.Request.ItemName);
                    NavigateToGenre(args.Request.ItemName, CurrentItem);
                    break;
                case "MusicGenre":
                    Logger.ReportInfo("Navigating to music genre {0} by request from remote client", args.Request.ItemName);
                    NavigateToGenre(args.Request.ItemName, CurrentItem, "MusicAlbum");
                    break;
                case "Artist":
                case "Person":
                    var actor = Kernel.Instance.MB3ApiRepository.RetrievePerson(args.Request.ItemName);
                    if (actor != null)
                    {
                        Logger.ReportInfo("Navigating to person {0} by request from remote client", args.Request.ItemName);
                        NavigateToActor(ItemFactory.Instance.Create(actor));
                    }
                    else
                    {
                        Logger.ReportWarning("Unable to browse to person {0}", args.Request.ItemName);
                        Information.AddInformationString("Cannot Browse to "+args.Request.ItemName);
                    }
                    break;
                case "Studio":
                    break;
                default:
                    var item = Kernel.Instance.MB3ApiRepository.RetrieveItem(new Guid(args.Request.ItemId));
                    if (item != null)
                    {
                        Logger.ReportInfo("Navigating to {0} by request from remote client", item.Name);
                        var model = ItemFactory.Instance.Create(item);
                        if (!TVHelper.CreateEpisodeParents(model))
                        {
                            //try to load real parent or attach a default
                            //var parent = !string.IsNullOrEmpty(item.ApiParentId) ? Kernel.Instance.MB3ApiRepository.RetrieveItem(new Guid(item.ApiParentId)) as Folder : null;
                            item.Parent = new IndexFolder(new List<BaseItem> {item});
                            model.PhysicalParent = ItemFactory.Instance.Create(item.Parent) as FolderModel;
                        }
                        CurrentFolder = model.PhysicalParent;
                        Application.UIDeferredInvokeIfRequired(()=>Navigate(model));
                    }
                    else
                    {
                        Logger.ReportWarning("Unable to browse to item {0}", args.Request.ItemId);
                        Information.AddInformationString("Cannot Browse to "+args.Request.ItemName);
                    }
                    break;
            }
        }
        private void GeneralCommand(object sender, Model.Events.GenericEventArgs<GeneralCommandEventArgs> generic)
        {
            var args = generic.Argument;

            switch (args.Command.Name)
            {
                case "DisplayContent":
                    var newArgs = new BrowseRequestEventArgs {Request = new BrowseRequest {ItemType = args.Command.Arguments["ItemType"], ItemId = args.Command.Arguments["ItemId"], ItemName = args.Command.Arguments["ItemName"]}};
                    BrowseRequest(this, newArgs);
                    break;

                case "DisplayMessage":
                    PopoutMessage(args.Command.Arguments["Header"], args.Command.Arguments["Text"]);
                    break;

                case "Back":
                    Back();
                    break;

                case "GoHome":
                    BackToRoot();
                    break;

                case "GoToSettings":
                    OpenConfiguration(true);
                    break;

                case "Mute":
                    WMCMute = true;
                    break;

                case "Unmute":
                    WMCMute = false;
                    break;

                case "VolumeUp":
                    WmcVolumeUp();
                    break;

                case "VolumeDown":
                    WmcVolumeDown();
                    break;

                case "SetVolume":
                    var amt = args.Command.Arguments["Volume"];
                    SetWmcVolume(Convert.ToInt32(amt) / 2);
                    break;

                case "ToggleMute":
                    WMCMute = !WMCMute;
                    break;

                case "MoveLeft":
                    Helper.ActivateMediaCenter();
                    Thread.Sleep(50);
                    try
                    {
                        Helper.SendKeyLeft();
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Error sending left key",e);
                    }
                    break;

                case "MoveRight":
                    Helper.ActivateMediaCenter();
                    Thread.Sleep(50);
                    try
                    {
                        Helper.SendKeyRight();
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Error sending right key",e);
                    }
                    break;

                case "MoveUp":
                    Helper.ActivateMediaCenter();
                    Thread.Sleep(50);
                    try
                    {
                        Helper.SendKeyUp();
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Error sending up key",e);
                    }
                    break;

                case "MoveDown":
                    Helper.ActivateMediaCenter();
                    Thread.Sleep(50);
                    try
                    {
                        Helper.SendKeyDown();
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Error sending down key",e);
                    }
                    break;

                case "PageUp":
                    Helper.ActivateMediaCenter();
                    Thread.Sleep(50);
                    try
                    {
                        Helper.SendKeyPageUp();
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Error sending page up key",e);
                    }
                    break;

                case "PageDown":
                    Helper.ActivateMediaCenter();
                    Thread.Sleep(50);
                    try
                    {
                        Helper.SendKeyPageDown();
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Error sending page down key",e);
                    }
                    break;

                case "Select":
                    Helper.ActivateMediaCenter();
                    Thread.Sleep(50);
                    try
                    {
                        Helper.SendKeyEnter();
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Error sending enter key",e);
                    }
                    break;


            }
        }
        private void GeneralCommand(object sender, GeneralCommandEventArgs args)
        {
            switch (args.Command.Name)
            {
                case "DisplayContent":
                    var newArgs = new BrowseRequestEventArgs {Request = new BrowseRequest {ItemType = args.Command.Arguments["ItemType"], ItemId = args.Command.Arguments["ItemId"], ItemName = args.Command.Arguments["ItemName"]}};
                    BrowseRequest(this, newArgs);
                    break;

                case "Back":
                    Back();
                    break;

                case "GoHome":
                    BackToRoot();
                    break;

                case "GoToSettings":
                    OpenConfiguration(true);
                    break;

                case "Mute":
                    WMCMute = true;
                    break;

                case "Unmute":
                    WMCMute = false;
                    break;

                case "ToggleMute":
                    WMCMute = !WMCMute;
                    break;

            }
        }