示例#1
0
 private void OnChangePriority(UpcomingProgram upcoming)
 {
     if (upcoming != null)
     {
         GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
         if (dlg != null)
         {
             dlg.Reset();
             dlg.SetHeading(Utility.GetLocalizedText(TextId.Priority));
             dlg.Add(Utility.GetLocalizedText(TextId.VeryLow));
             dlg.Add(Utility.GetLocalizedText(TextId.Low));
             dlg.Add(Utility.GetLocalizedText(TextId.Normal));
             dlg.Add(Utility.GetLocalizedText(TextId.High));
             dlg.Add(Utility.GetLocalizedText(TextId.VeryHigh));
             dlg.Add(Utility.GetLocalizedText(TextId.Highest));
             dlg.Add(Utility.GetLocalizedText(TextId.ResetToSchedulePriority));
             dlg.SelectedLabel = (int)upcoming.Priority + 2;
             dlg.DoModal(GetID);
             if (dlg.SelectedLabel >= 0)
             {
                 int selectedInt = dlg.SelectedLabel - 2;
                 UpcomingProgramPriority?priority = null;
                 if (selectedInt >= (int)UpcomingProgramPriority.VeryLow &&
                     selectedInt <= (int)UpcomingProgramPriority.Highest)
                 {
                     priority = (UpcomingProgramPriority)selectedInt;
                 }
                 SchedulerAgent.SetUpcomingProgramPriority(upcoming.UpcomingProgramId, upcoming.StartTime, priority);
                 m_iSelectedItem = GetSelectedItemNo();
                 LoadUpcomingPrograms(null);
             }
         }
     }
 }
示例#2
0
 private void DeleteChannelGroup(ChannelGroup group)
 {
     if (group != null)
     {
         SchedulerAgent.DeleteChannelGroup(group.ChannelGroupId, true, true);
     }
 }
示例#3
0
 private void OnPriority()
 {
     if (_upcomingProgram != null)
     {
         Schedule schedule = SchedulerAgent.GetScheduleById(_upcomingProgram.ScheduleId);
         if (schedule == null)
         {
             return;
         }
         GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
         if (dlg != null)
         {
             dlg.Reset();
             dlg.SetHeading(Utility.GetLocalizedText(TextId.RecordingsListItemsSuffix));
             dlg.Add(Utility.GetLocalizedText(TextId.VeryLow));
             dlg.Add(Utility.GetLocalizedText(TextId.Low));
             dlg.Add(Utility.GetLocalizedText(TextId.Normal));
             dlg.Add(Utility.GetLocalizedText(TextId.High));
             dlg.Add(Utility.GetLocalizedText(TextId.VeryHigh));
             dlg.SelectedLabel = (int)schedule.SchedulePriority + 2;
             dlg.DoModal(GetID);
             if (dlg.SelectedLabel >= 0)
             {
                 schedule.SchedulePriority = (SchedulePriority)(dlg.SelectedLabel - 2);
                 SchedulerAgent.SaveSchedule(schedule);
             }
         }
     }
 }
示例#4
0
        private void LoadChannelsForGroup(ChannelGroup group)
        {
            _channelsInGroupList.Clear();
            _channelIdsInList.Clear();

            if (group != null)
            {
                Channel[] channels = SchedulerAgent.GetChannelsInGroup(group.ChannelGroupId, false);
                if (channels != null && channels.Length > 0)
                {
                    foreach (Channel channel in channels)
                    {
                        _channelIdsInList.Add(channel.ChannelId);
                        GUIListItem item = new GUIListItem();
                        item.Label = channel.DisplayName;
                        item.TVTag = channel;

                        string logo = Utility.GetLogoImage(channel, SchedulerAgent);
                        if (!string.IsNullOrEmpty(logo))
                        {
                            item.IconImage = logo;
                        }
                        if (!channel.VisibleInGuide)
                        {
                            item.IsPlayed = true;
                        }
                        _channelsInGroupList.Add(item);
                    }
                }
            }
        }
示例#5
0
        private string GetChannelArgumentsString(bool isforDialog)
        {
            string text = string.Empty;

            text = Utility.GetLocalizedText(TextId.Channels) + " ";
            if (_channelArguments.Count > 0)
            {
                foreach (object argument in _channelArguments)
                {
                    Channel chan = SchedulerAgent.GetChannelById(new Guid(argument.ToString()));
                    text += chan.DisplayName + ",";
                }
                text = text.Remove(text.Length - 1);
            }
            else
            {
                if (isforDialog)
                {
                    text = Utility.GetLocalizedText(TextId.SelectChannel);
                }
                else
                {
                    text += Utility.GetLocalizedText(TextId.All);
                }
            }
            return(text);
        }
示例#6
0
        private void LoadAllChannels()
        {
            _allChannelsList.Clear();

            Channel[] channels = SchedulerAgent.GetAllChannels(_currentChannelType, false);
            if (channels != null && channels.Length > 0)
            {
                foreach (Channel channel in channels)
                {
                    if (!_channelIdsInList.Contains(channel.ChannelId))
                    {
                        GUIListItem item = new GUIListItem();
                        item.Label = channel.DisplayName;
                        item.TVTag = channel;

                        string logo = Utility.GetLogoImage(channel, SchedulerAgent);
                        if (!string.IsNullOrEmpty(logo))
                        {
                            item.IconImage = logo;
                        }
                        if (!channel.VisibleInGuide)
                        {
                            item.IsPlayed = true;
                        }
                        _allChannelsList.Add(item);
                    }
                }
            }
        }
示例#7
0
        private void SaveChannelsForCurrentGroup()
        {
            if (_savingNeeded)
            {
                _savingNeeded = false;

                Guid[] channelIds;
                if (_channelsInGroupList != null && _channelsInGroupList.Count > 0)
                {
                    channelIds = new Guid[_channelsInGroupList.Count];
                    for (int i = 0; i < _channelsInGroupList.Count; i++)
                    {
                        Channel channel = _channelsInGroupList[i].TVTag as Channel;
                        channelIds[i] = channel.ChannelId;
                    }
                }
                else
                {
                    channelIds = new Guid[0];
                }

                if (_currentGroup != null)
                {
                    SchedulerAgent.SetChannelGroupMembers(_currentGroup.ChannelGroupId, channelIds);
                }
            }
        }
示例#8
0
 private void OnChangeName()
 {
     if (_upcomingProgram != null)
     {
         Schedule schedule = SchedulerAgent.GetScheduleById(_upcomingProgram.ScheduleId);
         if (schedule == null)
         {
             return;
         }
         string          schedname = schedule.Name;
         VirtualKeyboard keyboard  = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
         if (keyboard != null)
         {
             keyboard.Reset();
             keyboard.IsSearchKeyboard = false;
             keyboard.Text             = schedname ?? String.Empty;
             keyboard.DoModal(GetID);
             if (keyboard.IsConfirmed)
             {
                 schedule.Name = keyboard.Text;
                 SchedulerAgent.SaveSchedule(schedule);
             }
         }
     }
 }
示例#9
0
        private void OnChangeGuideChannel(Channel channel)
        {
            GuideChannel[] guideChannels = GuideAgent.GetAllChannels(_currentChannelType);
            if (guideChannels != null && guideChannels.Length > 0)
            {
                GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dlg != null)
                {
                    dlg.Reset();
                    dlg.SetHeading(Utility.GetLocalizedText(TextId.SelectGuideChannel));
                    dlg.Add(Utility.GetLocalizedText(TextId.None));

                    int y = 0;
                    for (int i = 0; i < guideChannels.Length; i++)
                    {
                        GUIListItem item = new GUIListItem();
                        item.Label = guideChannels[i].Name;
                        if (channel.GuideChannelId.HasValue && (guideChannels[i].GuideChannelId == channel.GuideChannelId.Value))
                        {
                            item.IsPlayed = true;
                            y             = i + 1;
                        }
                        dlg.Add(item);
                    }
                    dlg.SelectedLabel = y;

                    dlg.DoModal(GetID);
                    if (dlg.SelectedId > 0)
                    {
                        if (dlg.SelectedLabel <= 0)
                        {
                            channel.GuideChannelId = null;
                            SchedulerAgent.SaveChannel(channel);
                        }
                        else
                        {
                            GuideChannel guideChannel = guideChannels[dlg.SelectedLabel - 1];
                            SchedulerAgent.AttachChannelToGuide(channel.ChannelId, guideChannel.GuideChannelId);
                        }
                    }
                }
            }
        }
示例#10
0
        private bool OnDeleteChannel(Channel channel)
        {
            GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

            if (dlgYesNo != null)
            {
                dlgYesNo.Reset();
                dlgYesNo.SetHeading(channel.DisplayName);
                dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.DeleteChannel));
                dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure));
                dlgYesNo.SetLine(3, string.Empty);
                dlgYesNo.SetDefaultToYes(false);
                dlgYesNo.DoModal(GetID);

                if (dlgYesNo.IsConfirmed)
                {
                    SchedulerAgent.DeleteChannel(channel.ChannelId, true);
                    return(true);
                }
            }
            return(false);
        }
示例#11
0
        private static void Main(string[] args)
        {
            var worldEnv = new World(); // derived from ActressMas.ConcurrentEnvironment

            int noCells = Utils.GridSize * Utils.GridSize;

            worldEnv.InitWorldMap();

            int[] randVect = Utils.RandomPermutation(noCells);

            for (int i = 0; i < Utils.NoDoodlebugs; i++)
            {
                var a = new DoodlebugAgent();
                worldEnv.Add(a, worldEnv.CreateName(a)); // unique name
                worldEnv.AddAgentToMap(a, randVect[i]);
                a.Start();
            }

            for (int i = Utils.NoDoodlebugs; i < Utils.NoDoodlebugs + Utils.NoAnts; i++)
            {
                var a = new AntAgent();
                worldEnv.Add(a, worldEnv.CreateName(a));
                worldEnv.AddAgentToMap(a, randVect[i]);
                a.Start();
            }

            //for (int i = 0; i < worldEnv.NoAgents; i++)
            //{
            //    worldEnv.Agents[i].Start();
            //}

            var s = new SchedulerAgent();

            worldEnv.Add(s, "scheduler");
            s.Start();

            worldEnv.WaitAll();
        }
示例#12
0
        private void CreateNewChannelGroup()
        {
            VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);

            if (keyboard != null)
            {
                keyboard.Reset();
                keyboard.IsSearchKeyboard = false;
                keyboard.Text             = string.Empty;
                keyboard.DoModal(GetID);
                if (keyboard.IsConfirmed && keyboard.Text != string.Empty)
                {
                    ChannelGroup group = new ChannelGroup()
                    {
                        Sequence       = GetAllChannelGroups().Length,
                        ChannelType    = _currentChannelType,
                        VisibleInGuide = true,
                        GroupName      = keyboard.Text
                    };

                    SchedulerAgent.SaveChannelGroup(group);
                }
            }
        }
示例#13
0
        private void SetLabels()
        {
            UpcomingRecording[]             upcomingRecordings       = ControlAgent.GetAllUpcomingRecordings(UpcomingRecordingsFilter.All, true);
            UpcomingGuideProgram[]          upcomingAlerts           = SchedulerAgent.GetUpcomingGuidePrograms(ScheduleType.Alert, true);
            UpcomingGuideProgram[]          upcomingSuggestions      = SchedulerAgent.GetUpcomingGuidePrograms(ScheduleType.Suggestion, true);
            UpcomingGuideProgramsDictionary AllUpcomingGuidePrograms = new UpcomingGuideProgramsDictionary(upcomingRecordings, upcomingAlerts, upcomingSuggestions);

            foreach (GUIListItem item in _viewsList.ListItems)
            {
                if (item.Label != _parentDirectoryLabel)
                {
                    UpcomingProgram program = item.TVTag as UpcomingProgram;
                    if (program != null)
                    {
                        if (!item.IsFolder)
                        {
                            item.PinImage = null;
                            Guid upcomingProgramId = program.UpcomingProgramId;
                            if (AllUpcomingGuidePrograms.ContainsKey(upcomingProgramId))
                            {
                                GuideUpcomingProgram programInfo = AllUpcomingGuidePrograms[upcomingProgramId];
                                item.PinImage = Utility.GetIconImageFileName(programInfo.Type, programInfo.IsPartOfSeries,
                                                                             programInfo.CancellationReason, programInfo.UpcomingRecording);
                            }

                            string title = GuideProgram.CreateProgramTitle(program.Title, program.SubTitle, program.EpisodeNumberDisplay);
                            item.Label = title;
                            string logoImagePath = Utility.GetLogoImage(program.Channel, _tvSchedulerAgent);
                            if (logoImagePath == null ||
                                !System.IO.File.Exists(logoImagePath))
                            {
                                item.Label    = String.Format("[{0}] {1}", program.Channel.DisplayName, title);
                                logoImagePath = "defaultVideoBig.png";
                            }

                            item.ThumbnailImage = logoImagePath;
                            item.IconImageBig   = logoImagePath;
                            item.IconImage      = logoImagePath;

                            item.Label2 = String.Format("{0} {1} - {2}", Utility.GetShortDayDateString(program.StartTime),
                                                        program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                        program.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                            if (_currentSortMethod == SortMethod.Channel)
                            {
                                item.Label3 = program.Channel.DisplayName;
                            }
                            else
                            {
                                item.Label3 = program.Category;
                            }
                        }
                        else
                        {
                            Utils.SetDefaultIcons(item);
                            item.Label = program.Title;
                        }
                    }
                }
            }
            AllUpcomingGuidePrograms.Clear();
            AllUpcomingGuidePrograms = null;
        }
示例#14
0
        private void ShowSearchResults(string selectedTitle)
        {
            GUIControl.ClearControl(GetID, _viewsList.GetID);
            if (_rules == null || _rules.Count == 0)
            {
                _viewsList.Clear();
                _selectedTitle    = string.Empty;
                _isInSubDirectory = false;
                return;
            }

            List <ScheduleRule> rules = new List <ScheduleRule>();

            for (int i = 0; i < _rules.Count; i++)
            {
                rules.Add(_rules[i]);
            }

            if (selectedTitle != string.Empty)
            {
                rules.Add(ScheduleRuleType.TitleEquals, selectedTitle);
            }

            if (_categorieArguments.Count > 0)
            {
                rules.Add(ScheduleRuleType.CategoryEquals, _categorieArguments.ToArray());
            }
            if (_channelArguments.Count > 0)
            {
                rules.Add(ScheduleRuleType.Channels, _channelArguments.ToArray());
            }

            Schedule _schedule = SchedulerAgent.CreateNewSchedule(this._channelType, ScheduleType.Recording);

            _schedule.Rules = rules;
            UpcomingProgram[] _searchResults = SchedulerAgent.GetUpcomingPrograms(_schedule, true);

            if (_searchResults.Length < 1)
            {
                GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                dlg.Reset();
                dlg.SetHeading(Utility.GetLocalizedText(TextId.Information));
                dlg.SetLine(1, Utility.GetLocalizedText(TextId.NoProgrammesFound));
                dlg.DoModal(GUIWindowManager.ActiveWindow);
                _isInSubDirectory = false;
                _selectedTitle    = string.Empty;
                return;
            }

            _selectedTitle = selectedTitle;
            if (selectedTitle == string.Empty)
            {
                List <String> upcomingTitles = new List <String>();
                foreach (UpcomingProgram program in _searchResults)
                {
                    if (!upcomingTitles.Contains(program.Title))
                    {
                        upcomingTitles.Add(program.Title);
                        _viewsList.Add(CreateListItem(program, true));
                    }
                }
                _isInSubDirectory = false;
            }
            else
            {
                GUIListItem item = new GUIListItem();
                item.Label    = _parentDirectoryLabel;
                item.IsFolder = true;
                Utils.SetDefaultIcons(item);
                _viewsList.Add(item);

                foreach (UpcomingProgram program in _searchResults)
                {
                    _viewsList.Add(CreateListItem(program, false));
                }
                _isInSubDirectory = true;
            }

            string strObjects = string.Format("{0}", _viewsList.Count - (_isInSubDirectory ? 1 : 0));

            GUIPropertyManager.SetProperty("#itemcount", strObjects);

            OnSort();
            int selectedItemIndex;

            if (_isInSubDirectory)
            {
                selectedItemIndex = _selectedProgramIndex;
            }
            else
            {
                selectedItemIndex = _selectedTitleIndex;
            }

            while (selectedItemIndex >= _viewsList.Count && selectedItemIndex > 0)
            {
                selectedItemIndex--;
            }
            GUIControl.SelectItemControl(GetID, _viewsList.GetID, selectedItemIndex);
            UpdateProperties();
        }
示例#15
0
        private void LoadUpcomingPrograms(ScheduleSummary schedule)
        {
            GUIControl.ClearControl(GetID, _viewsList.GetID);

            if (schedule == null)
            {
                _isInSubDirectory = false;
                bool group = false;
                if (_groupBySchedButton != null)
                {
                    group = _groupBySchedButton.Selected;
                }

                if (group)
                {
                    ScheduleSummary[] schedules = SchedulerAgent.GetAllSchedules(this._channelType, _currentProgramType, true);
                    foreach (ScheduleSummary sched in schedules)
                    {
                        GUIListItem item = CreateListItem(null, null, sched);
                        _viewsList.Add(item);
                    }
                }
                else
                {
                    if (_currentProgramType == ScheduleType.Recording)
                    {
                        List <UpcomingRecording> upcomingRecordings = new List <UpcomingRecording>(
                            this.ControlAgent.GetAllUpcomingRecordings(UpcomingRecordingsFilter.Recordings | UpcomingRecordingsFilter.CancelledByUser, false));
                        foreach (UpcomingRecording recording in upcomingRecordings)
                        {
                            if (recording.Program.Channel.ChannelType == this._channelType)
                            {
                                GUIListItem item = CreateListItem(recording.Program, recording, null);
                                _viewsList.Add(item);
                            }
                        }
                    }
                    else
                    {
                        List <UpcomingProgram> upcomingPrograms = new List <UpcomingProgram>(
                            this.SchedulerAgent.GetAllUpcomingPrograms(_currentProgramType, true));
                        foreach (UpcomingProgram program in upcomingPrograms)
                        {
                            if (program.Channel.ChannelType == this._channelType)
                            {
                                GUIListItem item = CreateListItem(program, null, null);
                                _viewsList.Add(item);
                            }
                        }
                    }
                }
            }
            else if (schedule != null)
            {
                //add prev directory folder
                GUIListItem item = new GUIListItem();
                item.Label    = _parentDirectoryLabel;
                item.IsFolder = true;
                Utils.SetDefaultIcons(item);
                _viewsList.Add(item);

                _selectedSchedule = schedule;
                if (_currentProgramType == ScheduleType.Recording)
                {
                    UpcomingRecording[] upcomingRecordings = ControlAgent.GetUpcomingRecordings(schedule.ScheduleId, true);
                    foreach (UpcomingRecording recording in upcomingRecordings)
                    {
                        item = CreateListItem(recording.Program, recording, null);
                        _viewsList.Add(item);
                    }
                }
                else
                {
                    Schedule          sched            = SchedulerAgent.GetScheduleById(schedule.ScheduleId);
                    UpcomingProgram[] upcomingPrograms = SchedulerAgent.GetUpcomingPrograms(sched, true);
                    foreach (UpcomingProgram upcomingProgram in upcomingPrograms)
                    {
                        item = CreateListItem(upcomingProgram, null, null);
                        _viewsList.Add(item);
                    }
                }

                _isInSubDirectory = true;
            }

            string strObjects = string.Format("{0}", _viewsList.Count - (_viewsList.Count > 0 && _viewsList[0].Label == _parentDirectoryLabel ? 1 : 0));

            GUIPropertyManager.SetProperty("#itemcount", strObjects);

            OnSort();
            UpdateButtonStates();
            UpdateProperties();

            if (GetItemCount() > 0)
            {
                if (_isInSubDirectory)
                {
                    while (m_iSelectedItemInFolder >= GetItemCount() && m_iSelectedItemInFolder > 0)
                    {
                        m_iSelectedItemInFolder--;
                    }
                    GUIControl.SelectItemControl(GetID, _viewsList.GetID, m_iSelectedItemInFolder);
                }
                else
                {
                    while (m_iSelectedItem >= GetItemCount() && m_iSelectedItem > 0)
                    {
                        m_iSelectedItem--;
                    }
                    GUIControl.SelectItemControl(GetID, _viewsList.GetID, m_iSelectedItem);
                }
            }
        }
示例#16
0
        private void Update(Schedule _schedule)
        {
            _upcomingEpsiodesList.Clear();
            if (_programTimeLabel != null && _programTitleFadeLabel != null)
            {
                if (_upcomingProgram != null)
                {
                    string strTime = String.Format("{0} {1} - {2}",
                                                   Utility.GetShortDayDateString(_upcomingProgram.StartTime),
                                                   _upcomingProgram.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                   _upcomingProgram.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                    _programTimeLabel.Label      = strTime;
                    _programTitleFadeLabel.Label = _upcomingProgram.Title;
                }
                else
                {
                    _programTimeLabel.Label      = string.Empty;
                    _programTitleFadeLabel.Label = string.Empty;
                }
            }

            if (_schedule != null)
            {
                if (_schedule.ScheduleType == ScheduleType.Recording)
                {
                    UpcomingRecording[] recordings = ControlAgent.GetUpcomingRecordings(_schedule.ScheduleId, true);
                    foreach (UpcomingRecording recording in recordings)
                    {
                        GUIListItem item  = new GUIListItem();
                        string      title = recording.Title;
                        item.Label = title;
                        string logoImagePath = Utility.GetLogoImage(recording.Program.Channel, SchedulerAgent);
                        if (logoImagePath == null ||
                            !System.IO.File.Exists(logoImagePath))
                        {
                            item.Label    = String.Format("[{0}] {1}", recording.Program.Channel.DisplayName, title);
                            logoImagePath = "defaultVideoBig.png";
                        }

                        item.PinImage = Utility.GetIconImageFileName(ScheduleType.Recording, recording.Program.IsPartOfSeries,
                                                                     recording.Program.CancellationReason, recording);

                        item.TVTag          = recording;
                        item.ThumbnailImage = logoImagePath;
                        item.IconImageBig   = logoImagePath;
                        item.IconImage      = logoImagePath;
                        item.Label2         = String.Format("{0} {1} - {2}",
                                                            Utility.GetShortDayDateString(recording.StartTime),
                                                            recording.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                            recording.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                        _upcomingEpsiodesList.Add(item);
                    }
                }
                else
                {
                    UpcomingProgram[] _progs = SchedulerAgent.GetUpcomingPrograms(_schedule, true);
                    foreach (UpcomingProgram program in _progs)
                    {
                        GUIListItem item  = new GUIListItem();
                        string      title = program.Title;
                        item.Label = title;
                        //item.OnItemSelected += new global::MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(item_OnItemSelected);
                        string logoImagePath = Utility.GetLogoImage(program.Channel, SchedulerAgent);
                        if (logoImagePath == null ||
                            !System.IO.File.Exists(logoImagePath))
                        {
                            item.Label    = String.Format("[{0}] {1}", program.Channel.DisplayName, title);
                            logoImagePath = "defaultVideoBig.png";
                        }

                        if (_schedule.ScheduleType == ScheduleType.Alert)
                        {
                            item.PinImage = item.PinImage = Utility.GetIconImageFileName(ScheduleType.Alert, program.IsPartOfSeries,
                                                                                         program.CancellationReason, null);
                        }
                        item.TVTag          = program;
                        item.ThumbnailImage = logoImagePath;
                        item.IconImageBig   = logoImagePath;
                        item.IconImage      = logoImagePath;
                        item.Label2         = String.Format("{0} {1} - {2}",
                                                            Utility.GetShortDayDateString(program.StartTime),
                                                            program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                            program.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                        _upcomingEpsiodesList.Add(item);
                    }
                }
            }
            _upcomingEpisodesLabel.IsVisible = (_upcomingEpsiodesList != null && _upcomingEpsiodesList.Count > 0);
        }
示例#17
0
        private void OnChannelSelected(GUIListItem item, int iItem, bool isAllChannelList)
        {
            Channel channel = item.TVTag as Channel;

            if (channel == null)
            {
                return;
            }

            if (isAllChannelList)
            {
                GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dlg != null)
                {
                    dlg.Reset();
                    dlg.SetHeading(channel.DisplayName);

                    dlg.Add(Utility.GetLocalizedText(TextId.AddToGroup));
                    if (channel.VisibleInGuide)
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.HideFromGuide));
                    }
                    else
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.ShowInGuide));
                    }

                    string text = Utility.GetLocalizedText(TextId.None);
                    if (channel.GuideChannelId.HasValue)
                    {
                        GuideChannel ch = GetGuideChannelForChannel(channel);
                        if (ch != null)
                        {
                            text = ch.Name;
                        }
                    }
                    dlg.Add(Utility.GetLocalizedText(TextId.GuideChannel) + ": " + text);
                    dlg.Add(Utility.GetLocalizedText(TextId.DeleteChannel));

                    dlg.DoModal(GetID);
                    if (dlg.SelectedId > 0)
                    {
                        _savingNeeded = true;

                        switch (dlg.SelectedLabel)
                        {
                        case 0:
                        {
                            _channelsInGroupList.Add(item);
                            _allChannelsList.RemoveItem(iItem);
                        }
                        break;

                        case 1:
                        {
                            if (channel.VisibleInGuide)
                            {
                                item.IsPlayed          = true;
                                channel.VisibleInGuide = false;
                            }
                            else
                            {
                                item.IsPlayed          = false;
                                channel.VisibleInGuide = true;
                            }
                            SchedulerAgent.SaveChannel(channel);
                        }
                        break;

                        case 2:
                        {
                            OnChangeGuideChannel(channel);
                            item.TVTag = SchedulerAgent.GetChannelById(channel.ChannelId);
                        }
                        break;

                        case 3:
                        {
                            if (OnDeleteChannel(channel))
                            {
                                _allChannelsList.RemoveItem(iItem);
                            }
                        }
                        break;
                        }
                    }
                }
            }
            else// channels in group list
            {
                if (!item.IsRemote)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    if (dlg != null)
                    {
                        dlg.Reset();
                        dlg.SetHeading(channel.DisplayName);

                        dlg.Add(Utility.GetLocalizedText(TextId.MoveChannel));
                        dlg.Add(Utility.GetLocalizedText(TextId.DeleteChannelFromGroup));
                        if (channel.VisibleInGuide)
                        {
                            dlg.Add(Utility.GetLocalizedText(TextId.HideFromGuide));
                        }
                        else
                        {
                            dlg.Add(Utility.GetLocalizedText(TextId.ShowInGuide));
                        }

                        string text = Utility.GetLocalizedText(TextId.None);
                        if (channel.GuideChannelId.HasValue)
                        {
                            GuideChannel ch = GetGuideChannelForChannel(channel);
                            if (ch != null)
                            {
                                text = ch.Name;
                            }
                        }
                        dlg.Add(Utility.GetLocalizedText(TextId.GuideChannel) + ": " + text);
                        dlg.Add(Utility.GetLocalizedText(TextId.DeleteChannel));

                        dlg.DoModal(GetID);
                        if (dlg.SelectedId > 0)
                        {
                            _savingNeeded = true;

                            switch (dlg.SelectedLabel)
                            {
                            case 0:
                                item.IsRemote = true;
                                break;

                            case 1:
                            {
                                _channelsInGroupList.RemoveItem(iItem);
                                _allChannelsList.Add(item);
                            }
                            break;

                            case 2:
                            {
                                if (channel.VisibleInGuide)
                                {
                                    item.IsPlayed          = true;
                                    channel.VisibleInGuide = false;
                                }
                                else
                                {
                                    item.IsPlayed          = false;
                                    channel.VisibleInGuide = true;
                                }
                                SchedulerAgent.SaveChannel(channel);
                            }
                            break;

                            case 3:
                            {
                                OnChangeGuideChannel(channel);
                                item.TVTag = SchedulerAgent.GetChannelById(channel.ChannelId);
                            }
                            break;

                            case 4:
                            {
                                if (OnDeleteChannel(channel))
                                {
                                    _channelsInGroupList.RemoveItem(iItem);
                                }
                            }
                            break;
                            }
                        }
                    }
                }
                else
                {
                    item.IsRemote = false;
                }
            }
        }
示例#18
0
        private void UpdateDateTime()
        {
            DateTime     time        = DateTime.Now;
            Schedule     sched       = null;
            ScheduleRule _manualRule = null;
            int          valueYear   = 0;
            bool         yearFound   = true;

            if (_upcomingProgram != null)
            {
                sched = SchedulerAgent.GetScheduleById(_upcomingProgram.ScheduleId);
                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;
            }
        }
示例#19
0
        private void UpdateButtonStates()
        {
            Schedule sched = null;

            if (_upcomingProgram != null)
            {
                sched = SchedulerAgent.GetScheduleById(_upcomingProgram.ScheduleId);
            }

            if (_upcomingProgram != null &&
                sched != null &&
                sched.ScheduleType == ScheduleType.Recording &&
                !_upcomingProgram.IsCancelled)
            {
                _RecordButton.Label      = Utility.GetLocalizedText(TextId.DontRecord);
                _AlertMeButton.IsEnabled = false;
            }
            else
            {
                _RecordButton.Label      = Utility.GetLocalizedText(TextId.Record);
                _AlertMeButton.IsEnabled = true;
            }

            if (_upcomingProgram != null &&
                sched != null &&
                sched.ScheduleType == ScheduleType.Alert &&
                !_upcomingProgram.IsCancelled)
            {
                _AlertMeButton.Label = Utility.GetLocalizedText(TextId.CancelReminder);
            }
            else
            {
                _AlertMeButton.Label = Utility.GetLocalizedText(TextId.SetReminder);
            }

            _StartTimeLabel.Label  = Utility.GetLocalizedText(TextId.OnDate);
            _SelectDaysLabel.Label = Utility.GetLocalizedText(TextId.SelectDays);

            if (_upcomingProgram != null && sched != null)
            {
                try
                {
                    var daysofweekrule = sched.Rules.FindRuleByType(ScheduleRuleType.DaysOfWeek);
                    if (daysofweekrule != null)
                    {
                        string daysofweek = daysofweekrule.Arguments[0].ToString();

                        if (daysofweek.Contains(ScheduleDaysOfWeek.Mondays.ToString()))
                        {
                            _mondayButton.Selected = true;
                        }
                        if (daysofweek.Contains(ScheduleDaysOfWeek.Tuesdays.ToString()))
                        {
                            _tuesdayButton.Selected = true;
                        }
                        if (daysofweek.Contains(ScheduleDaysOfWeek.Wednesdays.ToString()))
                        {
                            _wednesdayButton.Selected = true;
                        }
                        if (daysofweek.Contains(ScheduleDaysOfWeek.Thursdays.ToString()))
                        {
                            _thursdayButton.Selected = true;
                        }
                        if (daysofweek.Contains(ScheduleDaysOfWeek.Fridays.ToString()))
                        {
                            _fridayButton.Selected = true;
                        }
                        if (daysofweek.Contains(ScheduleDaysOfWeek.Saturdays.ToString()))
                        {
                            _saturdayButton.Selected = true;
                        }
                        if (daysofweek.Contains(ScheduleDaysOfWeek.Sundays.ToString()))
                        {
                            _sundayButton.Selected = true;
                        }
                    }
                }
                catch
                {
                    Log.Error("ManualSchedule: error updating select buttons");
                }

                _spinChannel.IsEnabled         = false;
                _spinGroup.IsEnabled           = false;
                _spinHoursDuration.IsEnabled   = false;
                _spinMinutesDuration.IsEnabled = false;
                _spinStartDay.IsEnabled        = false;
                _spinStartHour.IsEnabled       = false;
                _spinStartMinute.IsEnabled     = false;
                _spinStartMonth.IsEnabled      = false;
                _spinStartYear.IsEnabled       = false;

                _mondayButton.IsEnabled    = false;
                _tuesdayButton.IsEnabled   = false;
                _wednesdayButton.IsEnabled = false;
                _thursdayButton.IsEnabled  = false;
                _fridayButton.IsEnabled    = false;
                _saturdayButton.IsEnabled  = false;
                _sundayButton.IsEnabled    = false;

                if (sched.ScheduleType == ScheduleType.Recording &&
                    !_upcomingProgram.IsCancelled)
                {
                    _KeepButton.IsEnabled     = true;
                    _PriorityButton.IsEnabled = true;
                }
                else
                {
                    _KeepButton.IsEnabled     = false;
                    _PriorityButton.IsEnabled = false;
                }

                if (_upcomingProgram.IsCancelled)
                {
                    _ChangeNameButton.IsEnabled = false;
                }
                else
                {
                    _ChangeNameButton.IsEnabled = true;
                }
            }
            else
            {
                _spinChannel.IsEnabled         = true;
                _spinGroup.IsEnabled           = true;
                _spinHoursDuration.IsEnabled   = true;
                _spinMinutesDuration.IsEnabled = true;
                _spinStartDay.IsEnabled        = true;
                _spinStartHour.IsEnabled       = true;
                _spinStartMinute.IsEnabled     = true;
                _spinStartMonth.IsEnabled      = true;
                _spinStartYear.IsEnabled       = true;

                _mondayButton.IsEnabled    = true;
                _tuesdayButton.IsEnabled   = true;
                _wednesdayButton.IsEnabled = true;
                _thursdayButton.IsEnabled  = true;
                _fridayButton.IsEnabled    = true;
                _saturdayButton.IsEnabled  = true;
                _sundayButton.IsEnabled    = true;

                _KeepButton.IsEnabled       = false;
                _PriorityButton.IsEnabled   = false;
                _ChangeNameButton.IsEnabled = false;
            }

            if (_mondayButton.Selected || _tuesdayButton.Selected || _wednesdayButton.Selected ||
                _thursdayButton.Selected || _fridayButton.Selected || _saturdayButton.Selected ||
                _sundayButton.Selected)
            {
                _StartTimeLabel.Label = Utility.GetLocalizedText(TextId.FromDate);
                _recordOnce           = false;
            }
            else
            {
                _StartTimeLabel.Label = Utility.GetLocalizedText(TextId.OnDate);
                _recordOnce           = true;
            }

            Update(sched);
        }
示例#20
0
        private void OnKeep()
        {
            if (_upcomingProgram != null)
            {
                Schedule schedule = SchedulerAgent.GetScheduleById(_upcomingProgram.ScheduleId);
                if (schedule == null)
                {
                    return;
                }

                GUIDialogMenu dialog = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dialog == null)
                {
                    return;
                }
                dialog.Reset();

                dialog.SetHeading(1042); // Keep until
                dialog.Add(Utility.GetLocalizedText(TextId.UntilSpaceNeeded));
                dialog.Add(Utility.GetLocalizedText(TextId.NumberOfDays));
                dialog.Add(Utility.GetLocalizedText(TextId.NumberOfEpisodes));
                dialog.Add(Utility.GetLocalizedText(TextId.NumberOfWatchedEpisodes));
                dialog.Add(Utility.GetLocalizedText(TextId.Forever));

                switch (schedule.KeepUntilMode)
                {
                case KeepUntilMode.UntilSpaceIsNeeded:
                    dialog.SelectedLabel = 0;
                    break;

                case KeepUntilMode.NumberOfDays:
                    dialog.SelectedLabel = 1;
                    break;

                case KeepUntilMode.NumberOfEpisodes:
                    dialog.SelectedLabel = 2;
                    break;

                case KeepUntilMode.NumberOfWatchedEpisodes:
                    dialog.SelectedLabel = 3;
                    break;

                case KeepUntilMode.Forever:
                    dialog.SelectedLabel = 4;
                    break;
                }

                dialog.DoModal(GetID);
                if (dialog.SelectedId == -1)
                {
                    return;
                }

                switch (dialog.SelectedLabel)
                {
                case 0:
                    schedule.KeepUntilMode = KeepUntilMode.UntilSpaceIsNeeded;
                    break;

                case 1:
                {
                    int?value = GetKeepValue(1045, KeepUntilMode.NumberOfDays, 3014, 3015,
                                             schedule.KeepUntilMode == KeepUntilMode.NumberOfDays ? schedule.KeepUntilValue : 7);
                    if (value.HasValue)
                    {
                        schedule.KeepUntilMode  = KeepUntilMode.NumberOfDays;
                        schedule.KeepUntilValue = value;
                    }
                }
                break;

                case 2:
                {
                    int?value = GetKeepValue(887, KeepUntilMode.NumberOfEpisodes, 682, 914,
                                             schedule.KeepUntilMode == KeepUntilMode.NumberOfEpisodes ? schedule.KeepUntilValue : 3);
                    if (value.HasValue)
                    {
                        schedule.KeepUntilMode  = KeepUntilMode.NumberOfEpisodes;
                        schedule.KeepUntilValue = value;
                    }
                }
                break;

                case 3:
                {
                    int?value = GetKeepValue(887, KeepUntilMode.NumberOfWatchedEpisodes, 682, 914,
                                             schedule.KeepUntilMode == KeepUntilMode.NumberOfWatchedEpisodes ? schedule.KeepUntilValue : 3);
                    if (value.HasValue)
                    {
                        schedule.KeepUntilMode  = KeepUntilMode.NumberOfWatchedEpisodes;
                        schedule.KeepUntilValue = value;
                    }
                }
                break;

                case 4:
                    schedule.KeepUntilMode = KeepUntilMode.Forever;
                    break;
                }

                if (schedule != null)
                {
                    SchedulerAgent.SaveSchedule(schedule);
                }
            }
        }
示例#21
0
        private void UpdateChannels()
        {
            Schedule schedule     = null;
            bool     channelFound = false;
            int      channelIndex = 0;
            int      groupIndex   = 0;

            if (_upcomingProgram != null)
            {
                schedule = SchedulerAgent.GetScheduleById(_upcomingProgram.ScheduleId);
                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 SchedulerAgent.GetChannelsInGroup(group.ChannelGroupId, true))
                    {
                        _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;
            }
        }
示例#22
0
        private void OnGroupSelected(GUIListItem item, int iItem)
        {
            ChannelGroup  group = item.TVTag as ChannelGroup;
            GUIDialogMenu dlg   = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg != null)
            {
                dlg.Reset();
                dlg.SetHeading(group.GroupName);

                dlg.Add(Utility.GetLocalizedText(TextId.SelectThisGroup));
                dlg.Add(Utility.GetLocalizedText(TextId.DeleteThisGroup));
                if (group.VisibleInGuide)
                {
                    dlg.Add(Utility.GetLocalizedText(TextId.HideFromGuide));
                }
                else
                {
                    dlg.Add(Utility.GetLocalizedText(TextId.ShowInGuide));
                }

                dlg.DoModal(GetID);
                if (dlg.SelectedId > 0)
                {
                    switch (dlg.SelectedLabel)
                    {
                    case 0:
                    {
                        foreach (GUIListItem Item in _channelGroupsList.ListItems)
                        {
                            Item.IsRemote = false;
                        }
                        item.IsRemote = true;

                        SaveChannelsForCurrentGroup();
                        LoadAll(group);
                    }
                    break;

                    case 1:
                    {
                        //_channelGroupsList.RemoveItem(iItem);
                        SchedulerAgent.DeleteChannelGroup(group.ChannelGroupId, true, true);
                        LoadAll(null);
                    }
                    break;

                    case 2:
                    {
                        if (group.VisibleInGuide)
                        {
                            item.IsPlayed        = true;
                            group.VisibleInGuide = false;
                        }
                        else
                        {
                            item.IsPlayed        = false;
                            group.VisibleInGuide = true;
                        }
                        SchedulerAgent.SaveChannelGroup(group);
                    }
                    break;
                    }
                }
            }
        }
示例#23
0
        private void Onrecord(ScheduleType scheduleType)
        {
            Schedule schedule = null;

            if (_upcomingProgram != null)
            {
                schedule = SchedulerAgent.GetScheduleById(_upcomingProgram.ScheduleId);
            }
            if (_upcomingProgram != null && schedule != null &&
                schedule.ScheduleType == scheduleType)   //delete schedule
            {
                if (_upcomingProgram.IsCancelled)
                {
                    SchedulerAgent.UncancelUpcomingProgram(_upcomingProgram.ScheduleId, _upcomingProgram.GuideProgramId, _upcomingProgram.Channel.ChannelId, _upcomingProgram.StartTime);
                    try
                    {
                        //refresh _upcomingProgram
                        _upcomingProgram = SchedulerAgent.GetUpcomingPrograms(schedule, true)[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)
                            {
                                SchedulerAgent.DeleteSchedule(schedule.ScheduleId);
                                _upcomingProgram = null;
                            }
                        }
                    }
                    else
                    {
                        SchedulerAgent.DeleteSchedule(_upcomingProgram.ScheduleId);
                        _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 = SchedulerAgent.GetChannelByDisplayName(_channelType, _spinChannel.GetLabel());

                Schedule newSchedule = null;
                newSchedule = SchedulerAgent.CreateNewSchedule(_channelType, scheduleType);
                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;
                    SchedulerAgent.SaveSchedule(newSchedule);

                    bool found = false;
                    UpcomingProgram[] _programs = SchedulerAgent.GetAllUpcomingPrograms(scheduleType, true);
                    foreach (UpcomingProgram _prog in _programs)
                    {
                        if (_prog.Channel.ChannelId == channel.ChannelId &&
                            _prog.Duration == duration &&
                            !found)
                        {
                            Schedule _schedule = SchedulerAgent.GetScheduleById(_prog.ScheduleId);
                            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();
                    }
                }
            }
        }
示例#24
0
 private ChannelGroup[] GetAllChannelGroups()
 {
     return(SchedulerAgent.GetAllChannelGroups(_currentChannelType, true));
 }
示例#25
0
        protected override void OnClicked(int controlId, GUIControl control, global::MediaPortal.GUI.Library.Action.ActionType actionType)
        {
            base.OnClicked(controlId, control, actionType);

            if (control == _searchButton)
            {
                _selectedTitleIndex   = 0;
                _selectedProgramIndex = 0;

                if (_rules.Count > 0)
                {
                    GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                    if (dlgYesNo != null)
                    {
                        dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.Attention));
                        dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.ContinueWithPrevResults));
                        dlgYesNo.SetDefaultToYes(true);
                        dlgYesNo.DoModal(GetID);
                        if (!dlgYesNo.IsConfirmed)
                        {
                            _rules.Clear();
                            if (_viewsList != null && _viewsList.Count > 0)
                            {
                                _viewsList.Clear();
                            }
                        }
                    }
                }

                VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                if (keyboard != null)
                {
                    keyboard.Reset();
                    keyboard.IsSearchKeyboard = true;
                    keyboard.Text             = String.Empty;
                    keyboard.DoModal(GetID);
                    if (keyboard.IsConfirmed)
                    {
                        if (keyboard.Text == string.Empty)
                        {
                            GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                            if (dlgOk != null)
                            {
                                dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information));
                                dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoValidSearchText));
                                dlgOk.DoModal(GetID);
                            }
                        }
                        else
                        {
                            switch (_currentSearchMethod)
                            {
                            case SearchInMethod.Title:
                                _rules.Add(ScheduleRuleType.TitleContains, keyboard.Text);
                                break;

                            case SearchInMethod.Description:
                                _rules.Add(ScheduleRuleType.DescriptionContains, keyboard.Text);
                                break;

                            case SearchInMethod.ProgramInfo:
                                _rules.Add(ScheduleRuleType.ProgramInfoContains, keyboard.Text);
                                break;

                            case SearchInMethod.Actor:
                                _rules.Add(ScheduleRuleType.WithActor, keyboard.Text);
                                break;

                            case SearchInMethod.DirectedBy:
                                _rules.Add(ScheduleRuleType.DirectedBy, keyboard.Text);
                                break;
                            }
                            ShowSearchResults(string.Empty);
                        }
                    }
                }
            }
            else if (control == _searchMethodButton)
            {
                GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                if (dlg == null)
                {
                    return;
                }
                dlg.Reset();
                dlg.SetHeading(467);
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnTitle));
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnDescription));
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnProgramInfo));
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnActor));
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnDirectedBy));

                dlg.SelectedLabel = (int)_currentSearchMethod;
                // show dialog and wait for result
                dlg.DoModal(GetID);
                if (dlg.SelectedId == -1)
                {
                    return;
                }
                _currentSearchMethod = (SearchInMethod)(dlg.SelectedLabel);
                UpdateButtonStates();
            }
            else if (control == _selectChannelsButton)
            {
                List <ChannelGroup> groups         = new List <ChannelGroup>(PluginMain.Navigator.GetGroups(this._channelType));
                ChannelGroup        _selectedGroup = new ChannelGroup();

                if (groups.Count > 0)
                {
                    if (groups.Count > 1)
                    {
                        GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                        if (dlg == null)
                        {
                            return;
                        }

                        dlg.Reset();
                        dlg.SetHeading(Utility.GetLocalizedText(TextId.SelectGroup));
                        foreach (ChannelGroup group in groups)
                        {
                            dlg.Add(group.GroupName);
                        }

                        // show dialog and wait for result
                        dlg.DoModal(GetID);
                        if (dlg.SelectedId == -1)
                        {
                            return;
                        }
                        _selectedGroup = groups[dlg.SelectedId - 1];
                    }
                    else
                    {
                        _selectedGroup = groups[0];
                    }

                    List <Channel> channels = new List <Channel>();
                    if (_channelArguments.Count > 0)
                    {
                        List <Channel> channels2 = new List <Channel>(SchedulerAgent.GetChannelsInGroup(_selectedGroup.ChannelGroupId, true));
                        foreach (Channel channel in channels2)
                        {
                            if (!_channelArguments.Contains(channel.ChannelId))
                            {
                                channels.Add(channel);
                            }
                        }
                    }
                    else
                    {
                        channels = new List <Channel>(SchedulerAgent.GetChannelsInGroup(_selectedGroup.ChannelGroupId, true));
                    }

                    if (channels.Count > 0)
                    {
                        GUIDialogMenu dlg2 = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                        if (dlg2 == null)
                        {
                            return;
                        }

                        dlg2.Reset();
                        dlg2.SetHeading(GetChannelArgumentsString(true));
                        foreach (Channel channel in channels)
                        {
                            dlg2.Add(channel.DisplayName);
                        }

                        // show dialog and wait for result
                        dlg2.DoModal(GetID);
                        if (dlg2.SelectedId == -1)
                        {
                            return;
                        }
                        _channelArguments.Add(channels[dlg2.SelectedId - 1].ChannelId);
                        UpdateButtonStates();
                    }
                    else
                    {
                        GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                        if (dlgOk != null)
                        {
                            dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information));
                            dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoMoreChannelsToAdd));
                            dlgOk.DoModal(GetID);
                        }
                    }
                }
            }
            else if (control == _selectCategoriesButton)
            {
                List <string> categories  = new List <string>();
                string[]      _categories = new string[0];
                _categories = GuideAgent.GetAllCategories();

                foreach (string categorie in _categories)
                {
                    if (!_categorieArguments.Contains(categorie))
                    {
                        categories.Add(categorie);
                    }
                }

                if (categories.Count > 0)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }

                    dlg.Reset();
                    dlg.SetHeading(GetCategorieArgumentString(true));
                    foreach (string categorie in categories)
                    {
                        dlg.Add(categorie);
                    }

                    // show dialog and wait for result
                    dlg.DoModal(GetID);
                    if (dlg.SelectedId == -1)
                    {
                        return;
                    }
                    _categorieArguments.Add(dlg.SelectedLabelText);
                    UpdateButtonStates();
                }
                else
                {
                    GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                    if (dlgOk != null)
                    {
                        dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information));
                        dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoMoreCategoriesToAdd));
                        dlgOk.DoModal(GetID);
                    }
                }
            }
            else if (control == _clearButton)
            {
                OnClearRules(true);
                ShowSearchResults(string.Empty);
                UpdateButtonStates();
            }
            else if (control == _sortByButton)
            {
                if (_isInSubDirectory)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }
                    dlg.Reset();
                    dlg.SetHeading(495);         //Sort Options
                    dlg.AddLocalizedString(620); //channel
                    dlg.AddLocalizedString(621); //date
                    dlg.AddLocalizedString(268); //title/name

                    // set the focus to currently used sort method
                    dlg.SelectedLabel = (int)_currentSortMethod;

                    // show dialog and wait for result
                    dlg.DoModal(GetID);
                    if (dlg.SelectedId == -1)
                    {
                        return;
                    }
                    _currentSortMethod = (SortMethod)dlg.SelectedLabel;
                    OnSort();
                }
            }
            else if (control == _viewsList)
            {
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_SELECTED, GetID, 0, control.GetID, 0, 0, null);
                OnMessage(msg);
                int iItem = (int)msg.Param1;
                if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    OnSelectItem(iItem);
                }
                if (actionType == Action.ActionType.ACTION_SHOW_INFO)
                {
                    OnShowContextMenu();
                }
            }
        }
示例#26
0
        protected override void OnShowContextMenu()
        {
            int         iItem = GetSelectedItemNo();
            GUIListItem pItem = GetItem(iItem);

            if (pItem == null)
            {
                return;
            }
            if (pItem.IsFolder)
            {
                ScheduleSummary schedule = pItem.TVTag as ScheduleSummary;
                if (schedule != null)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }
                    dlg.Reset();
                    dlg.SetHeading(schedule.Name ?? string.Empty);
                    dlg.Add(Utility.GetLocalizedText(TextId.Settings));
                    if (schedule.IsActive)
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.CancelThisSchedule));
                    }
                    else
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.UnCancelThisSchedule));
                    }

                    dlg.Add(Utility.GetLocalizedText(TextId.DeleteThisSchedule));
                    dlg.DoModal(GetID);

                    Schedule _sched = SchedulerAgent.GetScheduleById(schedule.ScheduleId);
                    switch (dlg.SelectedLabel)
                    {
                    case 0:
                        if (_sched != null)
                        {
                            UpcomingProgram[] programs = SchedulerAgent.GetUpcomingPrograms(_sched, true);
                            if (programs != null && programs.Length > 0)
                            {
                                OnEditSchedule(programs[0]);
                            }
                        }
                        break;

                    case 1:
                        if (_sched != null)
                        {
                            if (_sched.IsActive)
                            {
                                _sched.IsActive = false;
                                SchedulerAgent.SaveSchedule(_sched);
                            }
                            else
                            {
                                _sched.IsActive = true;
                                SchedulerAgent.SaveSchedule(_sched);
                            }
                        }
                        break;

                    case 2:
                    {
                        GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                        if (dlgYesNo != null)
                        {
                            dlgYesNo.Reset();
                            dlgYesNo.SetHeading(schedule.Name);
                            dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.DeleteThisSchedule));
                            dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure));
                            dlgYesNo.SetLine(3, string.Empty);
                            dlgYesNo.SetDefaultToYes(false);
                            dlgYesNo.DoModal(GetID);

                            if (dlgYesNo.IsConfirmed)
                            {
                                SchedulerAgent.DeleteSchedule(schedule.ScheduleId);
                                _selectedSchedule = null;
                            }
                        }
                    }
                    break;
                    }
                    m_iSelectedItem = GetSelectedItemNo();
                    LoadUpcomingPrograms(null);
                }
            }
            else
            {
                UpcomingProgram upcoming = pItem.TVTag as UpcomingProgram;
                if (upcoming != null)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }
                    dlg.Reset();
                    dlg.SetHeading(upcoming.Title);
                    dlg.Add(Utility.GetLocalizedText(TextId.Settings));
                    dlg.Add(Utility.GetLocalizedText(TextId.Priority));
                    if (upcoming.IsCancelled)
                    {
                        if (upcoming.CancellationReason == UpcomingCancellationReason.Manual)
                        {
                            dlg.Add(Utility.GetLocalizedText(TextId.UncancelThisShow));
                        }
                    }
                    else
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.CancelThisShow));
                    }
                    dlg.DoModal(GetID);

                    switch (dlg.SelectedLabel)
                    {
                    case 0:     // settings/information
                        OnEditSchedule(upcoming);
                        break;

                    case 1:     // Priority
                        OnChangePriority(upcoming);
                        break;

                    case 2:     // (Un)Cancel
                        if (upcoming.IsCancelled)
                        {
                            this.SchedulerAgent.UncancelUpcomingProgram(upcoming.ScheduleId, upcoming.GuideProgramId, upcoming.Channel.ChannelId, upcoming.StartTime);
                        }
                        else
                        {
                            this.SchedulerAgent.CancelUpcomingProgram(upcoming.ScheduleId, upcoming.GuideProgramId, upcoming.Channel.ChannelId, upcoming.StartTime);
                        }
                        m_iSelectedItem = GetSelectedItemNo();
                        LoadUpcomingPrograms(null);
                        break;
                    }
                }
            }
        }