protected void UpdateForChannel(IChannel channel)
        {
            ChannelName = channel.Name;
            IProgram currentProgram;

            if (_tvHandler.ProgramInfo.GetCurrentProgram(channel, out currentProgram))
            {
                CurrentProgram.SetProgram(currentProgram);
                double progress = (DateTime.Now - currentProgram.StartTime).TotalSeconds /
                                  (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100;
                _programProgressProperty.SetValue(progress);
            }
            else
            {
                CurrentProgram.SetProgram(null);
                _programProgressProperty.SetValue(100d);
            }

            IProgram nextProgram;

            if (_tvHandler.ProgramInfo.GetNextProgram(channel, out nextProgram))
            {
                NextProgram.SetProgram(nextProgram);
            }
        }
        protected async Task UpdateForChannel(IChannel channel, ProgramProperties current, ProgramProperties next, AbstractProperty channelNameProperty, AbstractProperty channelNumberProperty, AbstractProperty progressProperty)
        {
            bool success = channel != null;

            if (success)
            {
                channelNameProperty.SetValue(channel.Name);
                channelNumberProperty.SetValue(channel.ChannelNumber);
                var result = await _tvHandler.ProgramInfo.GetNowNextProgramAsync(channel);

                success = result.Success;
                if (success)
                {
                    var currentProgram = result.Result[0];
                    var nextProgram    = result.Result[1];
                    current.SetProgram(currentProgram, channel);
                    next.SetProgram(nextProgram, channel);
                    double progress = currentProgram == null ? 100d : (DateTime.Now - currentProgram.StartTime).TotalSeconds / (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100;
                    progressProperty.SetValue(progress);
                }
            }
            if (!success)
            {
                current.SetProgram(null);
                next.SetProgram(null);
                progressProperty.SetValue(100d);
            }
        }
        protected async override void Update()
        {
            // Don't update the current channel and program information if we are in zap osd.
            if (_tvHandler == null || (_zapTimer != null && _zapTimer.IsEventPending))
            {
                return;
            }

            // Update current programs for all channels of current group (visible inside MiniGuide).
            await UpdateAllCurrentPrograms();

            _zapChannelIndex = ChannelContext.Instance.Channels.CurrentIndex;

            if (_tvHandler.NumberOfActiveSlots < 1)
            {
                PiPAvailable = false;
                PiPEnabled   = false;
                return;
            }

            PiPAvailable = true;

            // get the current channel and program out of the LiveTvMediaItems' TimeshiftContexes
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        playerContext        = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer);

            if (playerContext != null)
            {
                ILivePlayer player = playerContext.CurrentPlayer as ILivePlayer;
                if (player != null)
                {
                    LiveTvMediaItem   item           = player.CurrentItem;
                    ITimeshiftContext context        = item == null ? null : item.TimeshiftContexes.LastOrDefault();
                    IProgram          currentProgram = null;
                    IProgram          nextProgram    = null;
                    IChannel          channel        = null;
                    if (context != null && context.Channel != null)
                    {
                        channel         = context.Channel;
                        ChannelName     = channel.Name;
                        ChannelLogoType = channel.GetFanArtMediaType();
                        if (_tvHandler.ProgramInfo != null)
                        {
                            var result = await _tvHandler.ProgramInfo.GetNowNextProgramAsync(channel);

                            if (result.Success)
                            {
                                currentProgram = result.Result[0];
                                nextProgram    = result.Result[1];
                                double progress = currentProgram == null ? 100d : (DateTime.Now - currentProgram.StartTime).TotalSeconds /
                                                  (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100;
                                _programProgressProperty.SetValue(progress);
                            }
                        }
                    }
                    CurrentProgram.SetProgram(currentProgram, channel);
                    NextProgram.SetProgram(nextProgram, channel);
                }
            }
        }
Esempio n. 4
0
        protected void UpdateForChannel(IChannel channel, ProgramProperties current, ProgramProperties next, AbstractProperty channelNameProperty, AbstractProperty progressProperty)
        {
            channelNameProperty.SetValue(channel.Name);
            IProgram currentProgram;
            IProgram nextProgram;

            if (_tvHandler.ProgramInfo.GetNowNextProgram(channel, out currentProgram, out nextProgram))
            {
                current.SetProgram(currentProgram, channel);
                next.SetProgram(nextProgram, channel);
                double progress = (DateTime.Now - currentProgram.StartTime).TotalSeconds / (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100;
                progressProperty.SetValue(progress);
            }
            else
            {
                current.SetProgram(null);
                next.SetProgram(null);
                progressProperty.SetValue(100d);
            }
        }
        private void UpdateProgramForChannel(IChannel channel)
        {
            IProgram currentProgram;
            IProgram nextProgram;

            if (_tvHandler.ProgramInfo.GetNowNextProgram(channel, out currentProgram, out nextProgram))
            {
                _selectedCurrentProgramProperty.SetValue(FormatProgram(currentProgram));
                _selectedNextProgramProperty.SetValue(FormatProgram(nextProgram));
            }
        }
Esempio n. 6
0
        private void InitialMinutesChanged(AbstractProperty property, object _oldValue)
        {
            int oldValue = 0;

            if (_oldValue != null)
            {
                oldValue = (int)_oldValue;
            }

            if (_actSystemState.HasValue)
            {
                property.SetValue(oldValue); // no new value while running
                return;
            }

            int newValue = (int)property.GetValue();

            newValue = Math.Max(0, Math.Min(_maxSleepTimeInMinutes, newValue));
            property.SetValue(newValue);
            TimeText = newValue.ToString();
            UpdateButtonEnabled();
        }
Esempio n. 7
0
        public void SetAttachedPropertyValue <T>(string name, T value)
        {
            AbstractProperty result = GetAttachedProperty(name);

            if (result == null)
            {
                AddAttachedProperty(name, value, typeof(T));
            }
            else
            {
                result.SetValue(value);
            }
        }
        private void UpdateProgramForChannel(IChannel channel)
        {
            IProgram program;

            if (_tvHandler.ProgramInfo.GetCurrentProgram(channel, out program))
            {
                _selectedCurrentProgramProperty.SetValue(FormatProgram(program));
            }

            if (_tvHandler.ProgramInfo.GetNextProgram(channel, out program))
            {
                _selectedNextProgramProperty.SetValue(FormatProgram(program));
            }
        }
Esempio n. 9
0
        protected override void Update()
        {
            // Don't update the current channel and program information if we are in zap osd.
            if (_tvHandler == null || (_zapTimer != null && _zapTimer.IsEventPending))
            {
                return;
            }

            // Update current programs for all channels of current group (visible inside MiniGuide).
            UpdateAllCurrentPrograms();

            _zapChannelIndex = ChannelContext.Instance.Channels.CurrentIndex;

            if (_tvHandler.NumberOfActiveSlots < 1)
            {
                PiPAvailable = false;
                PiPEnabled   = false;
                return;
            }

            PiPAvailable = true;

            // get the current channel and program out of the LiveTvMediaItems' TimeshiftContexes
            IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>();
            IPlayerContext        playerContext        = playerContextManager.GetPlayerContext(PlayerChoice.PrimaryPlayer);

            if (playerContext != null)
            {
                LiveTvPlayer player = playerContext.CurrentPlayer as LiveTvPlayer;
                if (player != null)
                {
                    ITimeshiftContext context        = player.TimeshiftContexes.LastOrDefault();
                    IProgram          currentProgram = null;
                    IProgram          nextProgram    = null;
                    if (context != null && context.Channel != null)
                    {
                        ChannelName = context.Channel.Name;
                        if (_tvHandler.ProgramInfo != null && _tvHandler.ProgramInfo.GetNowNextProgram(context.Channel, out currentProgram, out nextProgram) && currentProgram != null)
                        {
                            double progress = (DateTime.Now - currentProgram.StartTime).TotalSeconds /
                                              (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100;
                            _programProgressProperty.SetValue(progress);
                        }
                    }
                    CurrentProgram.SetProgram(currentProgram);
                    NextProgram.SetProgram(nextProgram);
                }
            }
        }
Esempio n. 10
0
        public override void DeepCopy(IDeepCopyable source, ICopyManager copyManager)
        {
            base.DeepCopy(source, copyManager);
            Timeline t = (Timeline)source;

            BeginTime         = t.BeginTime;
            Accelleration     = t.Accelleration;
            AutoReverse       = t.AutoReverse;
            DecelerationRatio = t.DecelerationRatio;
            _durationProperty.SetValue(t._durationProperty.GetValue()); // Copying of a Nullable<TimeSpan>
            FillBehavior   = t.FillBehavior;
            RepeatBehavior = t.RepeatBehavior;

            _owner = copyManager.GetCopy(t._owner);
        }