当前位置: 首页>>代码示例>>C#>>正文


C# Kernel.AddMenuItem方法代码示例

本文整理汇总了C#中Kernel.AddMenuItem方法的典型用法代码示例。如果您正苦于以下问题:C# Kernel.AddMenuItem方法的具体用法?C# Kernel.AddMenuItem怎么用?C# Kernel.AddMenuItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kernel的用法示例。


在下文中一共展示了Kernel.AddMenuItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateMenu

    public static void CreateMenu(Kernel kernel)
    {
        var subtitleMenuItem = new MenuItem("Subtitle?", "resx://MediaBrowser/MediaBrowser.Resources/IconFloral", SubtitleMenuManager.DoesSubTitleExist, new List<Type>() { typeof(Movie), typeof(Episode) });

        kernel.AddMenuItem(subtitleMenuItem);
    }
开发者ID:mikoskinen,项目名称:SubtitleProvider,代码行数:6,代码来源:SubtitleMenuManager.cs

示例2: Init

        public override void Init(Kernel kernel)
        {
            _kernel = kernel;
            //AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            Logger.ReportInfo(string.Format("Tyring to load {0} v{1} loaded by {2}.", Name, LatestVersion.ToString(), AppDomain.CurrentDomain.FriendlyName));
            bool isConfigurator = !AppDomain.CurrentDomain.FriendlyName.Contains("ehExtHost");

            if (Settings.ValidateSettings(kernel.ConfigData.InitialFolder, true))
            {
                if (Settings.Instance.LoadiTunesLibrary)
                {
                    if (Settings.ValidateiTunesLibrary(true))
                    {
                        try
                        {
                            BaseItem itunes;
                            string message = "Refresh iTunes Library is set to true, this will force a rebuild of the iTunes Library, continue?";
                            string heading = "Rebuild iTunes Library Cache";

                            if (Settings.Instance.ForceRefreshiTunesLibrary && (isConfigurator || Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment.Dialog(message, heading, DialogButtons.Yes | DialogButtons.No, 60, true) == DialogResult.Yes))
                            {

                                itunes = iTunesLibrary.GetDetailsFromXml(kernel.ItemRepository.RetrieveItem(MusiciTunesGuid) as iTunesMusicLibrary);
                                Settings.Instance.ForceRefreshiTunesLibrary = false;
                                Settings.SaveSettingsFile();

                            }
                            else
                            {
                                itunes = kernel.ItemRepository.RetrieveItem(MusiciTunesGuid) ?? new iTunesLibrary().Library;
                            }
                            if (((iTunesMusicLibrary) itunes).LastUpdate != DateTime.MinValue && (itunes as iTunesMusicLibrary).LastUpdate < new System.IO.FileInfo(Settings.Instance.iTunesLibraryXMLPath).LastWriteTime)
                            {
                                message = "Your iTunes Library might have changed, do you want to rebuild it?";
                                if (isConfigurator || Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment.Dialog(message, heading, DialogButtons.Yes | DialogButtons.No, 60, true) == DialogResult.Yes)
                                    itunes = iTunesLibrary.GetDetailsFromXml(kernel.ItemRepository.RetrieveItem(MusiciTunesGuid) as iTunesMusicLibrary);

                            }

                            itunes.Path = "";
                            itunes.Id = MusiciTunesGuid;
                            Logger.ReportInfo("Music iTunes id - " + itunes.Id);
                            itunes.Name = Settings.Instance.iTunesLibraryVirtualFolderName;
                            Logger.ReportInfo("Music iTunes vf name - " + itunes.Name);
                            if (!string.IsNullOrEmpty(Settings.Instance.iTunesLibraryIcon))
                                itunes.PrimaryImagePath = Settings.Instance.iTunesLibraryIcon;

                            kernel.RootFolder.AddVirtualChild(itunes);
                            kernel.ItemRepository.SaveItem(itunes);
                            //add types to supported types
                            kernel.AddExternalPlayableItem(typeof(iTunesSong));
                            kernel.AddExternalPlayableFolder(typeof(iTunesAlbum));

                        }
                        catch (Exception ex)
                        {
                            Logger.ReportException("Cannot load iTunes Music Library", ex);
                        }
                    }
                }

                if (Settings.Instance.LoadNormalLibrary)
                {
                    if (Settings.ValidateNormalLibrary(true))
                    {
                        BaseItem music;

                        music = kernel.ItemRepository.RetrieveItem(MusicNormalGuid) ?? new MusicPluginFolder();
                        music.Id = MusicNormalGuid;
                        Logger.ReportInfo("Music normal id - " + music.Id);
                        music.Path = Settings.Instance.NormalLibraryPath;
                        Logger.ReportInfo("Music normal path - " + music.Path);
                        music.Name = Settings.Instance.NormalLibraryVirtualFolderName;
                        Logger.ReportInfo("Music normal name - " + music.Name);
                        if (!string.IsNullOrEmpty(Settings.Instance.NormalLibraryIcon))
                            music.PrimaryImagePath = Settings.Instance.NormalLibraryIcon;
                        kernel.RootFolder.AddVirtualChild(music);
                        kernel.ItemRepository.SaveItem(music);
                        //add types to supported types
                        kernel.AddExternalPlayableItem(typeof(Song));
                        kernel.AddExternalPlayableFolder(typeof(ArtistAlbum));
                    }
                }
            }

            //add our music specific menu items
            if (!isConfigurator)
            {
                kernel.AddMenuItem(new MenuItem("Queue All", "resx://MediaBrowser/MediaBrowser.Resources/Lines", this.queue, new List<Type>() { typeof(ArtistAlbum) }, new List<MenuType>() { MenuType.Item, MenuType.Play }));
                kernel.AddMenuItem(new MenuItem("Queue", "resx://MediaBrowser/MediaBrowser.Resources/Lines", this.queue, new List<Type>() { typeof(Song) }, new List<MenuType>() { MenuType.Item, MenuType.Play }));
            }

            kernel.EntityResolver.Insert(kernel.EntityResolver.Count - 2, new SongResolver());
            kernel.EntityResolver.Insert(kernel.EntityResolver.Count - 2, new ArtistAlbumResolver());
            //kernel.EntityResolver.Insert(kernel.EntityResolver.Count - 2, new AlbumResolver());
            //kernel.EntityResolver.Insert(kernel.EntityResolver.Count - 2, new ArtistResolver());
            PlayableItemFactory.Instance.RegisterType<PlayableMusicFile>();
            PlayableItemFactory.Instance.RegisterType<PlayableMultiFileMusic>();
            //kernel.MetadataProviderFactories.Add(new MetadataProviderFactory(typeof(ArtistAlbumProvider)));
            kernel.PlaybackControllers.Insert(0, new PlaybackControllerMusic());
//.........这里部分代码省略.........
开发者ID:xantilas,项目名称:videobrowser,代码行数:101,代码来源:Plugin.cs


注:本文中的Kernel.AddMenuItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。