forked from ARGUS-TV/ARGUS-TV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTvRecordingOverlay.cs
143 lines (122 loc) · 3.65 KB
/
TvRecordingOverlay.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#region Copyright (C) 2005-2013 Team MediaPortal
/*
* Copyright (C) 2005-2013 Team MediaPortal
* http://www.team-mediaportal.com
*
* This Program 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, or (at your option)
* any later version.
*
* This Program 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#endregion
using System;
using System.Drawing;
using System.Globalization;
using MediaPortal.GUI.Library;
using MediaPortal.Util;
using MediaPortal.Player;
using ArgusTV.ServiceProxy;
using ArgusTV.DataContracts;
namespace ArgusTV.UI.MediaPortal
{
/// <summary>
///
/// </summary>
public class TvRecordingOverlay : GUIInternalOverlayWindow, IRenderLayer
{
private DateTime _updateTimer = DateTime.Now;
private bool _lastStatus = false;
private bool _didRenderLastTime = false;
public TvRecordingOverlay()
{
GetID = (int)GUIWindow.Window.WINDOW_TV_OVERLAY;
}
#region Overrides
public override bool Init()
{
bool bResult = Load(GUIGraphicsContext.Skin + @"\tvOverlay.xml");
GetID = (int)GUIWindow.Window.WINDOW_TV_OVERLAY;
GUILayerManager.RegisterLayer(this, GUILayerManager.LayerType.TvOverlay);
return bResult;
}
public override void PreInit()
{
base.PreInit();
AllocResources();
}
public override bool SupportsDelayedLoad
{
get { return false; }
}
#endregion
#region IRenderLayer
private void OnUpdateState(bool render)
{
if (_didRenderLastTime != render)
{
_didRenderLastTime = render;
if (render)
{
QueueAnimation(AnimationType.WindowOpen);
}
else
{
QueueAnimation(AnimationType.WindowClose);
}
}
}
public bool ShouldRenderLayer()
{
if (GUIGraphicsContext.IsFullScreenVideo)
{
return false;
}
TimeSpan ts = DateTime.Now - _updateTimer;
if (ts.TotalMilliseconds < 1000)
{
return _lastStatus;
}
_updateTimer = DateTime.Now;
if (!PluginMain.IsConnected())
{
return false;
}
try
{
_lastStatus = (PluginMain.ActiveRecordings.Count > 0);
}
catch
{
_lastStatus = false;
}
OnUpdateState(_lastStatus);
if (!_lastStatus)
{
return base.IsAnimating(AnimationType.WindowClose);
}
else
{
return _lastStatus;
}
}
public void RenderLayer(float timePassed)
{
if (!GUIGraphicsContext.IsFullScreenVideo)
{
Render(timePassed);
}
}
#endregion
}
}