private GuideChannel GetGuideChannelForChannel(Channel channel) { GuideChannel guideChannel = null; GuideChannel[] guideChannels = GuideAgent.GetAllChannels(_currentChannelType); if (guideChannels != null && guideChannels.Length > 0) { foreach (GuideChannel gChannel in guideChannels) { if (gChannel.GuideChannelId == channel.GuideChannelId.Value) { guideChannel = gChannel; } } } return(guideChannel); }
private void OnChangeGuideChannel(Channel channel) { GuideChannel[] guideChannels = GuideAgent.GetAllChannels(_currentChannelType); if (guideChannels != null && guideChannels.Length > 0) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.SelectGuideChannel)); dlg.Add(Utility.GetLocalizedText(TextId.None)); int y = 0; for (int i = 0; i < guideChannels.Length; i++) { GUIListItem item = new GUIListItem(); item.Label = guideChannels[i].Name; if (channel.GuideChannelId.HasValue && (guideChannels[i].GuideChannelId == channel.GuideChannelId.Value)) { item.IsPlayed = true; y = i + 1; } dlg.Add(item); } dlg.SelectedLabel = y; dlg.DoModal(GetID); if (dlg.SelectedId > 0) { if (dlg.SelectedLabel <= 0) { channel.GuideChannelId = null; SchedulerAgent.SaveChannel(channel); } else { GuideChannel guideChannel = guideChannels[dlg.SelectedLabel - 1]; SchedulerAgent.AttachChannelToGuide(channel.ChannelId, guideChannel.GuideChannelId); } } } } }
private void SetProperties(UpcomingProgram program) { string guiPropertyPrefix = _channelType == ChannelType.Television ? "#TV" : "#Radio"; if (program == null) { Utility.ClearProperty(guiPropertyPrefix + ".Search.Channel"); Utility.ClearProperty(guiPropertyPrefix + ".Search.Title"); Utility.ClearProperty(guiPropertyPrefix + ".Search.Genre"); Utility.ClearProperty(guiPropertyPrefix + ".Search.Time"); Utility.ClearProperty(guiPropertyPrefix + ".Search.Description"); Utility.ClearProperty(guiPropertyPrefix + ".Search.thumb"); } else { string strTime = string.Format("{0} {1} - {2}", Utility.GetShortDayDateString(program.StartTime), program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), program.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Channel", program.Channel.DisplayName); GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Title", program.Title); GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Genre", program.Category); GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Time", strTime); string logo = Utility.GetLogoImage(program.Channel.ChannelId, program.Channel.DisplayName, _tvSchedulerAgent); if (System.IO.File.Exists(logo)) { GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.thumb", logo); } else { GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.thumb", "defaultVideoBig.png"); } GuideProgram guideProgram = GuideAgent.GetProgramById(program.GuideProgramId.Value); GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Description", guideProgram.CreateCombinedDescription(true)); } }
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(); } } }