public void Execute()
        {
            const string   DIALOG_SWITCH_VIEW_MODE = "DialogSwitchGenericViewMode";
            IScreenManager screenManager           = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(DIALOG_SWITCH_VIEW_MODE);
        }
        public void RecordMenu()
        {
            ListItem item = SelectedItem;

            if (item == null)
            {
                return;
            }
            if (_isScheduleMode)
            {
                item.Command.Execute();
                return;
            }
            IProgram program = item.AdditionalProperties["PROGRAM"] as IProgram;

            if (program == null || _tvHandler.ScheduleControl == null)
            {
                return;
            }
            var result = _tvHandler.ScheduleControl.GetRecordingStatusAsync(program).Result;

            if (result.Success)
            {
                DialogHeader = "SlimTvClient.RecordActions";
                _dialogActionsList.Clear();
                AddRecordingOptions(_dialogActionsList, program, result.Result);
                IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();
                screenManager.ShowDialog("DialogExtSchedule");
            }
        }
        /// <summary>
        /// Presents a dialog with recording options for the currently selected program/channel.
        /// </summary>
        public async void RecordMenu()
        {
            if (SlimTvExtScheduleModel.CurrentItem == null)
            {
                return;
            }
            ChannelProgramListItem item = SlimTvExtScheduleModel.CurrentItem as ChannelProgramListItem;

            if (item == null || item.Programs == null)
            {
                return;
            }
            IProgram program = null;
            IChannel channel = null;

            lock (item.Programs.SyncRoot)
                if (item.Programs.Count == 2)
                {
                    program = item.Programs[0].AdditionalProperties["PROGRAM"] as IProgram;
                    channel = item.AdditionalProperties["CHANNEL"] as IChannel;
                }
            if (program != null && channel != null && await InitActionsList(program, channel))
            {
                IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();
                screenManager.ShowDialog("DialogClientModel");
            }
        }
        private void ShowActions(ISchedule currentSchedule, IProgram program = null)
        {
            DialogHeader = currentSchedule.Name;
            _dialogActionsList.Clear();

            if (program != null && currentSchedule.IsSeries)
            {
                // In program list, offer to delete single program of series
                _dialogActionsList.Add(new ListItem(Consts.KEY_NAME, "[SlimTvClient.DeleteSingle]")
                {
                    Command = new AsyncMethodDelegateCommand(() => CreateOrDeleteSchedule(program))
                });
            }
            // Always offer to delete schedule (prompt is same as single program if recording isn't a series)
            _dialogActionsList.Add(new ListItem(Consts.KEY_NAME, currentSchedule.IsSeries ? "[SlimTvClient.DeleteFullSchedule]" : "[SlimTvClient.DeleteSingle]")
            {
                Command = new AsyncMethodDelegateCommand(() => DeleteSchedule(currentSchedule))
            });
            if (program == null && currentSchedule.IsSeries)
            {
                // In series list - offer to delete individual programs - will go to ExtSchedule to show all the programs
                _dialogActionsList.Add(new ListItem(Consts.KEY_NAME, "[SlimTvClient.CancelProgramsOfSeriesSchedule]")
                {
                    Command = new MethodDelegateCommand(() => ShowAndEditPrograms(currentSchedule))
                });
            }
            _dialogActionsList.FireChange();

            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog("DialogScheduleManagement");
        }
Example #5
0
        protected async Task CheckEditionMenuInternal(MediaItem item)
        {
            bool hasEditions = item.Editions.Count > 1;

            if (!hasEditions)
            {
                // Asynchronously leave the current workflow state because we're called from a workflow model method
                //await Task.Yield();
                await Task.Run(async() =>
                {
                    LeaveCheckEditionsState();
                    await CheckResumeMenuInternal(item, 0);
                });

                return;
            }

            _playMenuItems = new ItemsList();
            for (var editionIndex = 0; editionIndex < item.Editions.Count; editionIndex++)
            {
                var      edition     = item.Editions[editionIndex];
                var      label       = edition.Name;
                var      index       = editionIndex;
                ListItem editionItem = new ListItem
                {
                    Command = new AsyncMethodDelegateCommand(() => { return(CheckResumeMenuInternal(item, index)); })
                };
                editionItem.SetLabel(Consts.KEY_NAME, label);
                _playMenuItems.Add(editionItem);
            }
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_PLAY_MENU, (dialogName, dialogInstanceId) => LeaveCheckEditionsState());
        }
        public void RecordSeries(IProgram program)
        {
            InitSeriesTypeList(program);
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog("DialogExtSchedule");
        }
        /// <summary>
        /// Shows the channel selection dialog.
        /// </summary>
        public void ShowChannelDialog()
        {
            InitChannelList();
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog("DialogManualSchedule");
        }
        /// <summary>
        /// Shows the recording type selection dialog.
        /// </summary>
        public void ShowRecordingTypeDialog()
        {
            InitRecordingTypeList();
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog("DialogManualSchedule");
        }
        public void CancelSchedule(IProgram program)
        {
            InitDeleteChoicesList(program);
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog("DialogExtSchedule");
        }
        protected void CheckResumeMenuInternal(MediaItem item)
        {
            IResumeState    resumeState = null;
            IUserManagement userProfileDataManagement = ServiceRegistration.Get <IUserManagement>();

            if (userProfileDataManagement.IsValidUser)
            {
                string resumeStateString;
                if (userProfileDataManagement.UserProfileDataManagement.GetUserMediaItemData(userProfileDataManagement.CurrentUser.ProfileId, item.MediaItemId, PlayerContext.KEY_RESUME_STATE, out resumeStateString))
                {
                    resumeState = ResumeStateBase.Deserialize(resumeStateString);
                }
            }

            if (resumeState == null)
            {
                // Asynchronously leave the current workflow state because we're called from a workflow model method
                IThreadPool threadPool = ServiceRegistration.Get <IThreadPool>();
                threadPool.Add(() =>
                {
                    LeaveCheckResumePlaybackSingleItemState();
                    PlayItem(item);
                });
                return;
            }
            _playMenuItems = new ItemsList();
            ListItem resumeItem = new ListItem
            {
                Command = new MethodDelegateCommand(() =>
                {
                    LeaveCheckResumePlaybackSingleItemState();
                    PlayItem(item, resumeState);
                })
            };
            PositionResumeState positionResume = resumeState as PositionResumeState;

            if (positionResume != null)
            {
                string playbackResume = LocalizationHelper.Translate(Consts.RES_PLAYBACK_RESUME_TIME, positionResume.ResumePosition.ToString(@"hh\:mm\:ss"));
                resumeItem.SetLabel(Consts.KEY_NAME, playbackResume);
            }
            else
            {
                resumeItem.SetLabel(Consts.KEY_NAME, Consts.RES_PLAYBACK_RESUME);
            }
            _playMenuItems.Add(resumeItem);
            ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAYBACK_FROMSTART)
            {
                Command = new MethodDelegateCommand(() =>
                {
                    LeaveCheckResumePlaybackSingleItemState();
                    PlayItem(item);
                })
            };

            _playMenuItems.Add(playItem);
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_PLAY_MENU, (dialogName, dialogInstanceId) => LeaveCheckResumePlaybackSingleItemState());
        }
Example #11
0
        protected Task CheckQueryPlayAction_ShowMediaTypeChoice(GetMediaItemsDlgt getMediaItemsFunction)
        {
            _mediaTypeChoiceMenuItems = new ItemsList
            {
                new ListItem(Consts.KEY_NAME, Consts.RES_ADD_ALL_AUDIO)
                {
                    Command = new MethodDelegateCommand(() => CheckQueryPlayAction_Continue(
                                                            getMediaItemsFunction, new Guid[] { AudioAspect.Metadata.AspectId }, AVType.Audio))
                },
                new ListItem(Consts.KEY_NAME, Consts.RES_ADD_ALL_VIDEOS)
                {
                    Command = new MethodDelegateCommand(() => CheckQueryPlayAction_Continue(
                                                            getMediaItemsFunction, new Guid[] { VideoAspect.Metadata.AspectId }, AVType.Video))
                },
                new ListItem(Consts.KEY_NAME, Consts.RES_ADD_ALL_IMAGES)
                {
                    Command = new MethodDelegateCommand(() => CheckQueryPlayAction_Continue(
                                                            getMediaItemsFunction, new Guid[] { ImageAspect.Metadata.AspectId }, AVType.Video))
                },
                new ListItem(Consts.KEY_NAME, Consts.RES_ADD_VIDEOS_AND_IMAGES)
                {
                    Command = new MethodDelegateCommand(() => CheckQueryPlayAction_Continue(
                                                            getMediaItemsFunction, new Guid[] { VideoAspect.Metadata.AspectId, ImageAspect.Metadata.AspectId }, AVType.Video))
                },
            };
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_CHOOSE_AV_TYPE, (dialogName, dialogInstanceId) => LeaveQueryAVTypeState());
            return(Task.CompletedTask);
        }
Example #12
0
        protected async Task AsyncAddToPlaylist(IPlayerContext pc, GetMediaItemsDlgt getMediaItemsFunction, bool play)
        {
            IScreenManager screenManager    = ServiceRegistration.Get <IScreenManager>();
            Guid?          dialogInstanceId = screenManager.ShowDialog(Consts.DIALOG_ADD_TO_PLAYLIST_PROGRESS,
                                                                       (dialogName, instanceId) => StopAddToPlaylist());

            try
            {
                int numItems = 0;
                _stopAddToPlaylist = false;
                SetNumItemsAddedToPlaylist(0);
                ICollection <MediaItem> items = new List <MediaItem>();
                foreach (MediaItem item in getMediaItemsFunction())
                {
                    SetNumItemsAddedToPlaylist(++numItems);
                    if (_stopAddToPlaylist)
                    {
                        break;
                    }
                    items.Add(item);
                }
                pc.Playlist.AddAll(items);
            }
            finally
            {
                if (dialogInstanceId.HasValue)
                {
                    screenManager.CloseDialog(dialogInstanceId.Value);
                }
                IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();
                workflowManager.NavigatePopToState(Consts.WF_STATE_ID_PLAY_OR_ENQUEUE_ITEMS, true);
            }
            // Must be done after the dialog is closed
            await CompletePlayOrEnqueue(pc, play);
        }
Example #13
0
        private void ShowActions(ISchedule currentSchedule)
        {
            DialogHeader = currentSchedule.Name;
            _dialogActionsList.Clear();

            ListItem item = new ListItem(Consts.KEY_NAME, currentSchedule.IsSeries ? "[SlimTvClient.DeleteFullSchedule]" : "[SlimTvClient.DeleteSingle]")
            {
                Command = new MethodDelegateCommand(() => DeleteSchedule(currentSchedule))
            };

            _dialogActionsList.Add(item);
            if (currentSchedule.IsSeries)
            {
                item = new ListItem(Consts.KEY_NAME, "[SlimTvClient.CancelProgramsOfSeriesSchedule]")
                {
                    Command = new MethodDelegateCommand(() => ShowAndEditPrograms(currentSchedule))
                };
                _dialogActionsList.Add(item);
            }
            _dialogActionsList.FireChange();

            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog("DialogScheduleManagement");
        }
Example #14
0
        public void EnterModelContext(NavigationContext oldContext, NavigationContext newContext)
        {
            _deferredAction    = null;
            _deferredMediaItem = null;
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_MEDIAITEM_ACTION_MENU, (dialogName, dialogInstanceId) => LeaveMediaItemActionState());
        }
Example #15
0
 /// <summary>
 /// Presents a dialog with recording options.
 /// </summary>
 public void RecordDialog()
 {
     if (InitActionsList())
     {
         IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();
         screenManager.ShowDialog("DialogClientModel");
     }
 }
        public override void ExecuteConfiguration()
        {
            string dialog = DialogScreen;

            if (dialog != null)
            {
                IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();
                screenManager.ShowDialog(dialog);
            }
        }
        public void ChoosePlaylist()
        {
            if (!UpdatePlaylists())
            {
                return;
            }
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_CHOOSE_PLAYLIST);
        }
        protected static void ShowDialog(string title, ItemsList items)
        {
            IWorkflowManager   workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            LoadSkinThemeModel model           = (LoadSkinThemeModel)workflowManager.GetModel(LST_MODEL_ID);

            model.Initialize(title, items);
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(DIALOG_LOAD_SKIN_THEME);
        }
            public IList <Guid> Execute(IList <string> mediaFiles, ShareLocation shareLocation)
            {
                NumFiles = mediaFiles.Count;
                IServerConnectionManager scm = ServiceRegistration.Get <IServerConnectionManager>();
                IContentDirectory        cd  = scm.ContentDirectory;
                string systemId = shareLocation == ShareLocation.Local ? ServiceRegistration.Get <ISystemResolver>().LocalSystemId : scm.HomeServerSystemId;

                Guid[] necessaryAudioAspectIds = null;
                Guid[] optionalAudioAspectIds  = null;

                ILogger        logger        = ServiceRegistration.Get <ILogger>();
                IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();
                Guid?          dialogId      = screenManager.ShowDialog(Consts.DIALOG_IMPORT_PLAYLIST_PROGRESS, (dialogName, dialogInstanceId) => Cancel());

                if (!dialogId.HasValue)
                {
                    logger.Warn("ImportPlaylistOperation: Error showing progress dialog");
                    return(null);
                }

                IList <Guid> result = new List <Guid>();

                NumMatched   = 0;
                NumProcessed = 0;
                NumMatched   = 0;
                UpdateScreenData();
                try
                {
                    foreach (string localMediaFile in mediaFiles)
                    {
                        if (IsCancelled)
                        {
                            return(null);
                        }
                        CheckUpdateScreenData();
                        MediaItem item = cd.LoadItem(systemId, LocalFsResourceProviderBase.ToResourcePath(localMediaFile), necessaryAudioAspectIds, optionalAudioAspectIds);
                        NumProcessed++;
                        if (item == null)
                        {
                            logger.Warn("ImportPlaylistOperation: Media item '{0}' was not found in the media library", localMediaFile);
                            continue;
                        }
                        logger.Debug("ImportPlaylistOperation: Matched media item '{0}' in media library", localMediaFile);
                        NumMatched++;
                        result.Add(item.MediaItemId);
                    }
                }
                catch (Exception e)
                {
                    logger.Warn("ImportPlaylistOperation: Error importing playlist", e);
                }
                screenManager.CloseDialog(dialogId.Value);
                return(result);
            }
        protected void ShowAttachToServerDialog()
        {
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_ATTACH_TO_SERVER, (dialogName, instanceId) =>
            {
                if (_attachInfoDialogHandle == null)
                {
                    LeaveConfiguration();
                }
            });
        }
 /// <summary>
 /// Called from the GUI when the user chooses to leave the party mode.
 /// </summary>
 public void QueryLeavePartyMode()
 {
     ServiceRegistration.Get <ILogger>().Info("PartyMusicPlayerModel: Request to leave party mode");
     if (UseEscapePassword)
     {
         IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();
         screenManager.ShowDialog(Consts.DIALOG_QUERY_ESCAPE_PASSWORD);
     }
     else
     {
         LeavePartyMode();
     }
 }
        public static void ShowDialog(string title, ItemsList list)
        {
            var wf = ServiceRegistration.Get <IWorkflowManager>();
            SlimTvExtScheduleModel model = wf.GetModel(SlimTvExtScheduleModel.MODEL_ID) as SlimTvExtScheduleModel;

            model.InitModel();
            model.DialogHeader = title;
            model._dialogActionsList.Clear();
            foreach (ListItem i in list) // ItemsList doesn't have AddRange method :-(
            {
                model._dialogActionsList.Add(i);
            }
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog("DialogExtSchedule");
        }
 void OnMessageReceived(AsynchronousMessageQueue queue, SystemMessage message)
 {
     if (message.ChannelName == WorkflowManagerMessaging.CHANNEL)
     {
         if ((WorkflowManagerMessaging.MessageType)message.MessageType == WorkflowManagerMessaging.MessageType.StatePushed)
         {
             var workflowManager = ServiceRegistration.Get <IWorkflowManager>();
             var isHomeScreen    = workflowManager.CurrentNavigationContext.WorkflowState.StateId.ToString().Equals("7F702D9C-F2DD-42da-9ED8-0BA92F07787F", StringComparison.OrdinalIgnoreCase);
             if (isHomeScreen)
             {
                 // Show Dialog
                 IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();
                 screenManager.ShowDialog("whats-new");
             }
         }
     }
 }
Example #24
0
        public Guid ShowPathBrowser(string headerText, bool enumerateFiles, bool showSystemResources, ResourcePath initialPath, ValidatePathDlgt validatePathDlgt)
        {
            ChoosenResourcePath = null;
            UpdateResourceProviderPathTree();
            HeaderText          = headerText;
            _dialogHandle       = Guid.NewGuid();
            _dialogAccepted     = false;
            _enumerateFiles     = enumerateFiles;
            _validatePathDlgt   = validatePathDlgt;
            ShowSystemResources = showSystemResources;

            IScreenManager screenManager    = ServiceRegistration.Get <IScreenManager>();
            Guid?          dialogInstanceId = screenManager.ShowDialog(Consts.DIALOG_PATH_BROWSER, OnDialogClosed);

            if (!dialogInstanceId.HasValue)
            {
                throw new InvalidDataException("File browser could not be shown");
            }
            _dialogInstanceId = dialogInstanceId.Value;
            return(_dialogHandle);
        }
 public void FinishShareConfiguration()
 {
     try
     {
         if (_shareProxy.EditMode == SharesProxy.ShareEditMode.AddShare)
         {
             _shareProxy.AddShare();
             NavigateBackToOverview();
         }
         else if (_shareProxy.EditMode == SharesProxy.ShareEditMode.EditShare)
         {
             if (_shareProxy.IsResourcePathChanged)
             {
                 IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();
                 screenManager.ShowDialog(Consts.SCREEN_SHARES_CONFIG_RELOCATE_DIALOG);
             }
             else if (_shareProxy.IsCategoriesChanged)
             {
                 UpdateShareAndFinish(RelocationMode.ClearAndReImport);
             }
             else
             {
                 UpdateShareAndFinish(RelocationMode.None);
             }
         }
         else
         {
             throw new NotImplementedException(string.Format("ShareEditMode '{0}' is not implemented", _shareProxy.EditMode));
         }
     }
     catch (NotConnectedException)
     {
         DisconnectedError();
     }
     catch (Exception e)
     {
         ErrorEditShare(e);
     }
 }
Example #26
0
        public Guid ShowDialog(string headerText, string text, DialogType type,
                               bool showCancelButton, DialogButtonType?focusedButton)
        {
            Guid      dialogHandle = Guid.NewGuid();
            ItemsList buttons      = new ItemsList();

            switch (type)
            {
            case DialogType.OkDialog:
                buttons.Add(CreateButtonListItem(OK_BUTTON_TEXT, dialogHandle, DialogResult.Ok, focusedButton == DialogButtonType.Ok || !showCancelButton));
                break;

            case DialogType.YesNoDialog:
                buttons.Add(CreateButtonListItem(YES_BUTTON_TEXT, dialogHandle, DialogResult.Yes, focusedButton == DialogButtonType.Yes));
                buttons.Add(CreateButtonListItem(NO_BUTTON_TEXT, dialogHandle, DialogResult.No, focusedButton == DialogButtonType.No));
                break;

            default:
                throw new NotImplementedException(string.Format("DialogManager: DialogType {0} is not implemented yet", type));
            }
            if (showCancelButton)
            {
                buttons.Add(CreateButtonListItem(CANCEL_BUTTON_TEXT, dialogHandle, DialogResult.Cancel, focusedButton == DialogButtonType.Cancel));
            }

            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            _dialogData = new GenericDialogData(headerText, text, buttons, dialogHandle);
            Guid?dialogInstanceId = screenManager.ShowDialog(GENERIC_DIALOG_SCREEN, OnDialogClosed);

            if (!dialogInstanceId.HasValue)
            {
                throw new InvalidDataException("Generic dialog could not be shown");
            }
            _dialogData.DialogInstanceId = dialogInstanceId.Value;
            return(dialogHandle);
        }
Example #27
0
        public void Execute()
        {
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_SWITCH_SORTING);
        }
Example #28
0
        protected virtual void ShowProgramActions(IProgram program)
        {
            if (program == null)
            {
                return;
            }

            ILocalization loc = ServiceRegistration.Get <ILocalization>();

            _programActions = new ItemsList();
            // if program is over already, there is nothing to do.
            if (program.EndTime < DateTime.Now)
            {
                _programActions.Add(new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.ProgramOver]")));
            }
            else
            {
                // Check if program is currently running.
                bool isRunning = DateTime.Now >= program.StartTime && DateTime.Now <= program.EndTime;
                if (isRunning)
                {
                    _programActions.Add(new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.WatchNow]"))
                    {
                        Command = new AsyncMethodDelegateCommand(() => TuneChannelByProgram(program))
                    });
                }

                if (_tvHandler.ScheduleControl != null)
                {
                    var result = _tvHandler.ScheduleControl.GetRecordingStatusAsync(program).Result;
                    if (result.Success && result.Result != RecordingStatus.None)
                    {
                        if (isRunning)
                        {
                            _programActions.Add(
                                new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.WatchFromBeginning]"))
                            {
                                Command = new AsyncMethodDelegateCommand(() => _tvHandler.WatchRecordingFromBeginningAsync(program))
                            });
                        }

                        _programActions.Add(
                            new ListItem(Consts.KEY_NAME, loc.ToString(isRunning ? "[SlimTvClient.StopCurrentRecording]" : "[SlimTvClient.DeleteSchedule]", program.Title))
                        {
                            Command = new AsyncMethodDelegateCommand(async() =>
                            {
                                if (await _tvHandler.ScheduleControl.RemoveScheduleForProgramAsync(program, ScheduleRecordingType.Once))
                                {
                                    UpdateRecordingStatus(program, RecordingStatus.None);
                                }
                            }
                                                                     )
                        });
                    }
                    else
                    {
                        _programActions.Add(
                            new ListItem(Consts.KEY_NAME, loc.ToString(isRunning ? "[SlimTvClient.RecordNow]" : "[SlimTvClient.CreateSchedule]"))
                        {
                            Command = new AsyncMethodDelegateCommand(async() =>
                            {
                                AsyncResult <ISchedule> recResult;
                                // "No Program" placeholder
                                if (program.ProgramId == -1)
                                {
                                    recResult = await _tvHandler.ScheduleControl.CreateScheduleByTimeAsync(new Channel {
                                        ChannelId = program.ChannelId
                                    }, program.StartTime, program.EndTime, ScheduleRecordingType.Once);
                                }
                                else
                                {
                                    recResult = await _tvHandler.ScheduleControl.CreateScheduleAsync(program, ScheduleRecordingType.Once);
                                }

                                if (recResult.Success)
                                {
                                    UpdateRecordingStatus(program, RecordingStatus.Scheduled);
                                }
                            }
                                                                     )
                        });
                    }
                }
            }

            // Add list entries for extensions
            foreach (KeyValuePair <Guid, TvExtension> programExtension in _programExtensions)
            {
                TvExtension extension = programExtension.Value;
                // First check if this extension applies for the selected program
                if (!extension.Extension.IsAvailable(program))
                {
                    continue;
                }

                _programActions.Add(
                    new ListItem(Consts.KEY_NAME, loc.ToString(extension.Caption))
                {
                    Command = new MethodDelegateCommand(() => extension.Extension.ProgramAction(program))
                });
            }

            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(_programActionsDialogName);
        }
Example #29
0
        protected async Task CheckResumeMenuInternal(MediaItem item, int edition)
        {
            // First make sure the correct edition is selected
            if (edition <= item.MaximumEditionIndex)
            {
                item.ActiveEditionIndex = edition;
            }

            IResumeState    resumeState = null;
            IUserManagement userProfileDataManagement = ServiceRegistration.Get <IUserManagement>();

            if (userProfileDataManagement.IsValidUser)
            {
                var userResult = await userProfileDataManagement.UserProfileDataManagement.GetUserMediaItemDataAsync(userProfileDataManagement.CurrentUser.ProfileId, item.MediaItemId, PlayerContext.KEY_RESUME_STATE);

                if (userResult.Success)
                {
                    resumeState = ResumeStateBase.Deserialize(userResult.Result);
                }
            }

            // Check if resume state matches the current edition, if not start from beginning
            IResumeStateEdition rse = resumeState as IResumeStateEdition;

            if (rse != null && rse.ActiveEditionIndex != edition)
            {
                resumeState = null;
            }

            if (resumeState == null)
            {
                // Asynchronously leave the current workflow state because we're called from a workflow model method
                //await Task.Yield();
                await Task.Run(async() =>
                {
                    LeaveCheckResumePlaybackSingleItemState();
                    await PlayItem(item);
                });

                return;
            }
            _playMenuItems = new ItemsList();
            ListItem resumeItem = new ListItem
            {
                Command = new AsyncMethodDelegateCommand(() =>
                {
                    LeaveCheckResumePlaybackSingleItemState();
                    return(PlayItem(item, resumeState));
                })
            };
            PositionResumeState positionResume = resumeState as PositionResumeState;

            if (positionResume != null)
            {
                string playbackResume = LocalizationHelper.Translate(Consts.RES_PLAYBACK_RESUME_TIME, positionResume.ResumePosition.ToString(@"hh\:mm\:ss"));
                resumeItem.SetLabel(Consts.KEY_NAME, playbackResume);
            }
            else
            {
                resumeItem.SetLabel(Consts.KEY_NAME, Consts.RES_PLAYBACK_RESUME);
            }
            _playMenuItems.Add(resumeItem);
            ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAYBACK_FROMSTART)
            {
                Command = new AsyncMethodDelegateCommand(() =>
                {
                    LeaveCheckResumePlaybackSingleItemState();
                    return(PlayItem(item));
                })
            };

            _playMenuItems.Add(playItem);
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_PLAY_MENU, (dialogName, dialogInstanceId) => LeaveCheckResumePlaybackSingleItemState());
        }
Example #30
0
        protected void CheckPlayMenuInternal(MediaItem item)
        {
            IPlayerContextManager pcm = ServiceRegistration.Get <IPlayerContextManager>();
            int numOpen = pcm.NumActivePlayerContexts;

            if (numOpen == 0)
            {
                // Asynchronously leave the current workflow state because we're called from a workflow model method
                IThreadPool threadPool = ServiceRegistration.Get <IThreadPool>();
                threadPool.Add(() =>
                {
                    LeaveCheckQueryPlayActionSingleItemState();
                    CheckEdition(item);
                    //CheckResumeAction(item);
                });
                return;
            }
            _playMenuItems = new ItemsList();
            AVType avType   = pcm.GetTypeOfMediaItem(item);
            int    numAudio = pcm.GetPlayerContextsByAVType(AVType.Audio).Count();
            int    numVideo = pcm.GetPlayerContextsByAVType(AVType.Video).Count();

            switch (avType)
            {
            case AVType.Audio:
            {
                ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_AUDIO_ITEM)
                {
                    Command = new MethodDelegateCommand(() =>
                        {
                            LeaveCheckQueryPlayActionSingleItemState();
                            CheckEdition(item);
                            //CheckResumeAction(item);
                        })
                };
                _playMenuItems.Add(playItem);
                if (numAudio > 0)
                {
                    ListItem enqueueItem = new ListItem(Consts.KEY_NAME, Consts.RES_ENQUEUE_AUDIO_ITEM)
                    {
                        Command = new AsyncMethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionSingleItemState();
                                return(PlayOrEnqueueItem(item, false, PlayerContextConcurrencyMode.None));
                            })
                    };
                    _playMenuItems.Add(enqueueItem);
                }
                if (numVideo > 0)
                {
                    ListItem playItemConcurrently = new ListItem(Consts.KEY_NAME, Consts.RES_MUTE_VIDEO_PLAY_AUDIO_ITEM)
                    {
                        Command = new AsyncMethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionSingleItemState();
                                return(PlayOrEnqueueItem(item, true, PlayerContextConcurrencyMode.ConcurrentVideo));
                            })
                    };
                    _playMenuItems.Add(playItemConcurrently);
                }
            }
            break;

            case AVType.Video:
            {
                ListItem playItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEM)
                {
                    Command = new MethodDelegateCommand(() =>
                        {
                            LeaveCheckQueryPlayActionSingleItemState();
                            CheckEdition(item);
                            //CheckResumeAction(item);
                        })
                };
                _playMenuItems.Add(playItem);
                if (numVideo > 0)
                {
                    ListItem enqueueItem = new ListItem(Consts.KEY_NAME, Consts.RES_ENQUEUE_VIDEO_IMAGE_ITEM)
                    {
                        Command = new AsyncMethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionSingleItemState();
                                return(PlayOrEnqueueItem(item, false, PlayerContextConcurrencyMode.None));
                            })
                    };
                    _playMenuItems.Add(enqueueItem);
                }
                if (numAudio > 0)
                {
                    ListItem playItem_A = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEM_MUTED_CONCURRENT_AUDIO)
                    {
                        Command = new AsyncMethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionSingleItemState();
                                return(PlayOrEnqueueItem(item, true, PlayerContextConcurrencyMode.ConcurrentAudio));
                            })
                    };
                    _playMenuItems.Add(playItem_A);
                }
                if (numVideo > 0)
                {
                    ListItem playItem_V = new ListItem(Consts.KEY_NAME, Consts.RES_PLAY_VIDEO_IMAGE_ITEM_PIP)
                    {
                        Command = new AsyncMethodDelegateCommand(() =>
                            {
                                LeaveCheckQueryPlayActionSingleItemState();
                                return(PlayOrEnqueueItem(item, true, PlayerContextConcurrencyMode.ConcurrentVideo));
                            })
                    };
                    _playMenuItems.Add(playItem_V);
                }
            }
            break;

            default:
            {
                IDialogManager dialogManager  = ServiceRegistration.Get <IDialogManager>();
                Guid           dialogHandleId = dialogManager.ShowDialog(Consts.RES_SYSTEM_INFORMATION, Consts.RES_CANNOT_PLAY_ITEM_DIALOG_TEXT,
                                                                         DialogType.OkDialog, false, DialogButtonType.Ok);
                _dialogCloseWatcher = new DialogCloseWatcher(this, dialogHandleId, dialogResult => LeaveCheckQueryPlayActionSingleItemState());
            }
            break;
            }
            IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();

            screenManager.ShowDialog(Consts.DIALOG_PLAY_MENU, (dialogName, dialogInstanceId) => LeaveCheckQueryPlayActionSingleItemState());
        }