Beispiel #1
0
        private void UpdateDaysinMonth(int month, int year)
        {
            int selected = 0;

            if (_spinStartDay.GetLabel() != "")
            {
                selected = Int32.Parse(_spinStartDay.GetLabel());
            }
            _spinStartDay.Reset();
            for (int i = 1; i <= DateTime.DaysInMonth(year, month); i++)
            {
                if (i < 10)
                {
                    _spinStartDay.AddLabel("0" + i.ToString(), 0);
                }
                else
                {
                    _spinStartDay.AddLabel(i.ToString(), 0);
                }

                if (i == selected)
                {
                    _spinStartDay.Value = (i - 1);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Fill up the list with groups
        /// </summary>
        public void FillGroupList()
        {
            benchClock = Stopwatch.StartNew();

            ChannelGroup current = null;

            _channelGroupList = TVHome.Navigator.Groups;
            // empty list of channels currently in the
            // spin control
            spinGroup.Reset();
            // start to fill them up again
            for (int i = 0; i < _channelGroupList.Count; i++)
            {
                current = _channelGroupList[i];
                spinGroup.AddLabel(current.GroupName, i);
                // set selected
                if (current.GroupName.CompareTo(TVHome.Navigator.CurrentGroup.GroupName) == 0)
                {
                    spinGroup.Value = i;
                }
            }

            if (_channelGroupList.Count < 2)
            {
                spinGroup.Visible = false;
            }

            benchClock.Stop();
            Log.Debug("TvMiniGuide: FillGroupList finished after {0} ms", benchClock.ElapsedMilliseconds.ToString());
        }
Beispiel #3
0
        /// <summary>
        /// Fill up the list with groups
        /// </summary>
        private void FillGroupList()
        {
            PluginMain.Navigator.RefreshChannelGroups(this.ChannelType);
            _channelGroupList = PluginMain.Navigator.GetGroups(this.ChannelType);
            _currentGroup     = PluginMain.Navigator.CurrentGroup;

            // empty list of groups currently in the spin control
            _spinGroup.Reset();

            // start to fill them up again
            bool groupFound = false;

            for (int index = 0; index < _channelGroupList.Count; index++)
            {
                ChannelGroup group = _channelGroupList[index];
                _spinGroup.AddLabel(group.GroupName, index);
                // set selected
                if (_currentGroup != null &&
                    group.ChannelGroupId == _currentGroup.ChannelGroupId)
                {
                    _spinGroup.Value = index;
                    groupFound       = true;
                }
            }

            if (!groupFound)
            {
                _currentGroup = (_channelGroupList.Count > 0) ? _channelGroupList[0] : null;
            }

            if (_channelGroupList.Count < 2)
            {
                _spinGroup.Visible = false;
            }
        }
        public void AddSpinLabel(string label, int value)
        {
            _spinControl.AddLabel(label, value);

            // When the user has requested that the spin text should be rendered in the label text we listen for spin label adds
            // on the spincontrol and update the button label when a change is detected.
            if (_spinTextInButton)
            {
                Label = _spinControl.GetLabel();
            }
        }
Beispiel #5
0
        private void UpdateDateTime()
        {
            DateTime     time        = DateTime.Now;
            Schedule     sched       = null;
            ScheduleRule _manualRule = null;
            int          valueYear   = 0;
            bool         yearFound   = true;

            if (_upcomingProgram != null)
            {
                sched = Proxies.SchedulerService.GetScheduleById(_upcomingProgram.ScheduleId).Result;
                if (sched != null)
                {
                    yearFound   = false;
                    _manualRule = sched.Rules.FindRuleByType(ScheduleRuleType.ManualSchedule);
                    if (_manualRule != null)
                    {
                        time = Convert.ToDateTime(_manualRule.Arguments[0]);
                    }
                }
            }

            for (int i = DateTime.Now.Year; i <= DateTime.Now.Year + 2; i++)
            {
                _spinStartYear.AddLabel(i.ToString(), 0);
                if (_upcomingProgram != null && sched != null && yearFound == false)
                {
                    if (i.ToString() == time.Year.ToString())
                    {
                        yearFound = true;
                    }
                    valueYear++;
                }
            }

            if (yearFound == false)
            {
                // year not found in list, add year in list
                _spinStartYear.AddLabel(time.ToString(), 0);
                yearFound = true;
                valueYear++;
            }

            for (int i = 1; i <= 12; i++)
            {
                if (i < 10)
                {
                    _spinStartMonth.AddLabel("0" + i.ToString(), 0);
                }
                else
                {
                    _spinStartMonth.AddLabel(i.ToString(), 0);
                }
            }

            UpdateDaysinMonth(Int32.Parse(_spinStartMonth.GetLabel()), Int32.Parse(_spinStartYear.GetLabel()));

            for (int i = 0; i <= 23; i++)
            {
                if (i < 10)
                {
                    _spinStartHour.AddLabel("0" + i.ToString(), 0);
                    _spinHoursDuration.AddLabel("0" + i.ToString(), 0);
                }
                else
                {
                    _spinStartHour.AddLabel(i.ToString(), 0);
                    _spinHoursDuration.AddLabel(i.ToString(), 0);
                }
            }

            for (int i = 0; i <= 59; i++)
            {
                if (i < 10)
                {
                    _spinStartMinute.AddLabel("0" + i.ToString(), 0);
                    _spinMinutesDuration.AddLabel("0" + i.ToString(), 0);
                }
                else
                {
                    _spinStartMinute.AddLabel(i.ToString(), 0);
                    _spinMinutesDuration.AddLabel(i.ToString(), 0);
                }
            }

            _spinStartMonth.Value  = (time.Month - 1);
            _spinStartDay.Value    = (time.Day - 1);
            _spinStartHour.Value   = time.Hour;
            _spinStartMinute.Value = time.Minute;

            if (_upcomingProgram != null && sched != null && _manualRule != null)
            {
                if (yearFound)
                {
                    _spinStartYear.Value = (valueYear - 1);
                }
                _spinHoursDuration.Value   = _upcomingProgram.Duration.Hours;
                _spinMinutesDuration.Value = _upcomingProgram.Duration.Minutes;
            }
            else
            {
                //default duration = 1 hour
                _spinHoursDuration.Value   = 1;
                _spinMinutesDuration.Value = 0;
            }
        }
Beispiel #6
0
        private void UpdateChannels()
        {
            Schedule schedule     = null;
            bool     channelFound = false;
            int      channelIndex = 0;
            int      groupIndex   = 0;

            if (_upcomingProgram != null)
            {
                schedule = Proxies.SchedulerService.GetScheduleById(_upcomingProgram.ScheduleId).Result;
                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 Proxies.SchedulerService.GetChannelsInGroup(group.ChannelGroupId, true).Result)
                    {
                        _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;
            }
        }
        public override bool OnMessage(GUIMessage message)
        {
            switch (message.Message)
            {
            case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
            {
                base.OnMessage(message);
                _confirmed = false;
                spinStartHour.SetRange(0, 23);
                spinStartHour.Value = startDateTime.Hour;

                spinStartMinute.SetRange(0, 59);
                spinStartMinute.Value = startDateTime.Minute;

                if (DateTime.IsLeapYear(startDateTime.Year) && startDateTime.Month == 2)
                {
                    spinStartDay.SetRange(1, 29);
                }
                else
                {
                    spinStartDay.SetRange(1, months[startDateTime.Month]);
                }
                spinStartDay.Value = startDateTime.Day;

                spinStartMonth.SetRange(1, 12);
                spinStartMonth.Value = startDateTime.Month;

                spinStartYear.Value = startDateTime.Year;
                spinStartYear.SetRange(2004, 2010);


                spinChannel.Reset();
                int i = 0, iSel = 0;
                foreach (string strLabel in itemList)
                {
                    spinChannel.AddLabel(strLabel, 0);
                    if (channel == strLabel)
                    {
                        iSel = i;
                    }
                    i++;
                }
                if (iSel >= 0)
                {
                    SelectItemControl(GetID, spinChannel.GetID, iSel);
                }

                spinEndHour.SetRange(0, 23);
                spinEndHour.Value = endDateTime.Hour;

                spinEndMinute.SetRange(0, 59);
                spinEndMinute.Value = endDateTime.Minute;

                if (DateTime.IsLeapYear(endDateTime.Year) && endDateTime.Month == 2)
                {
                    spinEndDay.SetRange(1, 29);
                }
                else
                {
                    spinEndDay.SetRange(1, months[endDateTime.Month]);
                }
                spinEndDay.Value = endDateTime.Day;


                spinEndMonth.SetRange(1, 12);
                spinEndMonth.Value = endDateTime.Month;


                spinEndYear.Value = endDateTime.Year;
                spinEndYear.SetRange(2004, 2010);

                spinStartHour.Disabled   = !enableEditStartTime;
                spinStartMinute.Disabled = !enableEditStartTime;
                spinStartDay.Disabled    = !enableEditStartTime;
                spinStartMonth.Disabled  = !enableEditStartTime;
                spinStartYear.Disabled   = !enableEditStartTime;

                spinChannel.Disabled = !enableEditChannel;
            }
                return(true);
            }
            return(base.OnMessage(message));
        }
        protected override void OnPageLoad()
        {
            base.OnPageLoad();

            this._isOverlayAllowed = true;
            GUIVideoOverlay videoOverlay = (GUIVideoOverlay)GUIWindowManager.GetWindow((int)Window.WINDOW_VIDEO_OVERLAY);

            if ((videoOverlay != null) && (videoOverlay.Focused))
            {
                videoOverlay.Focused = false;
            }
            // GoBack bug fix (corrupted video info)
            if (currentMovie == null)
            {
                if (GUIWindowManager.HasPreviousWindow())
                {
                    GUIWindowManager.ShowPreviousWindow();
                }
                else
                {
                    GUIWindowManager.CloseCurrentWindow();
                }
                return;
            }
            // Default picture
            imdbCoverArtUrl = currentMovie.ThumbURL;
            coverArtUrls    = new string[1];
            coverArtUrls[0] = imdbCoverArtUrl;

            ResetSpinControl();
            spinDisc.UpDownType = GUISpinControl.SpinType.SPIN_CONTROL_TYPE_DISC_NUMBER;
            spinDisc.Reset();
            viewmode = ViewMode.Plot;
            spinDisc.AddLabel("HD", 0);
            for (int i = 0; i < 1000; ++i)
            {
                string description = String.Format("DVD#{0:000}", i);
                spinDisc.AddLabel(description, 0);
            }

            spinDisc.IsVisible = false;
            spinDisc.Disabled  = true;
            int iItem = 0;

            if (Util.Utils.IsDVD(currentMovie.Path))
            {
                spinDisc.IsVisible = true;
                spinDisc.Disabled  = false;
                string szNumber = string.Empty;
                int    iPos     = 0;
                bool   bNumber  = false;
                for (int i = 0; i < currentMovie.DVDLabel.Length; ++i)
                {
                    char kar = currentMovie.DVDLabel[i];
                    if (Char.IsDigit(kar))
                    {
                        szNumber += kar;
                        iPos++;
                        bNumber = true;
                    }
                    else
                    {
                        if (bNumber)
                        {
                            break;
                        }
                    }
                }
                int iDVD = 0;
                if (szNumber.Length > 0)
                {
                    int x = 0;
                    while (szNumber[x] == '0' && x + 1 < szNumber.Length)
                    {
                        x++;
                    }
                    if (x < szNumber.Length)
                    {
                        szNumber = szNumber.Substring(x);
                        iDVD     = Int32.Parse(szNumber);
                        if (iDVD < 0 && iDVD >= 1000)
                        {
                            iDVD = -1;
                        }
                        else
                        {
                            iDVD++;
                        }
                    }
                }
                if (iDVD <= 0)
                {
                    iDVD = 0;
                }
                iItem = iDVD;
                //0=HD
                //1=DVD#000
                //2=DVD#001
                GUIControl.SelectItemControl(GetID, spinDisc.GetID, iItem);
            }
            Refresh(false);
            Update();

            SearchImages();
        }