Пример #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);
                }
            }
        }
Пример #2
0
        protected override void OnPageLoad()
        {
            PluginMain.EnsureConnection();
            base.OnPageLoad();

            if (PluginMain.IsConnected())
            {
                UpdateChannels();
                UpdateDateTime();
                UpdateButtonStates();
                UpdateDaysinMonth(Int32.Parse(_spinStartMonth.GetLabel()), Int32.Parse(_spinStartYear.GetLabel()));
                GUIPropertyManager.SetProperty("#currentmodule", GUILocalizeStrings.Get(100748));
            }
        }
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            base.OnClicked(controlId, control, actionType);
            int iYear, iMonth;

            if (control == spinStartMonth)
            {
                iYear  = spinStartYear.Value;
                iMonth = spinStartMonth.Value;
                if (iMonth == 2 && DateTime.IsLeapYear(iYear))
                {
                    spinStartDay.SetRange(1, 29);
                }
                else
                {
                    spinStartDay.SetRange(1, months[iMonth]);
                }
            }
            if (control == spinEndMonth)
            {
                iYear  = spinEndYear.Value;
                iMonth = spinEndMonth.Value;
                if (iMonth == 2 && DateTime.IsLeapYear(iYear))
                {
                    spinEndDay.SetRange(1, 29);
                }
                else
                {
                    spinEndDay.SetRange(1, months[iMonth]);
                }
            }
            if (control == btnOK)
            {
                int iHour;
                iHour = spinStartHour.Value;
                int iMin;
                iMin = spinStartMinute.Value;
                int iDay;
                iDay    = spinStartDay.Value;
                iMonth  = spinStartMonth.Value;
                iYear   = spinStartYear.Value;
                channel = spinChannel.GetLabel();

                startDateTime = new DateTime(iYear, iMonth, iDay, iHour, iMin, 0, 0);
                iHour         = spinEndHour.Value;
                iMin          = spinEndMinute.Value;
                iDay          = spinEndDay.Value;
                iMonth        = spinEndMonth.Value;
                iYear         = spinEndYear.Value;
                endDateTime   = new DateTime(iYear, iMonth, iDay, iHour, iMin, 0, 0);

                _confirmed = true;
                PageDestroy();
                return;
            }
        }
Пример #4
0
 private void OnGroupChanged()
 {
     if (_spinGroup.Visible)
     {
         GUIWaitCursor.Show();
         _currentGroup = _channelGroupList[_spinGroup.Value];
         string guiPropertyPrefix = this.ChannelType == ChannelType.Television ? "#TV" : "#Radio";
         GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Guide.Group", _spinGroup.GetLabel());
         FillChannelList();
         GUIWaitCursor.Hide();
     }
 }
        /// <summary>
        /// OnMessage() This method gets called when there's a new message.
        /// Controls send messages to notify their parents about their state (changes)
        /// By overriding this method a control can respond to the messages of its controls
        /// </summary>
        /// <param name="message">message : contains the message</param>
        /// <returns>true if the message was handled, false if it wasnt</returns>
        public override bool OnMessage(GUIMessage message)
        {
            // Let the spin control handle messages first
            if (_spinControl.OnMessage(message))
            {
                return(true);
            }

            // Handle the GUI_MSG_LABEL_SET message
            if (message.TargetControlId == GetID)
            {
                if (message.Message == GUIMessage.MessageType.GUI_MSG_LABEL_SET)
                {
                    if (message.Label != null)
                    {
                        Label = message.Label;
                    }
                    return(true);
                }
            }

            // Handle the GUI_MSG_CLICKED messages from my spincontrol
            // When the user has requested that the spin text should be rendered in the label text we listen for clicks on the
            // spincontrol and update the button label when a change is detected.
            if (_spinTextInButton)
            {
                if ((message.TargetControlId == GetID) & (message.Message == GUIMessage.MessageType.GUI_MSG_CLICKED))
                {
                    Label = _spinControl.GetLabel();
                    return(true);
                }
            }

            // Let the base class handle the other messages
            if (base.OnMessage(message))
            {
                return(true);
            }
            return(false);
        }
Пример #6
0
        private void OnGroupChanged()
        {
            Stopwatch bClock = Stopwatch.StartNew();

            GUIWaitCursor.Show();
            TVHome.Navigator.SetCurrentGroup(spinGroup.Value);
            GUIPropertyManager.SetProperty("#TV.Guide.Group", spinGroup.GetLabel());
            lstChannels.Clear();
            FillChannelList();
            GUIWaitCursor.Hide();

            Log.Debug("OnGroupChanged {0} took {1} msec", spinGroup.Value, bClock.ElapsedMilliseconds);
        }
Пример #7
0
        private void Onrecord(ScheduleType scheduleType)
        {
            Schedule schedule = null;

            if (_upcomingProgram != null)
            {
                schedule = Proxies.SchedulerService.GetScheduleById(_upcomingProgram.ScheduleId).Result;
            }
            if (_upcomingProgram != null && schedule != null &&
                schedule.ScheduleType == scheduleType)   //delete schedule
            {
                if (_upcomingProgram.IsCancelled)
                {
                    Proxies.SchedulerService.UncancelUpcomingProgram(_upcomingProgram.ScheduleId, _upcomingProgram.GuideProgramId, _upcomingProgram.Channel.ChannelId, _upcomingProgram.StartTime).Wait();
                    try
                    {
                        //refresh _upcomingProgram
                        _upcomingProgram = Proxies.SchedulerService.GetUpcomingPrograms(schedule, true).Result[0];
                    }
                    catch { }
                }
                else
                {
                    if (_upcomingProgram.IsPartOfSeries)
                    {
                        GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                        if (dlgYesNo != null)
                        {
                            dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.DeleteEntireSchedule));
                            dlgYesNo.SetLine(1, "\"" + schedule.Name + "\"");
                            dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure));
                            dlgYesNo.SetLine(3, String.Empty);
                            dlgYesNo.SetDefaultToYes(false);
                            dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                            if (dlgYesNo.IsConfirmed)
                            {
                                Proxies.SchedulerService.DeleteSchedule(schedule.ScheduleId).Wait();
                                _upcomingProgram = null;
                            }
                        }
                    }
                    else
                    {
                        Proxies.SchedulerService.DeleteSchedule(_upcomingProgram.ScheduleId).Wait();
                        _upcomingProgram = null;
                    }
                }
            }
            else//create new schedule
            {
                TimeSpan           duration   = new TimeSpan(Int32.Parse(_spinHoursDuration.GetLabel()), Int32.Parse(_spinMinutesDuration.GetLabel()), 0);
                DateTime           startTime  = new DateTime(Int32.Parse(_spinStartYear.GetLabel()), Int32.Parse(_spinStartMonth.GetLabel()), Int32.Parse(_spinStartDay.GetLabel()), Int32.Parse(_spinStartHour.GetLabel()), Int32.Parse(_spinStartMinute.GetLabel()), 0);
                ScheduleDaysOfWeek daysOfWeek = new ScheduleDaysOfWeek();

                //TODO: What if we have multiple channels with the same name
                Channel channel = Proxies.SchedulerService.GetChannelByDisplayName(_channelType, _spinChannel.GetLabel()).Result;

                Schedule newSchedule = null;
                newSchedule = Proxies.SchedulerService.CreateNewSchedule(_channelType, scheduleType).Result;
                newSchedule.Rules.Add(ScheduleRuleType.Channels, channel.ChannelId);
                newSchedule.Rules.Add(ScheduleRuleType.ManualSchedule, startTime, new ScheduleTime(duration));
                if (!_recordOnce)
                {
                    string days = " ";
                    if (_mondayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Mondays;
                        days      += Utility.GetLocalizedText(TextId.Mon) + ",";
                    }
                    if (_tuesdayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Tuesdays;
                        days      += Utility.GetLocalizedText(TextId.Tue) + ",";
                    }
                    if (_wednesdayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Wednesdays;
                        days      += Utility.GetLocalizedText(TextId.Wed) + ",";
                    }
                    if (_thursdayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Thursdays;
                        days      += Utility.GetLocalizedText(TextId.Thu) + ",";
                    }
                    if (_fridayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Fridays;
                        days      += Utility.GetLocalizedText(TextId.Fri) + ",";
                    }
                    if (_saturdayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Saturdays;
                        days      += Utility.GetLocalizedText(TextId.Sat) + ",";
                    }
                    if (_sundayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Sundays;
                        days      += Utility.GetLocalizedText(TextId.Sun) + ",";
                    }
                    days = days.Remove(days.Length - 1);
                    newSchedule.Rules.Add(ScheduleRuleType.DaysOfWeek, daysOfWeek);
                    newSchedule.Name = String.Format(CultureInfo.CurrentCulture, "{0} {1} {2:t}-{3:t}", channel.DisplayName, days, startTime, startTime.Add(duration));
                }
                else
                {
                    newSchedule.Name = String.Format(CultureInfo.CurrentCulture, "{0} {1:g}-{2:t}", channel.DisplayName, startTime, startTime.Add(duration));
                }

                //TODO: try to prevent dublicate manual schedules
                //and find a better way to get the newly created "_schedule" and  "_upcomingProgram"
                if (newSchedule != null)
                {
                    newSchedule.ScheduleType = scheduleType;
                    Proxies.SchedulerService.SaveSchedule(newSchedule).Wait();

                    bool found     = false;
                    var  _programs = Proxies.SchedulerService.GetAllUpcomingPrograms(scheduleType, true).Result;
                    foreach (UpcomingProgram _prog in _programs)
                    {
                        if (_prog.Channel.ChannelId == channel.ChannelId &&
                            _prog.Duration == duration &&
                            !found)
                        {
                            Schedule _schedule = Proxies.SchedulerService.GetScheduleById(_prog.ScheduleId).Result;
                            if (_schedule.Rules.FindRuleByType(ScheduleRuleType.ManualSchedule) != null)
                            {
                                if (_schedule.Name == newSchedule.Name)
                                {
                                    if (_recordOnce &&
                                        _prog.StartTime == startTime)
                                    {
                                        _upcomingProgram = _prog;
                                        found            = true;
                                    }
                                    else if (!_recordOnce && _schedule.Rules.FindRuleByType(ScheduleRuleType.DaysOfWeek) != null &&
                                             _schedule.Rules.FindRuleByType(ScheduleRuleType.DaysOfWeek).Arguments[0].ToString() == daysOfWeek.ToString() &&
                                             Convert.ToDateTime(_schedule.Rules.FindRuleByType(ScheduleRuleType.ManualSchedule).Arguments[0]) == startTime)
                                    {
                                        _upcomingProgram = _prog;
                                        found            = true;
                                    }
                                    Update(_schedule);
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        GUIWindowManager.ShowPreviousWindow();
                    }
                }
            }
        }
Пример #8
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;
            }
        }
        // Changed - covers and the same movie name
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            base.OnClicked(controlId, control, actionType);
            if (control == btnRefresh)
            {
                // Check Internet connection
                if (!Win32API.IsConnectedToInternet())
                {
                    GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                    dlgOk.SetHeading(257);
                    dlgOk.SetLine(1, GUILocalizeStrings.Get(703));
                    dlgOk.DoModal(GUIWindowManager.ActiveWindow);
                    return;
                }
                string title = currentMovie.Title;
                int    id    = currentMovie.ID;
                string file  = currentMovie.Path + "\\" + currentMovie.File;
                // Delete covers
                FanArt.DeleteCovers(title, id);
                //Delete fanarts
                FanArt.DeleteFanarts(file, title);

                if (IMDBFetcher.RefreshIMDB(this, ref currentMovie, false, false, true))
                {
                    if ((imageSearchThread != null) && (imageSearchThread.IsAlive))
                    {
                        imageSearchThread.Abort();
                        imageSearchThread = null;
                    }

                    imdbCoverArtUrl = currentMovie.ThumbURL;
                    coverArtUrls    = new string[1];
                    coverArtUrls[0] = imdbCoverArtUrl;

                    ResetSpinControl();

                    Refresh(false);
                    Update();
                    // Start images search thread
                    SearchImages();
                }
                return;
            }

            if (control == spinImages)
            {
                int item = spinImages.Value - 1;
                if (item < 0 || item >= coverArtUrls.Length)
                {
                    item = 0;
                }
                if (currentMovie.ThumbURL == coverArtUrls[item])
                {
                    return;
                }

                currentMovie.ThumbURL = coverArtUrls[item];
                // Title suffix for problem with covers and movie with the same name
                string titleExt           = currentMovie.Title + "{" + currentMovie.ID + "}";
                string coverArtImage      = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);
                string largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                Util.Utils.FileDelete(coverArtImage);
                //
                // 07.11.2010 Deda: Cache entry Flag change for cover thumb file
                //
                Util.Utils.DoInsertNonExistingFileIntoCache(coverArtImage);
                //
                Util.Utils.FileDelete(largeCoverArtImage);
                Refresh(false);
                Update();
                int idMovie = currentMovie.ID;
                if (idMovie >= 0)
                {
                    VideoDatabase.SetThumbURL(idMovie, currentMovie.ThumbURL);
                }
                return;
            }

            if (control == btnCast)
            {
                viewmode = ViewMode.Cast;
                Update();
            }

            if (control == btnPlot)
            {
                viewmode = ViewMode.Plot;
                Update();
            }

            if (control == btnReview)
            {
                viewmode = ViewMode.Review;
                Update();
            }

            if (control == btnWatched)
            {
                if (currentMovie.Watched > 0)
                {
                    GUIPropertyManager.SetProperty("#iswatched", "no");
                    currentMovie.Watched = 0;
                    VideoDatabase.SetMovieWatchedStatus(currentMovie.ID, false);
                    ArrayList files = new ArrayList();
                    VideoDatabase.GetFiles(currentMovie.ID, ref files);

                    foreach (string file in files)
                    {
                        int fileId = VideoDatabase.GetFileId(file);
                        VideoDatabase.DeleteMovieStopTime(fileId);
                    }
                }
                else
                {
                    GUIPropertyManager.SetProperty("#iswatched", "yes");
                    currentMovie.Watched = 1;
                    VideoDatabase.SetMovieWatchedStatus(currentMovie.ID, true);
                }
                VideoDatabase.SetWatched(currentMovie);
            }

            if (control == spinDisc)
            {
                string selectedItem = spinDisc.GetLabel();
                int    idMovie      = currentMovie.ID;
                if (idMovie > 0)
                {
                    if (selectedItem != "HD" && selectedItem != "share")
                    {
                        VideoDatabase.SetDVDLabel(idMovie, selectedItem);
                    }
                    else
                    {
                        VideoDatabase.SetDVDLabel(idMovie, "HD");
                    }
                }
            }

            if (control == btnPlay)
            {
                int id = currentMovie.ID;

                ArrayList files = new ArrayList();
                VideoDatabase.GetFiles(id, ref files);

                if (files.Count > 1)
                {
                    GUIVideoFiles._stackedMovieFiles = files;
                    GUIVideoFiles._isStacked         = true;
                    GUIVideoFiles.MovieDuration(files);
                }

                GUIVideoFiles.PlayMovie(id, false);
                return;
            }
        }