Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

intial commit of patch #1

  • Loading branch information...
commit 791e6fe4dc95136ec74c0b2fb41d66063aeae21f 1 parent 3814bdb
@gibman gibman authored
View
4,902 ...brary/TvPlugin/TvPlugin/RadioGuideBase.cs → TVLibrary/TvPlugin/TvPlugin/EPG/GuideBase.cs
2,301 additions, 2,601 deletions not shown
View
2  TVLibrary/TvPlugin/TvPlugin/RadioGuide.cs → ...brary/TvPlugin/TvPlugin/EPG/RadioGuide.cs
@@ -29,7 +29,7 @@ namespace TvPlugin
/// <summary>
///
/// </summary>
- public class RadioGuide : RadioGuideBase
+ public sealed class RadioGuide : RadioGuideBase
{
public RadioGuide()
{
View
775 TVLibrary/TvPlugin/TvPlugin/EPG/RadioGuideBase.cs
@@ -0,0 +1,775 @@
+#region Copyright (C) 2005-2010 Team MediaPortal
+
+// Copyright (C) 2005-2010 Team MediaPortal
+// http://www.team-mediaportal.com
+//
+// MediaPortal is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// MediaPortal is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
+
+#endregion
+
+#region usings
+
+using System;
+using System.Collections.Generic;
+using MediaPortal.Dialogs;
+using MediaPortal.GUI.Library;
+using MediaPortal.Player;
+using MediaPortal.Util;
+using TvControl;
+using TvDatabase;
+
+#endregion
+
+namespace TvPlugin
+{
+ /// <summary>
+ ///
+ /// </summary>
+ public class RadioGuideBase : GuideBase
+ {
+ #region constants
+
+ private const string SKIN_PROPERTY_PREFIX = "#Radio";
+ private const string SETTINGS_GUIDE_SECTION = "radioguide";
+ private const string SETTINGS_SECTION = "myradio";
+
+ #endregion
+
+ #region variables
+
+ private Channel _recordingExpected;
+
+ #endregion
+
+ #region property overrides
+
+ protected override string SkinPropertyPrefix
+ {
+ get { return SKIN_PROPERTY_PREFIX; }
+ }
+
+ protected override string SettingsGuideSection
+ {
+ get { return SETTINGS_GUIDE_SECTION; }
+ }
+
+ protected override string SettingsSection
+ {
+ get { return SETTINGS_SECTION; }
+ }
+
+ protected override int ChannelGroupCount
+ {
+ get { return Radio.AllRadioGroups.Count; }
+ }
+
+ protected override string Thumb
+ {
+ get { return Thumbs.Radio; }
+ }
+
+ protected override string DefaultThumb
+ {
+ get { return "defaultMyRadioBig.png"; }
+ }
+
+ protected override string CurrentGroupName
+ {
+ get { return Radio.SelectedGroup.GroupName; }
+ }
+
+ #endregion
+
+ #region overrides
+
+ /// <summary>
+ /// changes the current channel group and refreshes guide display
+ /// </summary>
+ /// <param name="direction"></param>
+ protected override void OnChangeChannelGroup(int direction)
+ {
+ // in single channel view there would be errors when changing group
+ if (_singleChannelView) return;
+ int countGroups = Radio.AllRadioGroups.Count; // all
+ int newIndex = 0;
+ int oldIndex = 0;
+
+ for (int i = 0; i < countGroups; ++i)
+ {
+ if (Radio.AllRadioGroups[i].IdGroup == Radio.SelectedGroup.IdGroup)
+ {
+ newIndex = oldIndex = i;
+ break;
+ }
+ }
+
+ if (
+ (newIndex >= 1 && direction < 0) ||
+ (newIndex < countGroups - 1 && direction > 0)
+ )
+ {
+ newIndex += direction; // change group
+ }
+ else // Cycle handling
+ if ((newIndex == countGroups - 1) && direction > 0)
+ {
+ newIndex = 0;
+ }
+ else if (newIndex == 0 && direction < 0)
+ {
+ newIndex = countGroups - 1;
+ }
+
+ if (oldIndex != newIndex)
+ {
+ // update list
+ GUIWaitCursor.Show();
+ Radio.SelectedGroup = Radio.AllRadioGroups[newIndex];
+ GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Group", Radio.SelectedGroup.GroupName);
+
+ _cursorY = 1; // cursor should be on the program guide item
+ ChannelOffset = 0;
+ // reset to top; otherwise focus could be out of screen if new group has less then old position
+ _cursorX = 0; // first channel
+ GetChannels(true);
+ Update(false);
+ SetFocus();
+ GUIWaitCursor.Hide();
+ }
+ }
+
+ protected override void WindowInit(GUIMessage message)
+ {
+ UnFocus();
+ GetChannels(true);
+ LoadSchedules(true);
+ _currentProgram = null;
+ if (message.Param1 != (int)Window.WINDOW_TV_PROGRAM_INFO)
+ {
+ _viewingTime = DateTime.Now;
+ _cursorY = 0;
+ _cursorX = 0;
+ ChannelOffset = 0;
+ _singleChannelView = false;
+ _showChannelLogos = false;
+ if (TVHome.Card.IsTimeShifting)
+ {
+ _currentChannel = Radio.CurrentChannel;
+ for (int i = 0; i < _channelList.Count; i++)
+ {
+ Channel chan = (_channelList[i]).Channel;
+ if (chan.IdChannel == _currentChannel.IdChannel)
+ {
+ _cursorX = i;
+ break;
+ }
+ }
+ }
+ }
+ while (_cursorX >= _channelCount)
+ {
+ _cursorX -= _channelCount;
+ ChannelOffset += _channelCount;
+ }
+ // Mantis 3579: the above lines can lead to too large channeloffset.
+ // Now we check if the offset is too large, and if it is, we reduce it and increase the cursor position accordingly
+ if (!_guideContinuousScroll && (ChannelOffset > _channelList.Count - _channelCount))
+ {
+ _cursorX += ChannelOffset - (_channelList.Count - _channelCount);
+ ChannelOffset = _channelList.Count - _channelCount;
+ }
+ var cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl;
+ if (cntlDay != null)
+ {
+ DateTime dtNow = DateTime.Now;
+ cntlDay.Reset();
+ cntlDay.SetRange(0, MAX_DAYS_IN_GUIDE - 1);
+ for (int iDay = 0; iDay < MAX_DAYS_IN_GUIDE; iDay++)
+ {
+ DateTime dtTemp = dtNow.AddDays(iDay);
+ string day;
+ switch (dtTemp.DayOfWeek)
+ {
+ case DayOfWeek.Monday:
+ day = GUILocalizeStrings.Get(657);
+ break;
+ case DayOfWeek.Tuesday:
+ day = GUILocalizeStrings.Get(658);
+ break;
+ case DayOfWeek.Wednesday:
+ day = GUILocalizeStrings.Get(659);
+ break;
+ case DayOfWeek.Thursday:
+ day = GUILocalizeStrings.Get(660);
+ break;
+ case DayOfWeek.Friday:
+ day = GUILocalizeStrings.Get(661);
+ break;
+ case DayOfWeek.Saturday:
+ day = GUILocalizeStrings.Get(662);
+ break;
+ default:
+ day = GUILocalizeStrings.Get(663);
+ break;
+ }
+ day = String.Format("{0} {1}-{2}", day, dtTemp.Day, dtTemp.Month);
+ cntlDay.AddLabel(day, iDay);
+ }
+ }
+ else
+ {
+ Log.Debug("RadioGuideBase: SpinControl cntlDay is null!");
+ }
+
+ var cntlTimeInterval = GetControl((int)Controls.SPINCONTROL_TIME_INTERVAL) as GUISpinControl;
+ if (cntlTimeInterval != null)
+ {
+ cntlTimeInterval.Reset();
+ for (int i = 1; i <= 4; i++)
+ {
+ cntlTimeInterval.AddLabel(String.Empty, i);
+ }
+ cntlTimeInterval.Value = (_timePerBlock / 15) - 1;
+ }
+ else
+ {
+ Log.Debug("RadioGuideBase: SpinControl cntlTimeInterval is null!");
+ }
+
+ if (message.Param1 != (int)Window.WINDOW_TV_PROGRAM_INFO)
+ {
+ Update(true);
+ }
+ else
+ {
+ Update(false);
+ }
+
+ SetFocus();
+
+ if (_currentProgram != null)
+ {
+ _startTime = _currentProgram.StartTime;
+ }
+ UpdateCurrentProgram();
+ }
+
+ /// <summary>
+ /// Shows channel group selection dialog
+ /// </summary>
+ protected override void OnSelectChannelGroup()
+ {
+ // only if more groups present and not in singleChannelView
+ if (Radio.AllRadioGroups.Count > 1 && !_singleChannelView)
+ {
+ int prevGroup = Radio.SelectedGroup.IdGroup;
+
+ var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
+ if (dlg == null)
+ {
+ return;
+ }
+ dlg.Reset();
+ dlg.SetHeading(971); // group
+ int selected = 0;
+
+ for (int i = 0; i < Radio.AllRadioGroups.Count; ++i)
+ {
+ dlg.Add(Radio.AllRadioGroups[i].GroupName);
+ if (Radio.AllRadioGroups[i].GroupName == Radio.SelectedGroup.GroupName)
+ {
+ selected = i;
+ }
+ }
+
+ dlg.SelectedLabel = selected;
+ dlg.DoModal(GUIWindowManager.ActiveWindow);
+ if (dlg.SelectedLabel < 0)
+ {
+ return;
+ }
+
+ Radio.SelectedGroup = Radio.AllRadioGroups[dlg.SelectedId - 1];
+ GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Group", dlg.SelectedLabelText);
+
+ if (prevGroup != Radio.SelectedGroup.IdGroup)
+ {
+ GUIWaitCursor.Show();
+ _cursorY = 1; // cursor should be on the program guide item
+ ChannelOffset = 0;
+ // reset to top; otherwise focus could be out of screen if new group has less then old position
+ _cursorX = 0; // set to top, otherwise index could be out of range in new group
+
+ // group has been changed
+ GetChannels(true);
+ Update(false);
+
+ SetFocus();
+ GUIWaitCursor.Hide();
+ }
+ }
+ }
+
+ public override void Process()
+ {
+ OnKeyTimeout();
+
+ //if we did a manual rec. on the tvguide directly, then we have to wait for it to start and the update the GUI.
+ if (_recordingExpected != null)
+ {
+ TimeSpan ts = DateTime.Now - _updateTimerRecExpected;
+ if (ts.TotalMilliseconds > 1000)
+ {
+ _updateTimerRecExpected = DateTime.Now;
+ VirtualCard card;
+ if (_server.IsRecording(_recordingExpected.IdChannel, out card))
+ {
+ _recordingExpected = null;
+ GetChannels(true);
+ LoadSchedules(true);
+ _needUpdate = true;
+ }
+ }
+ }
+
+ if (_needUpdate)
+ {
+ _needUpdate = false;
+ Update(false);
+ SetFocus();
+ }
+
+ var vertLine = GetControl((int)Controls.VERTICAL_LINE) as GUIImage;
+ if (vertLine != null)
+ {
+ if (_singleChannelView)
+ {
+ vertLine.IsVisible = false;
+ }
+ else
+ {
+ vertLine.IsVisible = true;
+
+ DateTime dateNow = DateTime.Now.Date;
+ DateTime datePrev = _viewingTime.Date;
+ TimeSpan ts = dateNow - datePrev;
+ if (ts.TotalDays == 1)
+ {
+ _viewingTime = DateTime.Now;
+ }
+
+ if (_viewingTime.Date.Equals(DateTime.Now.Date) && _viewingTime < DateTime.Now)
+ {
+ int iStartX = GetControl((int)Controls.LABEL_TIME1).XPosition;
+ GUIControl guiControl = GetControl((int)Controls.LABEL_TIME1 + 1);
+ int iWidth = 1;
+ if (guiControl != null)
+ {
+ iWidth = guiControl.XPosition - iStartX;
+ }
+
+ iWidth *= 4;
+
+ int iMin = _viewingTime.Minute;
+ int iStartTime = _viewingTime.Hour * 60 + iMin;
+ int iCurTime = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
+ if (iCurTime >= iStartTime)
+ {
+ iCurTime -= iStartTime;
+ }
+ else
+ {
+ iCurTime = 24 * 60 + iCurTime - iStartTime;
+ }
+
+ int iTimeWidth = (_numberOfBlocks * _timePerBlock);
+ float fpos = (iCurTime) / ((float)(iTimeWidth));
+ fpos *= iWidth;
+ fpos += iStartX;
+ int width = vertLine.Width / 2;
+ vertLine.IsVisible = true;
+ vertLine.SetPosition((int)fpos - width, vertLine.YPosition);
+ vertLine.Select(0);
+ ts = DateTime.Now - _updateTimer;
+ if (ts.TotalMinutes >= 1)
+ {
+ if ((DateTime.Now - _viewingTime).TotalMinutes >= iTimeWidth / 2)
+ {
+ _cursorY = 0;
+ _viewingTime = DateTime.Now;
+ }
+ Update(false);
+ }
+ }
+ else
+ {
+ vertLine.IsVisible = false;
+ }
+ }
+ }
+ }
+
+ protected override void ShowContextMenu()
+ {
+ var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
+ if (dlg != null)
+ {
+ dlg.Reset();
+ dlg.SetHeading(GUILocalizeStrings.Get(924)); //Menu
+
+ if (_currentChannel != null)
+ {
+ dlg.AddLocalizedString(1213); // Listen to this Station
+ }
+
+ if (_currentProgram.IdProgram != 0)
+ {
+ dlg.AddLocalizedString(1041); //Upcoming episodes
+ }
+
+ if (_currentProgram != null && _currentProgram.StartTime > DateTime.Now)
+ {
+ if (_currentProgram.Notify)
+ {
+ dlg.AddLocalizedString(1212); // cancel reminder
+ }
+ else
+ {
+ dlg.AddLocalizedString(1040); // set reminder
+ }
+ }
+
+ dlg.AddLocalizedString(939); // Switch mode
+
+ if (_currentProgram != null && _currentChannel != null && _currentTitle.Length > 0)
+ {
+ if (_currentProgram.IdProgram == 0) // no EPG program recording., only allow to stop it.
+ {
+ bool isRecordingNoEPG = IsRecordingNoEPG(_currentProgram.ReferencedChannel());
+ if (isRecordingNoEPG)
+ {
+ dlg.AddLocalizedString(629); // stop non EPG Recording
+ }
+ else
+ {
+ dlg.AddLocalizedString(264); // start non EPG Recording
+ }
+ }
+ else if (!_currentRecOrNotify)
+ {
+ dlg.AddLocalizedString(264); // Record
+ }
+
+ else
+ {
+ dlg.AddLocalizedString(637); // Edit Recording
+ }
+ }
+
+ if (Radio.AllRadioGroups.Count > 1)
+ {
+ dlg.AddLocalizedString(971); // Group
+ }
+
+ dlg.DoModal(GetID);
+ if (dlg.SelectedLabel == -1)
+ {
+ return;
+ }
+ switch (dlg.SelectedId)
+ {
+ case 1041:
+ ShowProgramInfo();
+ Log.Debug("RadioGuide: show episodes or repeatings for current show");
+ break;
+ case 971: //group
+ OnSelectChannelGroup();
+ break;
+ case 1040: // set reminder
+ case 1212: // cancel reminder
+ OnNotify();
+ break;
+
+ case 1213: // listen to station
+
+ Log.Debug("viewch channel:{0}", _currentChannel);
+ Radio.Play();
+ if (_currentProgram != null && (TVHome.Card.IsTimeShifting && TVHome.Card.IdChannel == _currentProgram.ReferencedChannel().IdChannel))
+ {
+ g_Player.ShowFullScreenWindow();
+ }
+ return;
+
+
+ case 939: // switch mode
+ OnSwitchMode();
+ break;
+ case 629: //stop recording
+ if (_currentProgram != null)
+ {
+ Schedule schedule = Schedule.FindNoEPGSchedule(_currentProgram.ReferencedChannel());
+ TVUtil.DeleteRecAndEntireSchedWithPrompt(schedule);
+ }
+ Update(true); //remove RED marker
+ break;
+
+ case 637: // edit recording
+ case 264: // record
+ if (_currentProgram != null && _currentProgram.IdProgram == 0)
+ {
+ TVHome.StartRecordingSchedule(_currentProgram.ReferencedChannel(), true);
+ _currentProgram.IsRecordingOncePending = true;
+ Update(true); //remove RED marker
+ }
+ else
+ {
+ OnRecordContext();
+ }
+ break;
+ }
+ }
+ }
+
+ protected override void OnSelectItem(bool isItemSelected)
+ {
+ if (_currentProgram == null)
+ {
+ return;
+ }
+ Radio.CurrentChannel = _currentChannel;
+ if (isItemSelected)
+ {
+ if (_currentProgram.IsRunningAt(DateTime.Now) || _currentProgram.EndTime <= DateTime.Now)
+ {
+ //view this channel
+ if (g_Player.Playing && g_Player.IsTVRecording)
+ {
+ g_Player.Stop(true);
+ }
+ try
+ {
+ string fileName = "";
+ bool isRec = _currentProgram.IsRecording;
+
+ Recording rec = null;
+ if (isRec)
+ {
+ rec = Recording.ActiveRecording(_currentProgram.Title, _currentProgram.IdChannel);
+ }
+
+
+ if (rec != null)
+ {
+ fileName = rec.FileName;
+ }
+
+ if (!string.IsNullOrEmpty(fileName)) //are we really recording ?
+ {
+ Log.Info("RadioGuide: clicked on a currently running recording");
+ var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
+ if (dlg == null)
+ {
+ return;
+ }
+
+ dlg.Reset();
+ dlg.SetHeading(_currentProgram.Title);
+ dlg.AddLocalizedString(979); //Play recording from beginning
+ dlg.AddLocalizedString(1213); //Listen to this station
+ dlg.DoModal(GetID);
+
+ if (dlg.SelectedLabel == -1)
+ {
+ return;
+ }
+ if (_recordingList != null)
+ {
+ Log.Debug("RadioGuide: Found current program {0} in recording list", _currentTitle);
+ switch (dlg.SelectedId)
+ {
+ case 979: // Play recording from beginning
+ {
+ Recording recDB = Recording.Retrieve(fileName);
+ if (recDB != null)
+ {
+ GUIPropertyManager.RemovePlayerProperties();
+ GUIPropertyManager.SetProperty("#Play.Current.ArtistThumb", recDB.Description);
+ GUIPropertyManager.SetProperty("#Play.Current.Album", recDB.ReferencedChannel().DisplayName);
+ GUIPropertyManager.SetProperty("#Play.Current.Title", recDB.Description);
+
+ string strLogo = Utils.GetCoverArt(Thumbs.Radio, recDB.ReferencedChannel().DisplayName);
+ if (string.IsNullOrEmpty(strLogo))
+ {
+ strLogo = "defaultMyRadioBig.png";
+ }
+
+ GUIPropertyManager.SetProperty("#Play.Current.Thumb", strLogo);
+ TVUtil.PlayRecording(recDB, 0, g_Player.MediaType.Radio);
+ }
+ }
+ return;
+
+ case 1213: // listen to this station
+ {
+ Radio.Play();
+ if (g_Player.Playing)
+ {
+ g_Player.ShowFullScreenWindow();
+ }
+ }
+ return;
+ }
+ }
+ else
+ {
+ Log.Info("EPG: _recordingList was not available");
+ }
+
+
+ if (string.IsNullOrEmpty(fileName))
+ {
+ Radio.Play();
+ if (g_Player.Playing)
+ {
+ g_Player.ShowFullScreenWindow();
+ }
+ }
+ }
+ else //not recording
+ {
+ // clicked the show we're currently watching
+ if (Radio.CurrentChannel != null && Radio.CurrentChannel.IdChannel == _currentChannel.IdChannel &&
+ g_Player.Playing)
+ {
+ Log.Debug("RadioGuide: clicked on a currently running show");
+ var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
+ if (dlg == null)
+ {
+ return;
+ }
+
+ dlg.Reset();
+ dlg.SetHeading(_currentProgram.Title);
+ dlg.AddLocalizedString(1213); //Listen to this Station
+ dlg.AddLocalizedString(1041); //Upcoming episodes
+ dlg.DoModal(GetID);
+
+ if (dlg.SelectedLabel == -1)
+ {
+ return;
+ }
+
+ switch (dlg.SelectedId)
+ {
+ case 1041:
+ ShowProgramInfo();
+ Log.Debug("RadioGuide: show episodes or repeatings for current show");
+ break;
+ case 1213:
+ Log.Debug("RadioGuide: switch currently running show to fullscreen");
+ GUIWaitCursor.Show();
+ Radio.Play();
+ GUIWaitCursor.Hide();
+ if (g_Player.Playing)
+ {
+ g_Player.ShowFullScreenWindow();
+ }
+ else
+ {
+ Log.Debug("RadioGuide: no show currently running to switch to fullscreen");
+ }
+ break;
+ }
+ }
+ else
+ {
+ bool isPlayingTV = (g_Player.FullScreen && g_Player.IsTV);
+ // zap to selected show's channel
+ TVHome.UserChannelChanged = true;
+ // fixing mantis 1874: TV doesn't start when from other playing media to TVGuide & select program
+ GUIWaitCursor.Show();
+ Radio.Play();
+ GUIWaitCursor.Hide();
+ if (g_Player.Playing)
+ {
+ if (isPlayingTV) GUIWindowManager.CloseCurrentWindow();
+ g_Player.ShowFullScreenWindow();
+ }
+ }
+ } //end of not recording
+ }
+ finally
+ {
+ if (VMR9Util.g_vmr9 != null)
+ {
+ VMR9Util.g_vmr9.Enable(true);
+ }
+ }
+
+ return;
+ }
+ ShowProgramInfo();
+ return;
+ }
+ ShowProgramInfo();
+ }
+
+ /// <summary>
+ /// "Record" via REC button
+ /// </summary>
+ protected override void OnRecord()
+ {
+ if (_currentProgram == null)
+ {
+ return;
+ }
+ if ((_currentProgram.IsRunningAt(DateTime.Now) ||
+ (_currentProgram.EndTime <= DateTime.Now)))
+ {
+ //record current programme
+ GUIWindow tvHome = GUIWindowManager.GetWindow((int)Window.WINDOW_TV);
+ if ((tvHome != null) && (tvHome.GetID != GUIWindowManager.ActiveWindow))
+ {
+ bool didRecStart = TVHome.ManualRecord(_currentProgram.ReferencedChannel(), GetID);
+ //refresh view.
+ if (didRecStart)
+ {
+ _recordingExpected = _currentProgram.ReferencedChannel();
+ }
+ }
+ }
+ else
+ {
+ ShowProgramInfo();
+ }
+ }
+
+ protected override IList<Channel> GetGuideChannelsForGroup()
+ {
+ return _layer.GetRadioGuideChannelsForGroup(Radio.SelectedGroup.IdGroup);
+ }
+
+ protected override bool HasSelectedGroup()
+ {
+ return (Radio.SelectedGroup != null);
+ }
+
+ protected override bool IsChannelTypeCorrect(Channel channel)
+ {
+ return (channel.IsRadio);
+ }
+
+ #endregion
+ }
+}
View
7 TVLibrary/TvPlugin/TvPlugin/TVGuide.cs → TVLibrary/TvPlugin/TvPlugin/EPG/TVGuide.cs
@@ -26,15 +26,14 @@
namespace TvPlugin
{
- public class TVGuide : TvGuideBase
+ public sealed class TVGuide : TvGuideBase
{
- [SkinControl(98)] protected GUIImage videoBackground;
- [SkinControl(99)] protected GUIVideoControl videoWindow;
+ [SkinControl(98)] private GUIImage _videoBackground;
+ [SkinControl(99)] private GUIVideoControl _videoWindow;
#region Ctor
public TVGuide()
- : base()
{
GetID = (int)Window.WINDOW_TVGUIDE;
}
View
997 TVLibrary/TvPlugin/TvPlugin/EPG/TvGuideBase.cs
@@ -0,0 +1,997 @@
+#region Copyright (C) 2005-2010 Team MediaPortal
+
+// Copyright (C) 2005-2010 Team MediaPortal
+// http://www.team-mediaportal.com
+//
+// MediaPortal is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// MediaPortal is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
+
+#endregion
+
+#region usings
+
+using System;
+using System.Collections.Generic;
+using MediaPortal.Dialogs;
+using MediaPortal.GUI.Library;
+using MediaPortal.GUI.Video;
+using MediaPortal.Player;
+using MediaPortal.Util;
+using MediaPortal.Video.Database;
+using TvControl;
+using TvDatabase;
+
+#endregion
+
+namespace TvPlugin
+{
+ /// <summary>
+ ///
+ /// </summary>
+ public class TvGuideBase : GuideBase, IMDB.IProgress
+ {
+ #region constants
+
+ private const string SKIN_PROPERTY_PREFIX = "#TV";
+ private const string SETTINGS_GUIDE_SECTION = "tvguide";
+ private const string SETTINGS_SECTION = "mytv";
+
+ #endregion
+
+ #region vars
+
+ private readonly List<Channel> _recordingsExpected = new List<Channel>();
+ private readonly object _recordingsExpectedLock = new object();
+
+ #endregion
+
+ #region overrides
+
+ /// <summary>
+ /// changes the current channel group and refreshes guide display
+ /// </summary>
+ /// <param name="direction"></param>
+ protected override void OnChangeChannelGroup(int direction)
+ {
+ // in single channel view there would be errors when changing group
+ if (_singleChannelView) return;
+ int oldIndex;
+ int countGroups = TVHome.Navigator.Groups.Count; // all
+
+ int newIndex = oldIndex = TVHome.Navigator.CurrentGroupIndex;
+ if (
+ (newIndex >= 1 && direction < 0) ||
+ (newIndex < countGroups - 1 && direction > 0)
+ )
+ {
+ newIndex += direction; // change group
+ }
+ else // Cycle handling
+ if ((newIndex == countGroups - 1) && direction > 0)
+ {
+ newIndex = 0;
+ }
+ else if (newIndex == 0 && direction < 0)
+ {
+ newIndex = countGroups - 1;
+ }
+
+ if (oldIndex != newIndex)
+ {
+ // update list
+ GUIWaitCursor.Show();
+ TVHome.Navigator.SetCurrentGroup(newIndex);
+ GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Group", TVHome.Navigator.CurrentGroup.GroupName);
+
+ _cursorY = 1; // cursor should be on the program guide item
+ ChannelOffset = 0;
+ // reset to top; otherwise focus could be out of screen if new group has less then old position
+ _cursorX = 0; // first channel
+ GetChannels(true);
+ Update(false);
+ SetFocus();
+ GUIWaitCursor.Hide();
+ }
+ }
+
+ protected override void WindowInit(GUIMessage message)
+ {
+ bool isPreviousWindowTvGuideRelated = (message.Param1 == (int)Window.WINDOW_TV_PROGRAM_INFO ||
+ message.Param1 == (int)Window.WINDOW_VIDEO_INFO);
+
+ if (!isPreviousWindowTvGuideRelated)
+ {
+ UnFocus();
+ }
+
+ GetChannels(true);
+ LoadSchedules(true);
+ _currentProgram = null;
+ if (!isPreviousWindowTvGuideRelated)
+ {
+ _viewingTime = DateTime.Now;
+ _cursorY = 0;
+ _cursorX = 0;
+ ChannelOffset = 0;
+ _singleChannelView = false;
+ _showChannelLogos = false;
+ if (TVHome.Card.IsTimeShifting)
+ {
+ _currentChannel = TVHome.Navigator.Channel;
+ for (int i = 0; i < _channelList.Count; i++)
+ {
+ Channel chan = (_channelList[i]).Channel;
+ if (chan.IdChannel == _currentChannel.IdChannel)
+ {
+ _cursorX = i;
+ break;
+ }
+ }
+ }
+ }
+ while (_cursorX >= _channelCount)
+ {
+ _cursorX -= _channelCount;
+ ChannelOffset += _channelCount;
+ }
+ // Mantis 3579: the above lines can lead to too large channeloffset.
+ // Now we check if the offset is too large, and if it is, we reduce it and increase the cursor position accordingly
+ if (!_guideContinuousScroll && (ChannelOffset > _channelList.Count - _channelCount) &&
+ (_channelList.Count - _channelCount > 0))
+ {
+ _cursorX += ChannelOffset - (_channelList.Count - _channelCount);
+ ChannelOffset = _channelList.Count - _channelCount;
+ }
+ var cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl;
+ if (cntlDay != null)
+ {
+ DateTime dtNow = DateTime.Now;
+ cntlDay.Reset();
+ cntlDay.SetRange(0, MAX_DAYS_IN_GUIDE - 1);
+ for (int iDay = 0; iDay < MAX_DAYS_IN_GUIDE; iDay++)
+ {
+ DateTime dtTemp = dtNow.AddDays(iDay);
+ string day;
+ switch (dtTemp.DayOfWeek)
+ {
+ case DayOfWeek.Monday:
+ day = GUILocalizeStrings.Get(657);
+ break;
+ case DayOfWeek.Tuesday:
+ day = GUILocalizeStrings.Get(658);
+ break;
+ case DayOfWeek.Wednesday:
+ day = GUILocalizeStrings.Get(659);
+ break;
+ case DayOfWeek.Thursday:
+ day = GUILocalizeStrings.Get(660);
+ break;
+ case DayOfWeek.Friday:
+ day = GUILocalizeStrings.Get(661);
+ break;
+ case DayOfWeek.Saturday:
+ day = GUILocalizeStrings.Get(662);
+ break;
+ default:
+ day = GUILocalizeStrings.Get(663);
+ break;
+ }
+ day = String.Format("{0} {1}-{2}", day, dtTemp.Day, dtTemp.Month);
+ cntlDay.AddLabel(day, iDay);
+ }
+ }
+ else
+ {
+ Log.Debug("TvGuideBase: SpinControl cntlDay is null!");
+ }
+
+ var cntlTimeInterval = GetControl((int)Controls.SPINCONTROL_TIME_INTERVAL) as GUISpinControl;
+ if (cntlTimeInterval != null)
+ {
+ cntlTimeInterval.Reset();
+ for (int i = 1; i <= 4; i++)
+ {
+ cntlTimeInterval.AddLabel(String.Empty, i);
+ }
+ cntlTimeInterval.Value = (_timePerBlock / 15) - 1;
+ }
+ else
+ {
+ Log.Debug("TvGuideBase: SpinControl cntlTimeInterval is null!");
+ }
+
+ if (!isPreviousWindowTvGuideRelated)
+ {
+ Update(true);
+ }
+ else
+ {
+ Update(false);
+ }
+
+ SetFocus();
+
+ if (_currentProgram != null)
+ {
+ _startTime = _currentProgram.StartTime;
+ }
+ UpdateCurrentProgram();
+ }
+
+ /// <summary>
+ /// Shows channel group selection dialog
+ /// </summary>
+ protected override void OnSelectChannelGroup()
+ {
+ // only if more groups present and not in singleChannelView
+ if (TVHome.Navigator.Groups.Count > 1 && !_singleChannelView)
+ {
+ int prevGroup = TVHome.Navigator.CurrentGroup.IdGroup;
+
+ TVHome.OnSelectGroup();
+
+ if (prevGroup != TVHome.Navigator.CurrentGroup.IdGroup)
+ {
+ GUIWaitCursor.Show();
+ _cursorY = 1; // cursor should be on the program guide item
+ ChannelOffset = 0;
+ // reset to top; otherwise focus could be out of screen if new group has less then old position
+ _cursorX = 0; // set to top, otherwise index could be out of range in new group
+ // group has been changed
+ GetChannels(true);
+ Update(false);
+
+ SetFocus();
+ GUIWaitCursor.Hide();
+ }
+ }
+ }
+
+ public override void Process()
+ {
+ TVHome.UpdateProgressPercentageBar();
+
+ OnKeyTimeout();
+ UpdateRecStateOnExpectedRecordings();
+
+ if (_needUpdate)
+ {
+ _needUpdate = false;
+ Update(false);
+ SetFocus();
+ }
+
+ var vertLine = GetControl((int)Controls.VERTICAL_LINE) as GUIImage;
+ if (vertLine != null)
+ {
+ if (_singleChannelView)
+ {
+ vertLine.IsVisible = false;
+ }
+ else
+ {
+ vertLine.IsVisible = true;
+
+ DateTime dateNow = DateTime.Now.Date;
+ DateTime datePrev = _viewingTime.Date;
+ TimeSpan ts = dateNow - datePrev;
+ if (ts.TotalDays == 1)
+ {
+ _viewingTime = DateTime.Now;
+ }
+
+ if (_viewingTime.Date.Equals(DateTime.Now.Date) && _viewingTime < DateTime.Now)
+ {
+ int iStartX = GetControl((int)Controls.LABEL_TIME1).XPosition;
+ int iWidth = GetControl((int)Controls.LABEL_TIME1 + 1).XPosition - iStartX;
+ iWidth *= 4;
+
+ int iMin = _viewingTime.Minute;
+ int iStartTime = _viewingTime.Hour * 60 + iMin;
+ int iCurTime = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
+ if (iCurTime >= iStartTime)
+ {
+ iCurTime -= iStartTime;
+ }
+ else
+ {
+ iCurTime = 24 * 60 + iCurTime - iStartTime;
+ }
+
+ int iTimeWidth = (_numberOfBlocks * _timePerBlock);
+ float fpos = (iCurTime) / ((float)(iTimeWidth));
+ fpos *= iWidth;
+ fpos += iStartX;
+ int width = vertLine.Width / 2;
+ vertLine.IsVisible = true;
+ vertLine.SetPosition((int)fpos - width, vertLine.YPosition);
+ vertLine.Select(0);
+ ts = DateTime.Now - _updateTimer;
+ if (ts.TotalMinutes >= 1)
+ {
+ if ((DateTime.Now - _viewingTime).TotalMinutes >= iTimeWidth / 2)
+ {
+ _cursorY = 0;
+ _viewingTime = DateTime.Now;
+ }
+ Update(false);
+ }
+ }
+ else
+ {
+ vertLine.IsVisible = false;
+ }
+ }
+ }
+ }
+
+ protected override void OnSelectItem(bool isItemSelected)
+ {
+ if (_currentProgram == null)
+ {
+ return;
+ }
+ if (isItemSelected)
+ {
+ if (_currentProgram.IsRunningAt(DateTime.Now) || _currentProgram.EndTime <= DateTime.Now)
+ {
+ //view this channel
+ if (g_Player.Playing && g_Player.IsTVRecording)
+ {
+ g_Player.Stop(true);
+ }
+ try
+ {
+ string fileName = "";
+ bool isRec = _currentProgram.IsRecording;
+
+ Recording rec = null;
+ if (isRec)
+ {
+ rec = Recording.ActiveRecording(_currentProgram.Title, _currentProgram.IdChannel);
+ }
+
+
+ if (rec != null)
+ {
+ fileName = rec.FileName;
+ }
+
+ if (!string.IsNullOrEmpty(fileName)) //are we really recording ?
+ {
+ Log.Info("TVGuide: clicked on a currently running recording");
+ var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
+ if (dlg == null)
+ {
+ return;
+ }
+
+ dlg.Reset();
+ dlg.SetHeading(_currentProgram.Title);
+ dlg.AddLocalizedString(979); //Play recording from beginning
+ dlg.AddLocalizedString(938); //View this channel
+ dlg.DoModal(GetID);
+
+ if (dlg.SelectedLabel == -1)
+ {
+ return;
+ }
+ if (_recordingList != null)
+ {
+ Log.Debug("TVGuide: Found current program {0} in recording list", _currentTitle);
+ switch (dlg.SelectedId)
+ {
+ case 979: // Play recording from beginning
+ {
+ Recording recDB = Recording.Retrieve(fileName);
+ if (recDB != null)
+ {
+ TVUtil.PlayRecording(recDB);
+ }
+ }
+ return;
+
+ case 938: // View this channel
+ {
+ TVHome.ViewChannelAndCheck(_currentProgram.ReferencedChannel());
+ if (g_Player.Playing)
+ {
+ g_Player.ShowFullScreenWindow();
+ }
+ }
+ return;
+ }
+ }
+ else
+ {
+ Log.Info("EPG: _recordingList was not available");
+ }
+
+
+ if (string.IsNullOrEmpty(fileName))
+ {
+ TVHome.ViewChannelAndCheck(_currentProgram.ReferencedChannel());
+ if (g_Player.Playing)
+ {
+ g_Player.ShowFullScreenWindow();
+ }
+ }
+ }
+ else //not recording
+ {
+ // clicked the show we're currently watching
+ if (TVHome.Navigator.Channel != null && TVHome.Navigator.Channel.IdChannel == _currentChannel.IdChannel &&
+ g_Player.Playing && g_Player.IsTV)
+ {
+ Log.Debug("TVGuide: clicked on a currently running show");
+ var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
+ if (dlg == null)
+ {
+ return;
+ }
+
+ dlg.Reset();
+ dlg.SetHeading(_currentProgram.Title);
+ dlg.AddLocalizedString(938); //View this channel
+ dlg.AddLocalizedString(1041); //Upcoming episodes
+ dlg.DoModal(GetID);
+
+ if (dlg.SelectedLabel == -1)
+ {
+ return;
+ }
+
+ switch (dlg.SelectedId)
+ {
+ case 1041:
+ ShowProgramInfo();
+ Log.Debug("TVGuide: show episodes or repeatings for current show");
+ break;
+ case 938:
+ Log.Debug("TVGuide: switch currently running show to fullscreen");
+ GUIWaitCursor.Show();
+ TVHome.ViewChannelAndCheck(_currentProgram.ReferencedChannel());
+ GUIWaitCursor.Hide();
+ if (g_Player.Playing)
+ {
+ g_Player.ShowFullScreenWindow();
+ }
+ else
+ {
+ Log.Debug("TVGuide: no show currently running to switch to fullscreen");
+ }
+ break;
+ }
+ }
+ else
+ {
+ bool isPlayingTV = (g_Player.FullScreen && g_Player.IsTV);
+ // zap to selected show's channel
+ TVHome.UserChannelChanged = true;
+ // fixing mantis 1874: TV doesn't start when from other playing media to TVGuide & select program
+ GUIWaitCursor.Show();
+ TVHome.ViewChannelAndCheck(_currentProgram.ReferencedChannel());
+ GUIWaitCursor.Hide();
+ if (g_Player.Playing)
+ {
+ if (isPlayingTV) GUIWindowManager.CloseCurrentWindow();
+ g_Player.ShowFullScreenWindow();
+ }
+ }
+ } //end of not recording
+ }
+ finally
+ {
+ if (VMR9Util.g_vmr9 != null)
+ {
+ VMR9Util.g_vmr9.Enable(true);
+ }
+ }
+
+ return;
+ }
+ ShowProgramInfo();
+ return;
+ }
+ ShowProgramInfo();
+ }
+
+ /// <summary>
+ /// "Record" via REC button
+ /// </summary>
+ protected override void OnRecord()
+ {
+ if (_currentProgram == null)
+ {
+ return;
+ }
+ if ((_currentProgram.IsRunningAt(DateTime.Now) ||
+ (_currentProgram.EndTime <= DateTime.Now)))
+ {
+ //record current programme
+ GUIWindow tvHome = GUIWindowManager.GetWindow((int)Window.WINDOW_TV);
+ if ((tvHome != null) && (tvHome.GetID != GUIWindowManager.ActiveWindow))
+ {
+ bool didRecStart = TVHome.ManualRecord(_currentProgram.ReferencedChannel(), GetID);
+ _currentProgram.IsRecordingOncePending = didRecStart;
+ //refresh view.
+ if (didRecStart)
+ {
+ lock (_recordingsExpectedLock)
+ {
+ _recordingsExpected.Add(_currentProgram.ReferencedChannel());
+ }
+ }
+ else
+ {
+ lock (_recordingsExpectedLock)
+ {
+ if (_recordingsExpected.Contains(_currentProgram.ReferencedChannel()))
+ {
+ _recordingsExpected.Remove(_currentProgram.ReferencedChannel());
+ }
+ }
+ }
+ _needUpdate = true;
+ }
+ }
+ else
+ {
+ ShowProgramInfo();
+ }
+ }
+
+ protected override bool IsChannelTypeCorrect(Channel channel)
+ {
+ return (channel.IsTv);
+ }
+
+ protected override IList<Channel> GetGuideChannelsForGroup()
+ {
+ return _layer.GetTVGuideChannelsForGroup(TVHome.Navigator.CurrentGroup.IdGroup);
+ }
+
+ protected override bool HasSelectedGroup()
+ {
+ return (TVHome.Navigator.CurrentGroup != null);
+ }
+
+ protected override void ShowContextMenu()
+ {
+ var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
+ if (dlg != null)
+ {
+ dlg.Reset();
+ dlg.SetHeading(GUILocalizeStrings.Get(924)); //Menu
+
+ if (_currentChannel != null)
+ {
+ dlg.AddLocalizedString(938); // View this channel
+ }
+
+ if (_currentProgram.IdProgram != 0)
+ {
+ dlg.AddLocalizedString(1041); //Upcoming episodes
+ }
+
+ if (_currentProgram != null && _currentProgram.StartTime > DateTime.Now)
+ {
+ if (_currentProgram.Notify)
+ {
+ dlg.AddLocalizedString(1212); // cancel reminder
+ }
+ else
+ {
+ dlg.AddLocalizedString(1040); // set reminder
+ }
+ }
+
+ dlg.AddLocalizedString(939); // Switch mode
+
+ if (_currentProgram != null && _currentChannel != null && _currentTitle.Length > 0)
+ {
+ if (_currentProgram.IdProgram == 0) // no EPG program recording., only allow to stop it.
+ {
+ bool isRecordingNoEPG = IsRecordingNoEPG(_currentProgram.ReferencedChannel());
+ if (isRecordingNoEPG)
+ {
+ dlg.AddLocalizedString(629); // stop non EPG Recording
+ }
+ else
+ {
+ dlg.AddLocalizedString(264); // start non EPG Recording
+ }
+ }
+ else if (!_currentRecOrNotify)
+ {
+ dlg.AddLocalizedString(264); // Record
+ }
+
+ else
+ {
+ dlg.AddLocalizedString(637); // Edit Recording
+ }
+ }
+
+ if (TVHome.Navigator.Groups.Count > 1)
+ {
+ dlg.AddLocalizedString(971); // Group
+ }
+
+ dlg.AddLocalizedString(368); // IMDB
+
+ dlg.DoModal(GetID);
+ if (dlg.SelectedLabel == -1)
+ {
+ return;
+ }
+ switch (dlg.SelectedId)
+ {
+ case 1041:
+ ShowProgramInfo();
+ Log.Debug("TVGuide: show episodes or repeatings for current show");
+ break;
+ case 368: // IMDB
+ OnGetIMDBInfo();
+ break;
+ case 971: //group
+ OnSelectChannelGroup();
+ break;
+ case 1040: // set reminder
+ case 1212: // cancel reminder
+ OnNotify();
+ break;
+
+ case 938: // view channel
+
+ Log.Debug("viewch channel:{0}", _currentChannel);
+ if (_currentProgram != null)
+ {
+ TVHome.ViewChannelAndCheck(_currentProgram.ReferencedChannel());
+ if (TVHome.Card.IsTimeShifting && TVHome.Card.IdChannel == _currentProgram.ReferencedChannel().IdChannel)
+ {
+ g_Player.ShowFullScreenWindow();
+ }
+ }
+ return;
+
+
+ case 939: // switch mode
+ OnSwitchMode();
+ break;
+ case 629: //stop recording
+ if (_currentProgram != null)
+ {
+ Schedule schedule = Schedule.FindNoEPGSchedule(_currentProgram.ReferencedChannel());
+ TVUtil.DeleteRecAndEntireSchedWithPrompt(schedule);
+ }
+ Update(true); //remove RED marker
+ break;
+
+ case 637: // edit recording
+ case 264: // record
+ if (_currentProgram != null && _currentProgram.IdProgram == 0)
+ {
+ TVHome.StartRecordingSchedule(_currentProgram.ReferencedChannel(), true);
+ _currentProgram.IsRecordingOncePending = true;
+ Update(true); //add RED marker
+ }
+ else
+ {
+ OnRecordContext();
+ }
+ break;
+ }
+ }
+ }
+
+ #endregion
+
+ #region private methods
+
+ private void UpdateRecStateOnExpectedRecordings()
+ {
+ //if we did a manual rec. on the tvguide directly, then we have to wait for it to start and the update the GUI.
+ bool wasAnyRecordingExpectedStarted = false;
+ lock (_recordingsExpectedLock)
+ {
+ if (_recordingsExpected.Count > 0)
+ {
+ TimeSpan ts = DateTime.Now - _updateTimerRecExpected;
+ if (ts.TotalMilliseconds > 1000)
+ {
+ _updateTimerRecExpected = DateTime.Now;
+ IList<Channel> recordingsExpectedToRemove = new List<Channel>();
+ foreach (Channel recordingExpected in _recordingsExpected)
+ {
+ VirtualCard card;
+ if (_server.IsRecording(recordingExpected.IdChannel, out card))
+ {
+ wasAnyRecordingExpectedStarted = true;
+ recordingsExpectedToRemove.Add(recordingExpected);
+ }
+ }
+ _recordingsExpected.RemoveAll(recordingsExpectedToRemove.Contains);
+ }
+ }
+ }
+
+ if (wasAnyRecordingExpectedStarted)
+ {
+ GetChannels(true);
+ LoadSchedules(true);
+ _needUpdate = true;
+ }
+ }
+
+ private void OnGetIMDBInfo()
+ {
+ var movieDetails = new IMDBMovie {SearchString = _currentProgram.Title};
+ if (IMDBFetcher.GetInfoFromIMDB(this, ref movieDetails, true, false))
+ {
+ var dbLayer = new TvBusinessLayer();
+
+ IList<Program> progs = dbLayer.GetProgramExists(Channel.Retrieve(_currentProgram.IdChannel),
+ _currentProgram.StartTime, _currentProgram.EndTime);
+ if (progs != null && progs.Count > 0)
+ {
+ Program prog = progs[0];
+ prog.Description = movieDetails.Plot;
+ prog.Genre = movieDetails.Genre;
+ prog.StarRating = (int)movieDetails.Rating;
+ prog.Persist();
+ }
+ var videoInfo = (GUIVideoInfo)GUIWindowManager.GetWindow((int)Window.WINDOW_VIDEO_INFO);
+ videoInfo.Movie = movieDetails;
+ var btnPlay = (GUIButtonControl)videoInfo.GetControl(2);
+ btnPlay.Visible = false;
+ GUIWindowManager.ActivateWindow((int)Window.WINDOW_VIDEO_INFO);
+ }
+ else
+ {
+ Log.Info("IMDB Fetcher: Nothing found");
+ }
+ }
+
+ #endregion
+
+ #region property overrides
+
+ protected override string SkinPropertyPrefix
+ {
+ get { return SKIN_PROPERTY_PREFIX; }
+ }
+
+ protected override string SettingsGuideSection
+ {
+ get { return SETTINGS_GUIDE_SECTION; }
+ }
+
+ protected override string SettingsSection
+ {
+ get { return SETTINGS_SECTION; }
+ }
+
+ protected override int ChannelGroupCount
+ {
+ get { return TVHome.Navigator.Groups.Count; }
+ }
+
+ protected override string CurrentGroupName
+ {
+ get { return TVHome.Navigator.CurrentGroup.GroupName; }
+ }
+
+ protected override string Thumb
+ {
+ get { return Thumbs.TVChannel; }
+ }
+
+ protected override string DefaultThumb
+ {
+ get { return "defaultVideoBig.png"; }
+ }
+
+ #endregion
+
+ #region IMDB.IProgress
+
+ public bool OnDisableCancel(IMDBFetcher fetcher)
+ {
+ var pDlgProgress =
+ (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
+ if (pDlgProgress.IsInstance(fetcher))
+ {
+ pDlgProgress.DisableCancel(true);
+ }
+ return true;
+ }
+
+ public void OnProgress(string line1, string line2, string line3, int percent)
+ {
+ if (!GUIWindowManager.IsRouted)
+ {
+ return;
+ }
+ var pDlgProgress =
+ (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
+ pDlgProgress.ShowProgressBar(true);
+ pDlgProgress.SetLine(1, line1);
+ pDlgProgress.SetLine(2, line2);
+ if (percent > 0)
+ {
+ pDlgProgress.SetPercentage(percent);
+ }
+ pDlgProgress.Progress();
+ }
+
+ public bool OnSearchStarting(IMDBFetcher fetcher)
+ {
+ var pDlgProgress =
+ (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
+ // show dialog that we're busy querying www.imdb.com
+ pDlgProgress.Reset();
+ pDlgProgress.SetHeading(GUILocalizeStrings.Get(197));
+ pDlgProgress.SetLine(1, fetcher.MovieName);
+ pDlgProgress.SetLine(2, string.Empty);
+ pDlgProgress.SetObject(fetcher);
+ pDlgProgress.StartModal(GUIWindowManager.ActiveWindow);
+ return true;
+ }
+
+ public bool OnSearchStarted(IMDBFetcher fetcher)
+ {
+ var pDlgProgress =
+ (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
+ pDlgProgress.SetObject(fetcher);
+ pDlgProgress.DoModal(GUIWindowManager.ActiveWindow);
+ if (pDlgProgress.IsCanceled)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public bool OnSearchEnd(IMDBFetcher fetcher)
+ {
+ var pDlgProgress =
+ (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
+ if ((pDlgProgress != null) && (pDlgProgress.IsInstance(fetcher)))
+ {
+ pDlgProgress.Close();
+ }
+ return true;
+ }
+
+ public bool OnMovieNotFound(IMDBFetcher fetcher)
+ {
+ Log.Info("IMDB Fetcher: OnMovieNotFound");
+ // show dialog...
+ var dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
+ dlgOK.SetHeading(195);
+ dlgOK.SetLine(1, fetcher.MovieName);
+ dlgOK.SetLine(2, string.Empty);
+ dlgOK.DoModal(GUIWindowManager.ActiveWindow);
+ return true;
+ }
+
+ public bool OnDetailsStarting(IMDBFetcher fetcher)
+ {
+ var pDlgProgress =
+ (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
+ // show dialog that we're downloading the movie info
+ pDlgProgress.Reset();
+ pDlgProgress.SetHeading(GUILocalizeStrings.Get(198));
+ pDlgProgress.SetLine(1, fetcher.MovieName);
+ pDlgProgress.SetLine(2, string.Empty);
+ pDlgProgress.SetObject(fetcher);
+ pDlgProgress.StartModal(GUIWindowManager.ActiveWindow);
+ return true;
+ }
+
+ public bool OnDetailsStarted(IMDBFetcher fetcher)
+ {
+ var pDlgProgress =
+ (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
+ pDlgProgress.SetObject(fetcher);
+ pDlgProgress.DoModal(GUIWindowManager.ActiveWindow);
+ if (pDlgProgress.IsCanceled)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public bool OnDetailsEnd(IMDBFetcher fetcher)
+ {
+ var pDlgProgress =
+ (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
+ if ((pDlgProgress != null) && (pDlgProgress.IsInstance(fetcher)))
+ {
+ pDlgProgress.Close();
+ }
+ return true;
+ }
+
+ public bool OnActorsStarting(IMDBFetcher fetcher)
+ {
+ // won't occure
+ return true;
+ }
+
+ public bool OnActorsStarted(IMDBFetcher fetcher)
+ {
+ // won't occure
+ return true;
+ }
+
+ public bool OnActorsEnd(IMDBFetcher fetcher)
+ {
+ // won't occure
+ return true;
+ }
+
+ public bool OnDetailsNotFound(IMDBFetcher fetcher)
+ {
+ Log.Info("IMDB Fetcher: OnDetailsNotFound");
+ // show dialog...
+ var dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
+ // show dialog...
+ dlgOk.SetHeading(195);
+ dlgOk.SetLine(1, fetcher.MovieName);
+ dlgOk.SetLine(2, string.Empty);
+ dlgOk.DoModal(GUIWindowManager.ActiveWindow);
+ return false;
+ }
+
+ public bool OnRequestMovieTitle(IMDBFetcher fetcher, out string movieName)
+ {
+ // won't occure
+ movieName = "";
+ return true;
+ }
+
+ public bool OnSelectMovie(IMDBFetcher fetcher, out int selectedMovie)
+ {
+ // won't occure
+ selectedMovie = 0;
+ return true;
+ }
+
+ public bool OnScanStart(int total)
+ {
+ // won't occure
+ return true;
+ }
+
+ public bool OnScanEnd()
+ {
+ // won't occure
+ return true;
+ }
+
+ public bool OnScanIterating(int count)
+ {
+ // won't occure
+ return true;
+ }
+
+ public bool OnScanIterated(int count)
+ {
+ // won't occure
+ return true;
+ }
+
+ #endregion
+ }
+}
View
529 TVLibrary/TvPlugin/TvPlugin/GuideBase.cs
@@ -1,529 +0,0 @@
-#region Copyright (C) 2005-2010 Team MediaPortal
-
-// Copyright (C) 2005-2010 Team MediaPortal
-// http://www.team-mediaportal.com
-//
-// MediaPortal is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 2 of the License, or
-// (at your option) any later version.
-//
-// MediaPortal is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with MediaPortal. If not, see <http://www.gnu.org/licenses/>.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using MediaPortal.Dialogs;
-using MediaPortal.GUI.Library;
-using MediaPortal.Util;
-using TvDatabase;
-
-namespace TvPlugin
-{
- public abstract class GuideBase : GUIDialogWindow
- {
- protected const int MaxDaysInGuide = 30;
- protected const int RowID = 1000;
- protected const int ColID = 10;
- protected const int GUIDE_COMPONENTID_START = 50000;
- private int _channelOffset = 0;
- protected DateTime _viewingTime = DateTime.Now;
- protected DateTime _updateTimer = DateTime.Now;
- protected GUILabelControl _titleDarkTemplate;
- protected GUILabelControl _titleTemplate;
- protected GUILabelControl _genreDarkTemplate;
- protected GUILabelControl _genreTemplate;
- protected GUIButton3PartControl _programPartialRecordTemplate;
- protected GUIButton3PartControl _programRecordTemplate;
- protected GUIButton3PartControl _programNotifyTemplate;
- protected GUIButton3PartControl _programNotRunningTemplate;
- protected GUIButton3PartControl _programRunningTemplate;
- protected bool _showChannelLogos = false;
- protected int _timePerBlock = 30; // steps of 30 minutes
- protected bool _singleChannelView = false;
- protected int _channelCount = 5;
- protected List<GuideChannel> _channelList = new List<GuideChannel>();
- protected int _singleChannelNumber = 0;
- protected int _cursorY = 0;
- protected int _cursorX = 0;
- protected Channel _currentChannel = null;
- protected int _numberOfBlocks = 4;
-
- protected int ChannelOffset
- {
- get { return _channelOffset; }
- set
- {
- _channelOffset = value;
- if (_channelOffset < 0)
- {
- _channelOffset = 0;
- }
- }
- }
-
- protected void Update(bool selectCurrentShow)
- {
- lock (this)
- {
- if (GUIWindowManager.ActiveWindowEx != this.GetID)
- {
- return;
- }
-
- // sets button visible state
- UpdateGroupButton();
-
- _updateTimer = DateTime.Now;
- GUISpinControl cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl;
-
- // Find first day in TVGuide and set spincontrol position
- int iDay = CalcDays();
- for (; iDay < 0; ++iDay)
- {
- _viewingTime = _viewingTime.AddDays(1.0);
- }
- for (; iDay >= MaxDaysInGuide; --iDay)
- {
- _viewingTime = _viewingTime.AddDays(-1.0);
- }
- cntlDay.Value = iDay;
-
- int xpos, ypos;
- GUIControl cntlPanel = GetControl((int)Controls.PANEL_BACKGROUND);
- GUIImage cntlChannelImg = (GUIImage)GetControl((int)Controls.CHANNEL_IMAGE_TEMPLATE);
- GUILabelControl cntlChannelLabel = (GUILabelControl)GetControl((int)Controls.CHANNEL_LABEL_TEMPLATE);
- GUILabelControl labelTime = (GUILabelControl)GetControl((int)Controls.LABEL_TIME1);
- GUIImage cntlHeaderBkgImg = (GUIImage)GetControl((int)Controls.IMG_TIME1);
- GUIImage cntlChannelTemplate = (GUIImage)GetControl((int)Controls.CHANNEL_TEMPLATE);
-
-
- _titleDarkTemplate = GetControl((int)Controls.LABEL_TITLE_DARK_TEMPLATE) as GUILabelControl;
- _titleTemplate = GetControl((int)Controls.LABEL_TITLE_TEMPLATE) as GUILabelControl;
- _genreDarkTemplate = GetControl((int)Controls.LABEL_GENRE_DARK_TEMPLATE) as GUILabelControl;
- _genreTemplate = GetControl((int)Controls.LABEL_GENRE_TEMPLATE) as GUILabelControl;
-
- _programPartialRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_PARTIAL_RECORD) as GUIButton3PartControl;
- _programRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_RECORD) as GUIButton3PartControl;
- _programNotifyTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOTIFY) as GUIButton3PartControl;
- _programNotRunningTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOT_RUNNING) as GUIButton3PartControl;
- _programRunningTemplate = GetControl((int)Controls.BUTTON_PROGRAM_RUNNING) as GUIButton3PartControl;
-
- _showChannelLogos = cntlChannelImg != null;
- if (_showChannelLogos)
- {
- cntlChannelImg.IsVisible = false;
- }
- cntlChannelLabel.IsVisible = false;
- cntlHeaderBkgImg.IsVisible = false;
- labelTime.IsVisible = false;
- cntlChannelTemplate.IsVisible = false;
- int iLabelWidth = (cntlPanel.XPosition + cntlPanel.Width - labelTime.XPosition) / 4;
-
- // add labels for time blocks 1-4
- int iHour, iMin;
- iMin = _viewingTime.Minute;
- _viewingTime = _viewingTime.AddMinutes(-iMin);
- iMin = (iMin / _timePerBlock) * _timePerBlock;
- _viewingTime = _viewingTime.AddMinutes(iMin);
-
- DateTime dt = new DateTime();
- dt = _viewingTime;
-
- for (int iLabel = 0; iLabel < 4; iLabel++)
- {
- xpos = iLabel * iLabelWidth + labelTime.XPosition;
- ypos = labelTime.YPosition;
-
- GUIImage img = GetControl((int)Controls.IMG_TIME1 + iLabel) as GUIImage;
- if (img == null)
- {
- img = new GUIImage(GetID, (int)Controls.IMG_TIME1 + iLabel, xpos, ypos, iLabelWidth - 4,
- cntlHeaderBkgImg.RenderHeight, cntlHeaderBkgImg.FileName, 0x0);
- img.AllocResources();
- GUIControl cntl2 = (GUIControl)img;
- Add(ref cntl2);
- }
-
- img.IsVisible = !_singleChannelView;
- img.Width = iLabelWidth - 4;
- img.Height = cntlHeaderBkgImg.RenderHeight;
- img.SetFileName(cntlHeaderBkgImg.FileName);
- img.SetPosition(xpos, ypos);
- img.DoUpdate();
-
- GUILabelControl label = GetControl((int)Controls.LABEL_TIME1 + iLabel) as GUILabelControl;
- if (label == null)
- {
- label = new GUILabelControl(GetID, (int)Controls.LABEL_TIME1 + iLabel, xpos, ypos, iLabelWidth,
- cntlHeaderBkgImg.RenderHeight, labelTime.FontName, String.Empty,
- labelTime.TextColor, labelTime.TextAlignment, labelTime.TextVAlignment, false,
- labelTime.ShadowAngle, labelTime.ShadowDistance, labelTime.ShadowColor);
- label.AllocResources();
- GUIControl cntl = (GUIControl)label;
- this.Add(ref cntl);
- }
- iHour = dt.Hour;
- iMin = dt.Minute;
- string strTime = dt.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat);
- label.Label = " " + strTime;
- dt = dt.AddMinutes(_timePerBlock);
-
- label.TextAlignment = GUIControl.Alignment.ALIGN_LEFT;
- label.IsVisible = !_singleChannelView;
- label.Width = iLabelWidth;
- label.Height = cntlHeaderBkgImg.RenderHeight;
- label.FontName = labelTime.FontName;
- label.TextColor = labelTime.TextColor;
- label.SetPosition(xpos, ypos);
- }
-
- // add channels...
- int iItemHeight = cntlChannelTemplate.Height;
- UpdateChannelCount();
-
- for (int iChan = 0; iChan < _channelCount; ++iChan)
- {
- xpos = cntlChannelTemplate.XPosition;
- ypos = cntlChannelTemplate.YPosition + iChan * iItemHeight;
-
- //this.Remove((int)Controls.IMG_CHAN1+iChan);
- GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChan) as GUIButton3PartControl;
- if (imgBut == null)
- {
- string strChannelImageFileName = String.Empty;
- if (_showChannelLogos)
- {
- strChannelImageFileName = cntlChannelImg.FileName;
- }
-
- // Use a template control if it exists, otherwise use default values.
- GUIButton3PartControl buttonTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOT_RUNNING) as GUIButton3PartControl;
- if (buttonTemplate != null)
- {
- buttonTemplate.IsVisible = false;
- imgBut = new GUIButton3PartControl(GetID, (int)Controls.IMG_CHAN1 + iChan, xpos, ypos,
- cntlChannelTemplate.Width - 2, cntlChannelTemplate.Height - 2,
- buttonTemplate.TexutureFocusLeftName,
- buttonTemplate.TexutureFocusMidName,
- buttonTemplate.TexutureFocusRightName,
- buttonTemplate.TexutureNoFocusLeftName,
- buttonTemplate.TexutureNoFocusMidName,
- buttonTemplate.TexutureNoFocusRightName,
- strChannelImageFileName);
-
- imgBut.TileFillTFL = buttonTemplate.TileFillTFL;
- imgBut.TileFillTNFL = buttonTemplate.TileFillTNFL;
- imgBut.TileFillTFM = buttonTemplate.TileFillTFM;
- imgBut.TileFillTNFM = buttonTemplate.TileFillTNFM;
- imgBut.TileFillTFR = buttonTemplate.TileFillTFR;
- imgBut.TileFillTNFR = buttonTemplate.TileFillTNFR;
- }
- else
- {
- imgBut = new GUIButton3PartControl(GetID, (int)Controls.IMG_CHAN1 + iChan, xpos, ypos,
- cntlChannelTemplate.Width - 2, cntlChannelTemplate.Height - 2,
- "tvguide_button_selected_left.png",
- "tvguide_button_selected_middle.png",
- "tvguide_button_selected_right.png",
- "tvguide_button_light_left.png",
- "tvguide_button_light_middle.png",
- "tvguide_button_light_right.png",
- strChannelImageFileName);
- }
- imgBut.AllocResources();
- GUIControl cntl = (GUIControl)imgBut;
- Add(ref cntl);
- }
-
- imgBut.Width = cntlChannelTemplate.Width - 2; //labelTime.XPosition-cntlChannelImg.XPosition;
- imgBut.Height = cntlChannelTemplate.Height - 2; //iItemHeight-2;
- imgBut.SetPosition(xpos, ypos);
- imgBut.FontName1 = cntlChannelLabel.FontName;
- imgBut.TextColor1 = cntlChannelLabel.TextColor;
- imgBut.Label1 = String.Empty;
- imgBut.RenderLeft = false;
- imgBut.RenderRight = false;
- imgBut.SetShadow1(cntlChannelLabel.ShadowAngle, cntlChannelLabel.ShadowDistance, cntlChannelLabel.ShadowColor);
-
- if (_showChannelLogos)
- {
- imgBut.TexutureIcon = cntlChannelImg.FileName;
- imgBut.IconOffsetX = cntlChannelImg.XPosition;
- imgBut.IconOffsetY = cntlChannelImg.YPosition;
- imgBut.IconWidth = cntlChannelImg.RenderWidth;
- imgBut.IconHeight = cntlChannelImg.RenderHeight;
- imgBut.IconKeepAspectRatio = cntlChannelImg.KeepAspectRatio;
- imgBut.IconCentered = cntlChannelImg.Centered;
- imgBut.IconZoom = cntlChannelImg.Zoom;
- }
- imgBut.TextOffsetX1 = cntlChannelLabel.XPosition;
- imgBut.TextOffsetY1 = cntlChannelLabel.YPosition;
- imgBut.ColourDiffuse = 0xffffffff;
- imgBut.DoUpdate();
- }
-
- UpdateHorizontalScrollbar();
- UpdateVerticalScrollbar();
-
- GetChannels(false);
-
-
- string day;
- switch (_viewingTime.DayOfWeek)
- {
- case DayOfWeek.Monday:
- day = GUILocalizeStrings.Get(657);
- break;
- case DayOfWeek.Tuesday:
- day = GUILocalizeStrings.Get(658);
- break;
- case DayOfWeek.Wednesday:
- day = GUILocalizeStrings.Get(659);
- break;
- case DayOfWeek.Thursday:
- day = GUILocalizeStrings.Get(660);
- break;
- case DayOfWeek.Friday:
- day = GUILocalizeStrings.Get(661);
- break;
- case DayOfWeek.Saturday:
- day = GUILocalizeStrings.Get(662);
- break;
- default:
- day = GUILocalizeStrings.Get(663);
- break;
- }
- GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.View.SDOW", day);
- GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.View.Month", _viewingTime.Month.ToString());
- GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.View.Day", _viewingTime.Day.ToString());
-
- //day = String.Format("{0} {1}-{2}", day, _viewingTime.Day, _viewingTime.Month);
- day = Utils.GetShortDayString(_viewingTime);
- GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Day", day);
-
- //2004 03 31 22 20 00
- string strStart = String.Format("{0}{1:00}{2:00}{3:00}{4:00}{5:00}",
- _viewingTime.Year, _viewingTime.Month, _viewingTime.Day,
- _viewingTime.Hour, _viewingTime.Minute, 0);
- DateTime dtStop = new DateTime();
- dtStop = _viewingTime;
- dtStop = dtStop.AddMinutes(_numberOfBlocks * _timePerBlock - 1);
- iMin = dtStop.Minute;
- string strEnd = String.Format("{0}{1:00}{2:00}{3:00}{4:00}{5:00}",
- dtStop.Year, dtStop.Month, dtStop.Day,
- dtStop.Hour, iMin, 0);
-
- long iStart = Int64.Parse(strStart);
- long iEnd = Int64.Parse(strEnd);
-
-
- LoadSchedules(false);
-
- if (ChannelOffset > _channelList.Count)
- {
- ChannelOffset = 0;
- _cursorX = 0;
- }
-
- for (int i = 0; i < controlList.Count; ++i)
- {
- GUIControl cntl = (GUIControl)controlList[i];
- if (cntl.GetID >= RadioGuideBase.GUIDE_COMPONENTID_START)
- {
- cntl.IsVisible = false;
- }
- }
-
- if (_singleChannelView)
- {
- // show all buttons (could be less visible if channels < rows)
- for (int iChannel = 0; iChannel < _channelCount; iChannel++)
- {
- GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChannel) as GUIButton3PartControl;
- if (imgBut != null)
- imgBut.IsVisible = true;
- }
-
- Channel channel = (Channel)_channelList[_singleChannelNumber].channel;
- setGuideHeadingVisibility(false);
- RenderSingleChannel(channel);
- }
- else
- {
- TvBusinessLayer layer = new TvBusinessLayer();
-
- List<Channel> visibleChannels = new List<Channel>();
-
- int chan = ChannelOffset;
- for (int iChannel = 0; iChannel < _channelCount; iChannel++)
- {
- if (chan >= 0 && chan < _channelList.Count)
- {
- visibleChannels.Add(_channelList[chan].channel);
- }
- chan++;
- if (chan >= _channelList.Count && visibleChannels.Count < _channelList.Count)
- {
- chan = 0;
- }
- }
- Dictionary<int, List<Program>> programs = layer.GetProgramsForAllChannels(Utils.longtodate(iStart),
- Utils.longtodate(iEnd),
- visibleChannels);
- // make sure the TV Guide heading is visiable and the single channel labels are not.
- setGuideHeadingVisibility(true);
- setSingleChannelLabelVisibility(false);
- chan = ChannelOffset;
-
- int firstButtonYPos = 0;
- int lastButtonYPos = 0;
-
- for (int iChannel = 0; iChannel < _channelCount; iChannel++)
- {
- if (chan >= 0 && chan < _channelList.Count)
- {
- GuideChannel tvGuideChannel = (GuideChannel)_channelList[chan];
- RenderChannel(ref programs, iChannel, tvGuideChannel, iStart, iEnd, selectCurrentShow);
- // remember bottom y position from last visible button
- GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChannel) as GUIButton3PartControl;
- if (imgBut != null)
- {
- if (iChannel == 0)
- firstButtonYPos = imgBut.YPosition;
-
- lastButtonYPos = imgBut.YPosition + imgBut.Height;
- }
- }
- chan++;
- if (chan >= _channelList.Count && _channelList.Count > _channelCount)
- {
- chan = 0;
- }
- if (chan > _channelList.Count)
- {
- GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChannel) as GUIButton3PartControl;
- if (imgBut != null)
- {
- imgBut.IsVisible = false;
- }
- }
- }
-
- GUIImage vertLine = GetControl((int)Controls.VERTICAL_LINE) as GUIImage;
- if (vertLine != null)
- {
- // height taken from last button (bottom) minus the yposition of slider plus the offset of slider in relation to first button
- vertLine.Height = lastButtonYPos - vertLine.YPosition + (firstButtonYPos - vertLine.YPosition);
- }
- // update selected channel
- _singleChannelNumber = _cursorX + ChannelOffset;
- if (_singleChannelNumber >= _channelList.Count)
- {
- _singleChannelNumber -= _channelList.Count;
- }
-
- // instead of direct casting us "as"; else it fails for other controls!
- GUIButton3PartControl img = GetControl(_cursorX + (int)Controls.IMG_CHAN1) as GUIButton3PartControl;
- if (null != img)
- {
- _currentChannel = (Channel)img.Data;
- }
- }
- UpdateVerticalScrollbar();
- }
- }
-
- protected abstract void UpdateHorizontalScrollbar();
-
- protected abstract void GetChannels(bool b);
-
- protected abstract void LoadSchedules(bool b);
-
- protected abstract void RenderSingleChannel(Channel channel);
-
- protected abstract void setSingleChannelLabelVisibility(bool b);
-
- protected abstract void setGuideHeadingVisibility(bool p0);
-
- protected abstract void RenderChannel(ref Dictionary<int, List<Program>> programs, int iChannel, GuideChannel tvGuideChannel, long iStart, long iEnd, bool selectCurrentShow);
-
- protected abstract void UpdateVerticalScrollbar();
-
- protected abstract int CalcDays();
-
- protected abstract void UpdateGroupButton();
-
- protected class GuideChannel
- {
- public Channel channel;
- public int channelNum;
- public string strLogo;
- }
-
- #region enums
-
- protected enum Controls
- {
- PANEL_BACKGROUND = 2,
- SPINCONTROL_DAY = 6,
- SPINCONTROL_TIME_INTERVAL = 8,
- CHANNEL_IMAGE_TEMPLATE = 7,
- CHANNEL_LABEL_TEMPLATE = 18,
- LABEL_GENRE_TEMPLATE = 23,
- LABEL_TITLE_TEMPLATE = 24,
- VERTICAL_LINE = 25,
- LABEL_TITLE_DARK_TEMPLATE = 26,
- LABEL_GENRE_DARK_TEMPLATE = 30,
- CHANNEL_TEMPLATE = 20, // Channel rectangle and row height
-
- HORZ_SCROLLBAR = 28,
- VERT_SCROLLBAR = 29,
- LABEL_TIME1 = 40, // first and template
- IMG_CHAN1 = 50,
- IMG_CHAN1_LABEL = 70,
- IMG_TIME1 = 90, // first and template
- IMG_REC_PIN = 31,
- SINGLE_CHANNEL_LABEL = 32,
- SINGLE_CHANNEL_IMAGE = 33,
- LABEL_KEYED_CHANNEL = 34,
- BUTTON_PROGRAM_RUNNING = 35,
- BUTTON_PROGRAM_NOT_RUNNING = 36,
- BUTTON_PROGRAM_NOTIFY = 37,
- BUTTON_PROGRAM_RECORD = 38,
- BUTTON_PROGRAM_PARTIAL_RECORD = 39,
-
- CHANNEL_GROUP_BUTTON = 100
- } ;
-
- #endregion
-
- protected abstract string SkinPropertyPrefix { get; }
-
- protected void UpdateChannelCount()
- {
- GetChannels(false);
- GUIControl cntlPanel = GetControl((int)Controls.PANEL_BACKGROUND);
- GUIImage cntlChannelTemplate = (GUIImage)GetControl((int)Controls.CHANNEL_TEMPLATE);
-
- int iHeight = cntlPanel.Height + cntlPanel.YPosition - cntlChannelTemplate.YPosition;
- int iItemHeight = cntlChannelTemplate.Height;
- _channelCount = (int)(((float)iHeight) / iItemHeight);
-
- if (_channelCount > _channelList.Count())
- {
- _channelCount = _channelList.Count();
- }
- }
- }
-}
View
4,447 TVLibrary/TvPlugin/TvPlugin/TvGuideBase.cs
0 additions, 4,447 deletions not shown
View
10 TVLibrary/TvPlugin/TvPlugin/TvPlugin.csproj
@@ -130,14 +130,14 @@
<Compile Include="..\..\..\..\Common-MP-TVE3\SolutionInfo.cs">
<Link>SolutionInfo.cs</Link>
</Compile>
- <Compile Include="GuideBase.cs" />
+ <Compile Include="EPG\GuideBase.cs" />
<Compile Include="RadioSearch.cs" />
<Compile Include="Helper\BitHelper.cs" />
<Compile Include="RadioRecorded.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Radio.cs" />
- <Compile Include="RadioGuide.cs" />
- <Compile Include="RadioGuideBase.cs" />
+ <Compile Include="EPG\RadioGuide.cs" />
+ <Compile Include="EPG\RadioGuideBase.cs" />
<Compile Include="RadioSetupForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -155,8 +155,8 @@
<Compile Include="TvCropSettings.cs" />
<Compile Include="TvEpgSettings.cs" />
<Compile Include="TvFullScreen.cs" />
- <Compile Include="TVGuide.cs" />
- <Compile Include="TvGuideBase.cs" />
+ <Compile Include="EPG\TVGuide.cs" />
+ <Compile Include="EPG\TvGuideBase.cs" />
<Compile Include="TVHome.cs" />
<Compile Include="TVHomeNavigator.cs" />
<Compile Include="TvMiniGuide.cs" />
Please sign in to comment.
Something went wrong with that request. Please try again.