public void SetMatch(ListItem item) { if (item == null) { return; } IDialogManager dialogManager = ServiceRegistration.Get <IDialogManager>(); string header = LocalizationHelper.Translate("[Media.ConfirmAction]"); string text = LocalizationHelper.Translate("[Media.ReimportMediaItem.Confirmation]"); Guid handle = dialogManager.ShowDialog(header, text, DialogType.YesNoDialog, false, DialogButtonType.No); _dialogCloseWatcher = new DialogCloseWatcher(this, handle, dialogResult => { if (dialogResult == DialogResult.Yes) { _matchedAspects = (IDictionary <Guid, IList <MediaItemAspect> >)item.AdditionalProperties[KEY_ASPECTS]; ServiceRegistration.Get <ILogger>().Info("Re-import: Setting matched aspects"); } if (_matchDialogHandle.HasValue) { ServiceRegistration.Get <IScreenManager>().CloseDialog(_matchDialogHandle.Value); } _dialogCloseWatcher?.Dispose(); ClearData(); }); }
public void RemoveAllSites() { if (SitesList.Count > 0) { var dialogHandleId = ServiceRegistration.Get <IDialogManager>().ShowDialog(LocalizationHelper.Translate("[OnlineVideos.RemoveAllFromMySites]") + "?", "", DialogType.YesNoDialog, false, DialogButtonType.No); _dialogCloseWatcher = new DialogCloseWatcher(this, dialogHandleId, (dialogResult) => { if (dialogResult == DialogResult.Yes) { bool needRefresh = false; foreach (var siteToRemove in SitesList) { SiteSettings localSite = null; var localSiteIndex = OnlineVideoSettings.Instance.GetSiteByName(((OnlineSiteViewModel)siteToRemove).Site.Name, out localSite); if (localSiteIndex >= 0) { OnlineVideoSettings.Instance.RemoveSiteAt(localSiteIndex); needRefresh = true; } } if (needRefresh) { OnlineVideoSettings.Instance.SaveSites(); newDataSaved = true; GetFilteredAndSortedSites(); } } }); } }
public void SetMatch(ListItem item) { if (item == null) { return; } var langs = _searchAspects[TempSubtitleAspect.ASPECT_ID].First().GetAttributeValue <string>(TempSubtitleAspect.ATTR_LANGUAGE); List <string> searchLangs = new List <string>(); if (langs?.Count() > 0) { searchLangs.AddRange(langs.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(l => new CultureInfo(l).TwoLetterISOLanguageName)); } bool externalSubsPresent = false; foreach (var sub in _searchAspects.Where(a => a.Key == SubtitleAspect.ASPECT_ID).SelectMany(a => a.Value)) { var subLang = sub.GetAttributeValue <string>(SubtitleAspect.ATTR_SUBTITLE_LANGUAGE); if (!sub.GetAttributeValue <bool>(SubtitleAspect.ATTR_INTERNAL) && (searchLangs.Count == 0 || string.IsNullOrEmpty(subLang) || searchLangs.Contains(subLang))) { externalSubsPresent = true; break; } } //If external sub is present a match might ovewrite it so ask for confirmation if (externalSubsPresent) { IDialogManager dialogManager = ServiceRegistration.Get <IDialogManager>(); string header = LocalizationHelper.Translate("[Media.ConfirmAction]"); string text = LocalizationHelper.Translate("[Media.SubtitleReplace.Confirmation]"); Guid handle = dialogManager.ShowDialog(header, text, DialogType.YesNoDialog, false, DialogButtonType.No); _dialogCloseWatcher = new DialogCloseWatcher(this, handle, dialogResult => { if (dialogResult == DialogResult.Yes) { SetMatchedAspects(item); } if (_matchDialogHandle.HasValue) { ServiceRegistration.Get <IScreenManager>().CloseDialog(_matchDialogHandle.Value); } _dialogCloseWatcher?.Dispose(); ClearData(); }); } else { SetMatchedAspects(item); if (_matchDialogHandle.HasValue) { ServiceRegistration.Get <IScreenManager>().CloseDialog(_matchDialogHandle.Value); } ClearData(); } }
protected void ReleaseModelData() { _mediaTypeChoiceMenuItems = null; _playMenuItems = null; if (_dialogCloseWatcher != null) { _dialogCloseWatcher.Dispose(); _dialogCloseWatcher = null; } }
void HandleCustomContextMenuEntry(Sites.ContextMenuEntry entry) { ServiceRegistration.Get <IScreenManager>().CloseTopmostDialog(); switch (entry.Action) { case Sites.ContextMenuEntry.UIAction.Execute: ExecuteCustomContextMenuEntry(entry); break; case Sites.ContextMenuEntry.UIAction.GetText: //todo: show input dialog and execute when confirmed //entry.UserInputText = text; //ExecuteCustomContextMenuEntry(entry); break; case Sites.ContextMenuEntry.UIAction.PromptYesNo: var dialogHandleId = ServiceRegistration.Get <IDialogManager>().ShowDialog(entry.DisplayText, entry.PromptText, DialogType.YesNoDialog, false, DialogButtonType.No); var dialogCloseWatcher = new DialogCloseWatcher(this, dialogHandleId, (dialogResult) => { if (dialogResult == DialogResult.Yes) { ExecuteCustomContextMenuEntry(entry); } }); break; case Sites.ContextMenuEntry.UIAction.ShowList: var menuItems = new ItemsList(); foreach (var item in entry.SubEntries) { var listItem = new ListItem(Consts.KEY_NAME, item.DisplayText); listItem.AdditionalProperties.Add(Consts.KEY_MEDIA_ITEM, item); menuItems.Add(listItem); } ServiceRegistration.Get <IWorkflowManager>().NavigatePushTransient( WorkflowState.CreateTransientState("CustomContextItems", entry.DisplayText, true, "ovsDialogGenericItems", false, WorkflowType.Dialog), new NavigationContextConfig() { AdditionalContextVariables = new Dictionary <string, object> { { Constants.CONTEXT_VAR_ITEMS, menuItems }, { Constants.CONTEXT_VAR_COMMAND, new CommandContainer <ListItem>((li) => HandleCustomContextMenuEntry(li.AdditionalProperties[Consts.KEY_MEDIA_ITEM] as Sites.ContextMenuEntry)) } } }); break; } }
protected void ShowConfirmation(IMediaItemActionConfirmation confirmation, MediaItem mediaItem) { IDialogManager dialogManager = ServiceRegistration.Get <IDialogManager>(); string header = LocalizationHelper.Translate(Consts.RES_CONFIRM_HEADER); string text = LocalizationHelper.Translate(confirmation.ConfirmationMessage); Guid handle = dialogManager.ShowDialog(header, text, DialogType.YesNoDialog, false, DialogButtonType.No); _dialogCloseWatcher = new DialogCloseWatcher(this, handle, dialogResult => { if (dialogResult == DialogResult.Yes) { InvokeAction(confirmation, mediaItem); } _dialogCloseWatcher?.Dispose(); }); }
public void DeleteKeyMapping() { if (SelectedItem != null) { var selectedItem = SelectedItem; var dialogManager = ServiceRegistration.Get <IDialogManager>(); Guid handle = dialogManager.ShowDialog(selectedItem.Label(Consts.KEY_NAME, selectedItem.ToString()).ToString(), LocalizationHelper.Translate(RES_REMOVE_MAPPING_TEXT), DialogType.YesNoDialog, false, DialogButtonType.No); _dialogCloseWatcher = new DialogCloseWatcher(this, handle, dialogResult => { if (dialogResult == DialogResult.Yes && selectedItem != null) { InputDevice device; if (InputDeviceManager.InputDevices.TryGetValue(_currentInputDevice, out device)) { MappedKeyCode mappedKeyCode = device.KeyMap.FirstOrDefault(k => k.Key == (string)selectedItem.AdditionalProperties[KEY_KEYMAP_DATA]); if (mappedKeyCode != null) { device.KeyMap.Remove(mappedKeyCode); ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); var settings = settingsManager.Load <InputManagerSettings>(); var inputDevice = settings?.InputDevices.FirstOrDefault(d => d.DeviceID == _currentInputDevice); if (inputDevice != null) { inputDevice.KeyMap = device.KeyMap; settingsManager.Save(settings); // update settings in the main plugin InputDeviceManager.Instance.UpdateLoadedSettings(settings); // this brings us back to the add key menu UpdateKeymapping(); } } } } _dialogCloseWatcher?.Dispose(); }); } }
public void QueryDeleteAll(List <MediaItem> mediaItems) { if (mediaItems.Count == 0) { ServiceRegistration.Get <ILogger>().Error("DeleteAllRecordings: No items to delete"); return; } IDialogManager dialogManager = ServiceRegistration.Get <IDialogManager>(); string header = LocalizationHelper.Translate(Consts.RES_CONFIRM_HEADER); string text = LocalizationHelper.Translate("[SlimTvClient.DeleteAllRecordings.Confirmation]", mediaItems.Count); Guid handle = dialogManager.ShowDialog(header, text, DialogType.YesNoDialog, false, DialogButtonType.No); DialogCloseWatcher dialogCloseWatcher = null; dialogCloseWatcher = new DialogCloseWatcher(this, handle, async dialogResult => { dialogCloseWatcher?.Dispose(); if (dialogResult == DialogResult.Yes) { await DeleteList(mediaItems); } }); }
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()); }