private void LoadChannelsForGroup(ChannelGroup group) { _channelsInGroupList.Clear(); _channelIdsInList.Clear(); if (group != null) { Channel[] channels = SchedulerAgent.GetChannelsInGroup(group.ChannelGroupId, false); if (channels != null && channels.Length > 0) { foreach (Channel channel in channels) { _channelIdsInList.Add(channel.ChannelId); GUIListItem item = new GUIListItem(); item.Label = channel.DisplayName; item.TVTag = channel; string logo = Utility.GetLogoImage(channel, SchedulerAgent); if (!string.IsNullOrEmpty(logo)) { item.IconImage = logo; } if (!channel.VisibleInGuide) { item.IsPlayed = true; } _channelsInGroupList.Add(item); } } } }
private void UpdateChannels() { Schedule schedule = null; bool channelFound = false; int channelIndex = 0; int groupIndex = 0; if (_upcomingProgram != null) { schedule = SchedulerAgent.GetScheduleById(_upcomingProgram.ScheduleId); if (schedule != null) { _channelType = _upcomingProgram.Channel.ChannelType; } } List <ChannelGroup> groups = new List <ChannelGroup>(PluginMain.Navigator.GetGroups(_channelType)); if (_spinGroup.GetLabel() == "" || _spinGroup.GetLabel() == GUILocalizeStrings.Get(2014)) { _spinGroup.Reset(); foreach (ChannelGroup group in groups) { _spinGroup.AddLabel(group.GroupName, 0); } } //based on name but I don't know anything better string groupName = _spinGroup.GetLabel(); _spinChannel.Reset(); foreach (ChannelGroup group in groups) { if (group.GroupName == groupName || (channelFound == false && schedule != null)) { foreach (Channel chan in SchedulerAgent.GetChannelsInGroup(group.ChannelGroupId, true)) { _spinChannel.AddLabel(chan.DisplayName, 0); if (!channelFound && schedule != null) { if (_upcomingProgram.Channel.ChannelId == chan.ChannelId) { channelFound = true; } channelIndex++; } } } if (!channelFound) { groupIndex++; } } if (!channelFound && schedule != null) { // channel not found in groups, create a "unknown group" for this channel _spinGroup.AddLabel(GUILocalizeStrings.Get(2014), 0); _spinGroup.Value = groupIndex; _spinChannel.Reset(); _spinChannel.AddLabel(_upcomingProgram.Channel.DisplayName, 0); } if (channelFound) { _spinChannel.Value = channelIndex - 1; _spinGroup.Value = groupIndex; } }
protected override void OnClicked(int controlId, GUIControl control, global::MediaPortal.GUI.Library.Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); if (control == _searchButton) { _selectedTitleIndex = 0; _selectedProgramIndex = 0; if (_rules.Count > 0) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.Attention)); dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.ContinueWithPrevResults)); dlgYesNo.SetDefaultToYes(true); dlgYesNo.DoModal(GetID); if (!dlgYesNo.IsConfirmed) { _rules.Clear(); if (_viewsList != null && _viewsList.Count > 0) { _viewsList.Clear(); } } } } VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD); if (keyboard != null) { keyboard.Reset(); keyboard.IsSearchKeyboard = true; keyboard.Text = String.Empty; keyboard.DoModal(GetID); if (keyboard.IsConfirmed) { if (keyboard.Text == string.Empty) { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (dlgOk != null) { dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information)); dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoValidSearchText)); dlgOk.DoModal(GetID); } } else { switch (_currentSearchMethod) { case SearchInMethod.Title: _rules.Add(ScheduleRuleType.TitleContains, keyboard.Text); break; case SearchInMethod.Description: _rules.Add(ScheduleRuleType.DescriptionContains, keyboard.Text); break; case SearchInMethod.ProgramInfo: _rules.Add(ScheduleRuleType.ProgramInfoContains, keyboard.Text); break; case SearchInMethod.Actor: _rules.Add(ScheduleRuleType.WithActor, keyboard.Text); break; case SearchInMethod.DirectedBy: _rules.Add(ScheduleRuleType.DirectedBy, keyboard.Text); break; } ShowSearchResults(string.Empty); } } } } else if (control == _searchMethodButton) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(467); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnTitle)); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnDescription)); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnProgramInfo)); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnActor)); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnDirectedBy)); dlg.SelectedLabel = (int)_currentSearchMethod; // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _currentSearchMethod = (SearchInMethod)(dlg.SelectedLabel); UpdateButtonStates(); } else if (control == _selectChannelsButton) { List <ChannelGroup> groups = new List <ChannelGroup>(PluginMain.Navigator.GetGroups(this._channelType)); ChannelGroup _selectedGroup = new ChannelGroup(); if (groups.Count > 0) { if (groups.Count > 1) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.SelectGroup)); foreach (ChannelGroup group in groups) { dlg.Add(group.GroupName); } // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _selectedGroup = groups[dlg.SelectedId - 1]; } else { _selectedGroup = groups[0]; } List <Channel> channels = new List <Channel>(); if (_channelArguments.Count > 0) { List <Channel> channels2 = new List <Channel>(SchedulerAgent.GetChannelsInGroup(_selectedGroup.ChannelGroupId, true)); foreach (Channel channel in channels2) { if (!_channelArguments.Contains(channel.ChannelId)) { channels.Add(channel); } } } else { channels = new List <Channel>(SchedulerAgent.GetChannelsInGroup(_selectedGroup.ChannelGroupId, true)); } if (channels.Count > 0) { GUIDialogMenu dlg2 = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg2 == null) { return; } dlg2.Reset(); dlg2.SetHeading(GetChannelArgumentsString(true)); foreach (Channel channel in channels) { dlg2.Add(channel.DisplayName); } // show dialog and wait for result dlg2.DoModal(GetID); if (dlg2.SelectedId == -1) { return; } _channelArguments.Add(channels[dlg2.SelectedId - 1].ChannelId); UpdateButtonStates(); } else { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (dlgOk != null) { dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information)); dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoMoreChannelsToAdd)); dlgOk.DoModal(GetID); } } } } else if (control == _selectCategoriesButton) { List <string> categories = new List <string>(); string[] _categories = new string[0]; _categories = GuideAgent.GetAllCategories(); foreach (string categorie in _categories) { if (!_categorieArguments.Contains(categorie)) { categories.Add(categorie); } } if (categories.Count > 0) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GetCategorieArgumentString(true)); foreach (string categorie in categories) { dlg.Add(categorie); } // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _categorieArguments.Add(dlg.SelectedLabelText); UpdateButtonStates(); } else { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (dlgOk != null) { dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information)); dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoMoreCategoriesToAdd)); dlgOk.DoModal(GetID); } } } else if (control == _clearButton) { OnClearRules(true); ShowSearchResults(string.Empty); UpdateButtonStates(); } else if (control == _sortByButton) { if (_isInSubDirectory) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(495); //Sort Options dlg.AddLocalizedString(620); //channel dlg.AddLocalizedString(621); //date dlg.AddLocalizedString(268); //title/name // set the focus to currently used sort method dlg.SelectedLabel = (int)_currentSortMethod; // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _currentSortMethod = (SortMethod)dlg.SelectedLabel; OnSort(); } } else if (control == _viewsList) { GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_SELECTED, GetID, 0, control.GetID, 0, 0, null); OnMessage(msg); int iItem = (int)msg.Param1; if (actionType == Action.ActionType.ACTION_SELECT_ITEM) { OnSelectItem(iItem); } if (actionType == Action.ActionType.ACTION_SHOW_INFO) { OnShowContextMenu(); } } }