public OnlineVideosGuiListItem(SitesGroup item) : base(item.Name)
 {
     Label2   = item.Sites.Count.ToString();
     IsFolder = true;
     Item     = item;
     if (!string.IsNullOrEmpty(item.Thumbnail))
     {
         ThumbnailImage = item.Thumbnail;
         IconImage      = item.Thumbnail;
         IconImageBig   = item.Thumbnail;
     }
     else
     {
         MediaPortal.Util.Utils.SetDefaultIcons(this);
     }
 }
 public OnlineVideosGuiListItem(SitesGroup item) : base(item.Name)
 {
     Label2 = item.Sites.Count.ToString();
     IsFolder = true;
     Item = item;
     if (!string.IsNullOrEmpty(item.Thumbnail))
     {
         ThumbnailImage = item.Thumbnail;
         IconImage = item.Thumbnail;
         IconImageBig = item.Thumbnail;
     }
     else
     {
         MediaPortal.Util.Utils.SetDefaultIcons(this);
     }
 }
        private void DisplayGroups()
        {
            var sitesGroups = PluginConfiguration.Instance.SitesGroups;
            if ((sitesGroups == null || sitesGroups.Count == 0) && PluginConfiguration.Instance.autoGroupByLang) sitesGroups = PluginConfiguration.Instance.CachedAutomaticSitesGroups;

            SelectedSite = null;
            GUIControl.ClearControl(GetID, GUI_facadeView.GetID);

            // add Favorites and Downloads Site as first two Groups (if they are available and user configured them to be first)
            if (OnlineVideoSettings.Instance.FavoritesFirst) AddFavoritesAndDownloadsSitesToFacade();

            HashSet<string> groupedSites = new HashSet<string>();
            foreach (SitesGroup sitesGroup in sitesGroups)
            {
                if (sitesGroup.Sites != null && sitesGroup.Sites.Count > 0)
                {
                    OnlineVideosGuiListItem loListItem = new OnlineVideosGuiListItem(sitesGroup);
                    loListItem.OnItemSelected += OnItemSelected;
                    loListItem.ItemId = GUI_facadeView.Count;
                    GUI_facadeView.Add(loListItem);
                    if (selectedSitesGroup != null && selectedSitesGroup.Label == sitesGroup.Name) GUI_facadeView.SelectedListItemIndex = GUI_facadeView.Count - 1;
                }

                foreach (string site in sitesGroup.Sites) groupedSites.Add(site);
            }

            // add the item for all ungrouped sites if there are any
            SitesGroup othersGroup = new SitesGroup() { Name = Translation.Instance.Others };
            foreach (string site in OnlineVideoSettings.Instance.SiteUtilsList.Keys)
                if (!groupedSites.Contains(site) && site != Translation.Instance.Favourites && site != Translation.Instance.DownloadedVideos)
                    othersGroup.Sites.Add(site);
            if (othersGroup.Sites.Count > 0)
            {
                OnlineVideosGuiListItem listItem = new OnlineVideosGuiListItem(othersGroup);
                listItem.OnItemSelected += OnItemSelected;
                listItem.ItemId = GUI_facadeView.Count;
                GUI_facadeView.Add(listItem);
                if (selectedSitesGroup != null && selectedSitesGroup.Label == othersGroup.Name) GUI_facadeView.SelectedListItemIndex = GUI_facadeView.Count - 1;
            }

            // add Favorites and Downloads Site as last two Groups (if they are available)
            if (!OnlineVideoSettings.Instance.FavoritesFirst) AddFavoritesAndDownloadsSitesToFacade();

            CurrentState = State.groups;
            UpdateViewState();
        }
Exemplo n.º 4
0
        void DoPageLoad()
        {
            // called everytime the plugin is shown, after some other window was shown (also after fullscreen playback)
            if (PreviousWindowId != OnlineVideos.MediaPortal1.Player.GUIOnlineVideoFullscreen.WINDOW_FULLSCREEN_ONLINEVIDEO)
            {
                // reload settings that can be modified with the MPEI plugin
                PluginConfiguration.Instance.ReLoadRuntimeSettings();

                // if groups are now enabled/disabled we need to set the states accordingly
                if (GroupsEnabled)
                {
                    // showing sites, but groups are enabled and no group is selected -> show groups
                    if (CurrentState == State.sites && selectedSitesGroup == null)
                    {
                        CurrentState = State.groups;
                    }

                    // we might have to generate automatic groups if it is enabled now
                    if (PluginConfiguration.Instance.CachedAutomaticSitesGroups.Count == 0)
                    {
                        PluginConfiguration.Instance.BuildAutomaticSitesGroups();
                    }
                }
                else
                {
                    // showing groups, but groups are disabled -> show sites
                    if (CurrentState == State.groups)
                    {
                        CurrentState = State.sites;
                    }
                    selectedSitesGroup = null;
                }

                // reset the LoadParameterInfo
                loadParamInfo = null;

                string loadParam = null;
                // check if running version of mediaportal supports loading with parameter and handle _loadParameter
                System.Reflection.FieldInfo fi = typeof(GUIWindow).GetField("_loadParameter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                if (fi != null)
                {
                    loadParam = (string)fi.GetValue(this);
                }
                // check for LoadParameters by GUIproperties if nothing was set by the _loadParameter
                if (string.IsNullOrEmpty(loadParam))
                {
                    loadParam = LoadParameterInfo.FromGuiProperties();
                }

                if (!string.IsNullOrEmpty(loadParam))
                {
                    Log.Instance.Info("Called with LoadParameter: '{0}'", loadParam);
                    loadParamInfo = new LoadParameterInfo(loadParam);

                    // set all state variables to reflect the state we were called with
                    currentNavigationContextSwitch = null;
                    if (!string.IsNullOrEmpty(loadParamInfo.Group))
                    {
                        SitesGroup group = PluginConfiguration.Instance.SitesGroups.FirstOrDefault(sg => sg.Name == loadParamInfo.Group);
                        if (group == null)
                        {
                            group = PluginConfiguration.Instance.CachedAutomaticSitesGroups.FirstOrDefault(sg => sg.Name == loadParamInfo.Group);
                        }
                        if (group != null)
                        {
                            selectedSitesGroup = new OnlineVideosGuiListItem(group);
                            CurrentState       = State.sites;
                        }
                    }
                    if (!string.IsNullOrEmpty(loadParamInfo.Site) && OnlineVideoSettings.Instance.SiteUtilsList.ContainsKey(loadParamInfo.Site))
                    {
                        SelectedSite     = OnlineVideoSettings.Instance.SiteUtilsList[loadParamInfo.Site];
                        CurrentState     = State.categories;
                        selectedCategory = null;
                    }
                    if (SelectedSite != null && SelectedSite.CanSearch && !string.IsNullOrEmpty(loadParamInfo.Search))
                    {
                        Display_SearchResults(loadParamInfo.Search);
                        return;
                    }
                }
            }

            Log.Instance.Info("DoPageLoad with CurrentState '{0}', PreviousWindowId '{1}'", CurrentState, PreviousWindowId);
            switch (CurrentState)
            {
            case State.groups: DisplayGroups(); break;

            case State.sites: DisplaySites(); break;

            case State.categories: DisplayCategories(selectedCategory); break;

            case State.videos: SetVideosToFacade(currentVideoList, currentVideosDisplayMode); break;

            default: SetVideosToInfoList(currentTrailerList); break;
            }
        }