/// <summary> /// this will turn the _users list into the _usersExposed list /// </summary> private async Task RefreshUserList() { // clear the exposed users list _loginUserList.Clear(); _autoLoginUserList.Clear(); IUserManagement userManagement = ServiceRegistration.Get <IUserManagement>(); if (userManagement.UserProfileDataManagement == null) { return; } // Get our local client profile, it will be available for local login var localSystemGuid = Guid.Parse(ServiceRegistration.Get <ISettingsManager>().Load <SystemResolverSettings>().SystemId); UserProxy proxy; proxy = new UserProxy(); proxy.SetLabel(Consts.KEY_NAME, LocalizationHelper.Translate(Consts.RES_DISABLE)); proxy.SetUserProfile(new UserProfile(Guid.Empty, LocalizationHelper.Translate(Consts.RES_DISABLE))); proxy.Selected = UserSettingStorage.AutoLoginUser == Guid.Empty; proxy.SelectedProperty.Attach(OnAutoLoginUserSelectionChanged); _autoLoginUserList.Add(proxy); // add users to expose them var users = await userManagement.UserProfileDataManagement.GetProfilesAsync(); foreach (UserProfile user in users) { var isCurrentClient = user.ProfileId == localSystemGuid; if (user.ProfileType != UserProfileType.ClientProfile || isCurrentClient) { proxy = new UserProxy(); proxy.SetLabel(Consts.KEY_NAME, user.Name); proxy.SetUserProfile(user); if (UserSettingStorage.AutoLoginUser == user.ProfileId) { proxy.Selected = true; } proxy.SelectedProperty.Attach(OnAutoLoginUserSelectionChanged); _autoLoginUserList.Add(proxy); if (!isCurrentClient) { _loginUserList.Add(proxy); } } } // tell the skin that something might have changed _loginUserList.FireChange(); _autoLoginUserList.FireChange(); }
public void ReadCinemas() { Cinemas.Clear(); AddSelectedCinemasToAllCinemas(); foreach (var c in GoogleMovies.GoogleMovies.GetCinemas(Location).Where(IsCinemaNew)) { _allCinemas.Add(c); } AddAllCinemas(); Cinemas.FireChange(); }
private void FillProgramsList() { _programsList.Clear(); bool isSingle = false; bool isSeries = false; foreach (IProgram program in _programs) { IChannel channel; if (!_tvHandler.ChannelAndGroupInfo.GetChannel(program.ChannelId, out channel)) { channel = null; } // Use local variable, otherwise delegate argument is not fixed ProgramProperties programProperties = new ProgramProperties(); IProgram currentProgram = program; programProperties.SetProgram(currentProgram, channel); if (ProgramComparer.Instance.Equals(_selectedProgram, program)) { isSingle = programProperties.IsScheduled; isSeries = programProperties.IsSeriesScheduled; } ProgramListItem item = new ProgramListItem(programProperties) { Command = new MethodDelegateCommand(() => CreateOrDeleteSchedule(currentProgram)) }; item.AdditionalProperties["PROGRAM"] = currentProgram; item.Selected = _lastProgramId == program.ProgramId; // Restore focus if (channel != null) { item.SetLabel("ChannelName", channel.Name); item.SetLabel("ChannelLogoType", channel.GetFanArtMediaType()); } _programsList.Add(item); } // "Record" buttons are related to properties, for schedules we need to keep them to "Cancel record" state. if (_isScheduleMode) { isSingle = isSeries = _selectedSchedule != null; } IsSingleRecordingScheduled = isSingle; IsSeriesRecordingScheduled = isSeries; _programsList.FireChange(); }
protected void UpdateAudioStreamsMenu() { // Some updates could be avoided if we tracked a "dirty" flag and break execution if !dirty lock (_syncObj) { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); int numActivePlayers = playerContextManager.NumActivePlayerContexts; int numberOfAudioStreams = GetTotalNumberOfAudioStreams(); _audioStreamsMenu.Clear(); for (int i = 0; i < numActivePlayers; i++) { IPlayerContext pc = playerContextManager.GetPlayerContext(i); if (pc == null || !pc.IsActive) { continue; } IPlayer player = pc.CurrentPlayer; AudioStreamDescriptor currentAudioStream; IList <AudioStreamDescriptor> asds = new List <AudioStreamDescriptor>(pc.GetAudioStreamDescriptors(out currentAudioStream)); foreach (AudioStreamDescriptor asd in asds) { string playedItem = player == null ? null : player.MediaItemTitle ?? pc.Name; string choiceItemName; int count = asds.Count; if (numActivePlayers > 1 && count > 1 && count != numberOfAudioStreams) { // Only display the playedItem name if more than one player is able to provide audio streams. If a single player provides // multiple streams, they will be distinguished by the VideoPlayer. choiceItemName = playedItem + ": " + asd.AudioStreamName; } else { choiceItemName = count != numberOfAudioStreams ? playedItem : asd.AudioStreamName; } AudioStreamDescriptor asdClosureCopy = asd; ListItem item = new ListItem(Consts.KEY_NAME, choiceItemName) { Command = new MethodDelegateCommand(() => ChooseAudioStream(asdClosureCopy)), Selected = asd == currentAudioStream, }; item.AdditionalProperties[Consts.KEY_NAVIGATION_MODE] = NavigationMode.ExitPCWorkflow; _audioStreamsMenu.Add(item); } } _audioStreamsMenu.FireChange(); } }
protected void Reset() { EndMapping(); ResetMapper(); CurrentPlayerHeader = null; CurrentDeviceName = null; _currentDevice = null; _currentPortMapping = null; _portsList.Clear(); _portsList.FireChange(); _deviceList.Clear(); _deviceList.FireChange(); _inputList.Clear(); _inputList.FireChange(); }
protected void BuildCategoriesTree(ItemsList contents, TreeItem parentItem, ICollection <string> categories, ICollection <string> allSelectedCategories, IDictionary <string, ICollection <string> > categories2Children, IDictionary <string, MediaCategory> allCategories) { contents.Clear(); List <string> categoriesSorted = new List <string>(categories); categoriesSorted.Sort(); foreach (string mediaCategory in categoriesSorted) { TreeItem categoryItem = new TreeItem(Consts.KEY_NAME, mediaCategory); categoryItem.AdditionalProperties[Consts.KEY_MEDIA_CATEGORY] = allCategories[mediaCategory]; categoryItem.AdditionalProperties[Consts.KEY_PARENT_ITEM] = parentItem; if (allSelectedCategories.Contains(mediaCategory)) { categoryItem.Selected = true; } PropertyChangedHandler handler = (property, oldValue) => OnMediaCategoryItemSelectionChanged(categoryItem); categoryItem.SelectedProperty.Attach(handler); categoryItem.AdditionalProperties["HandlerStrongReference"] = handler; // SelectedProperty only manages weak references to its handlers -> avoid handler to be removed ICollection <string> childCategories; if (!categories2Children.TryGetValue(mediaCategory, out childCategories)) { childCategories = new List <string>(); } BuildCategoriesTree(categoryItem.SubItems, categoryItem, childCategories, allSelectedCategories, categories2Children, allCategories); contents.Add(categoryItem); } }
protected void RefreshResourceProviderPathList(ItemsList items, ResourcePath path) { items.Clear(); IEnumerable <ResourcePathMetadata> res = GetChildDirectoriesData(path); if (res != null) { List <ResourcePathMetadata> directories = new List <ResourcePathMetadata>(res); directories.Sort((a, b) => a.ResourceName.CompareTo(b.ResourceName)); foreach (ResourcePathMetadata childDirectory in directories) { TreeItem directoryItem = new TreeItem(Consts.KEY_NAME, childDirectory.ResourceName); directoryItem.AdditionalProperties[Consts.KEY_RESOURCE_PATH] = childDirectory.ResourcePath; directoryItem.SetLabel(Consts.KEY_PATH, childDirectory.HumanReadablePath); if (ChoosenResourcePath == childDirectory.ResourcePath) { directoryItem.Selected = true; } directoryItem.SelectedProperty.Attach(OnTreePathSelectionChanged); directoryItem.AdditionalProperties[Consts.KEY_EXPANSION] = new ExpansionHelper(directoryItem, this); items.Add(directoryItem); } } items.FireChange(); }
public void UpdateResourceProvidersList() { _allBaseResourceProvidersList.Clear(); bool selected = false; List <ResourceProviderMetadata> resourceProviderMDs = new List <ResourceProviderMetadata>( GetAvailableBaseResourceProviders().Where(metadata => !metadata.TransientMedia && (metadata.ProviderSystemAffinity & SystemAffinity) != ResourceProviderMetadata.SystemAffinity.Undefined)); resourceProviderMDs.Sort((a, b) => a.Name.CompareTo(b.Name)); ResourceProviderMetadata choosenBaseResourceProvider = BaseResourceProvider; foreach (ResourceProviderMetadata metadata in resourceProviderMDs) { ListItem resourceProviderItem = new ListItem(Consts.KEY_NAME, metadata.Name); resourceProviderItem.AdditionalProperties[Consts.KEY_RESOURCE_PROVIDER_METADATA] = metadata; if ((choosenBaseResourceProvider != null && choosenBaseResourceProvider.ResourceProviderId == metadata.ResourceProviderId) || resourceProviderMDs.Count == 1 && !MultipleSources) /* pre-select single option only, if there are not multiple share proxies used */ { resourceProviderItem.Selected = true; selected = true; } resourceProviderItem.SelectedProperty.Attach(OnResourceProviderItemSelectionChanged); _allBaseResourceProvidersList.Add(resourceProviderItem); } IsResourceProviderSelected = selected; }
protected void UpdatePlaylists(ItemsList list, List <PlaylistBase> playlistsData, bool selectFirstItem) { list.Clear(); bool selectPlaylist = selectFirstItem; playlistsData.Sort((a, b) => a.Name.CompareTo(b.Name)); foreach (PlaylistBase playlistData in playlistsData) { AVType?avType = ConvertPlaylistTypeToAVType(playlistData.PlaylistType); if (!avType.HasValue) { continue; } ListItem playlistItem = new ListItem(Consts.KEY_NAME, playlistData.Name); playlistItem.AdditionalProperties[Consts.KEY_PLAYLIST_AV_TYPE] = avType.Value; playlistItem.AdditionalProperties[Consts.KEY_PLAYLIST_NUM_ITEMS] = playlistData.NumItems; playlistItem.AdditionalProperties[Consts.KEY_PLAYLIST_DATA] = playlistData; PlaylistBase plCopy = playlistData; playlistItem.Command = new MethodDelegateCommand(() => ShowPlaylistInfo(plCopy)); if (selectPlaylist) { selectPlaylist = false; playlistItem.Selected = true; } playlistItem.SelectedProperty.Attach(OnPlaylistItemSelectionChanged); lock (_syncObj) list.Add(playlistItem); } list.FireChange(); }
public void Filter(ItemsList filterList, ItemsList originalList, string search) { // Handle external filter if (string.IsNullOrEmpty(search)) return; // Handle given search as single key KeyPress(search[0]); // List will not be replaced, as the instance is already bound by screen, we only filter items. filterList.Clear(); foreach (NavigationItem item in originalList.OfType<NavigationItem>()) { var simpleTitle = item.SimpleTitle; // Filter if (_listFilterAction == FilterAction.StartsWith) { if (simpleTitle.ToLower().StartsWith(_listFilterString)) filterList.Add(item); } else { if (NumPadEncode(simpleTitle).Contains(_listFilterString)) filterList.Add(item); } } filterList.FireChange(); }
protected void UpdatePlaylist() { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext pc = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer); IPlaylist playlist = pc == null ? null : pc.Playlist; UpdatePlaylistHeader(pc == null ? null : (AVType?)pc.AVType, pc == null ? true : pc.IsPrimaryPlayerContext); lock (_syncObj) { // TODO: If playlist objects differ, leave state EditPlaylist? _playlist = playlist; _items.Clear(); if (playlist != null) { IList <MediaItem> items = playlist.ItemList; for (int i = 0; i < items.Count; i++) { MediaItem mediaItem = items[i]; PlayableMediaItem item = PlayableMediaItem.CreateItem(mediaItem); item.SetLabel(Consts.KEY_NUMBERSTR, (i + 1) + "."); item.AdditionalProperties[Consts.KEY_INDEX] = i; item.AdditionalProperties[Consts.KEY_IS_DOWN_BUTTON_FOCUSED] = i == _focusedDownButton; item.AdditionalProperties[Consts.KEY_IS_UP_BUTTON_FOCUSED] = i == _focusedUpButton; _items.Add(item); } } _focusedDownButton = -1; _focusedUpButton = -1; IsPlaylistEmpty = _items.Count == 0; NumPlaylistItemsStr = Utils.BuildNumItemsStr(_items.Count, null); } _items.FireChange(); }
protected void CreatePositionedItems() { _positionedItems.Clear(); int x = 0; foreach (var menuItem in MenuItems) { object action; if (!menuItem.AdditionalProperties.TryGetValue(Consts.KEY_ITEM_ACTION, out action)) { continue; } WorkflowAction wfAction = action as WorkflowAction; if (wfAction == null) { continue; } // intercept the menu item commands, so we can set the item as LastSelectedItem // since the menu items are recreated when an sub screen is opened we have to check if the item is already intercepted each time if (!(menuItem.Command is MenuItemCommandInterceptor)) { menuItem.Command = new MenuItemCommandInterceptor(this, menuItem); } // Under "others" all items are places, that do not fit into any other category if (CurrentKey == MenuSettings.MENU_NAME_OTHERS) { bool found = _menuSettings.Settings.MenuItems.Keys.Any(key => _menuSettings.Settings.MenuItems[key].ContainsKey(wfAction.ActionId)); if (!found) { GridListItem gridItem = new GridListItem(menuItem) { GridColumn = x % MenuSettings.DEFAULT_NUM_COLS, GridRow = (x / MenuSettings.DEFAULT_NUM_COLS) * MenuSettings.DEFAULT_ROWSPAN_SMALL, GridRowSpan = MenuSettings.DEFAULT_ROWSPAN_SMALL, GridColumnSpan = MenuSettings.DEFAULT_COLSPAN_SMALL, }; _positionedItems.Add(gridItem); x += MenuSettings.DEFAULT_COLSPAN_SMALL; } } else { GridPosition gridPosition; if (Positions.TryGetValue(wfAction.ActionId, out gridPosition)) { GridListItem gridItem = new GridListItem(menuItem) { GridRow = gridPosition.Row, GridColumn = gridPosition.Column, GridRowSpan = gridPosition.RowSpan, GridColumnSpan = gridPosition.ColumnSpan, }; _positionedItems.Add(gridItem); } } } _positionedItems.FireChange(); }
public void Filter(ItemsList filterList, ItemsList originalList, string search) { // Handle external filter if (string.IsNullOrEmpty(search)) { return; } // Handle given search as single key KeyPress(search[0]); // List will not be replaced, as the instance is already bound by screen, we only filter items. filterList.Clear(); foreach (NavigationItem item in originalList.OfType <NavigationItem>()) { var simpleTitle = item.SimpleTitle; // Filter if (_listFilterAction == FilterAction.StartsWith) { if (simpleTitle.ToLower().StartsWith(_listFilterString)) { filterList.Add(item); } } else { if (NumPadEncode(simpleTitle).Contains(_listFilterString)) { filterList.Add(item); } } } filterList.FireChange(); }
protected void UpdateFiltersList() { _filterItemsList.Clear(); NavigationData navigationData = GetCurrentNavigationData(); IList <WorkflowAction> actions = navigationData.GetWorkflowActions(); if (actions == null) { return; } string currentScreenTitle = LocalizationHelper.CreateResourceString(navigationData.CurrentScreenData?.MenuItemLabel)?.Evaluate(); foreach (WorkflowAction action in actions) { WorkflowAction actionCopy = action; ListItem screenItem = new ListItem(Consts.KEY_NAME, action.DisplayTitle) { Command = new MethodDelegateCommand(actionCopy.Execute), Selected = currentScreenTitle == action.DisplayTitle?.Evaluate() }; screenItem.AdditionalProperties[Consts.KEY_FILTER] = actionCopy; _filterItemsList.Add(screenItem); } _filterItemsList.FireChange(); }
protected void UpdateShutdownItems() { ISettingsManager sm = ServiceRegistration.Get <ISettingsManager>(); List <SystemStateItem> systemStateItems = sm.Load <SystemStateDialogSettings>().ShutdownItemList; bool timerActive = false; Models.SleepTimerModel stm = ServiceRegistration.Get <IWorkflowManager>().GetModel(Consts.WF_STATE_ID_SLEEP_TIMER_MODEL) as Models.SleepTimerModel; if (stm != null && stm.IsSleepTimerActive == true) { timerActive = true; } _shutdownItems.Clear(); if (systemStateItems != null) { for (int i = 0; i < systemStateItems.Count; i++) { SystemStateItem systemStateItem = systemStateItems[i]; if (!systemStateItem.Enabled) { continue; } ListItem item = new ListItem(Consts.KEY_NAME, Consts.GetResourceIdentifierForMenuItem(systemStateItem.Action, timerActive)); item.Command = new MethodDelegateCommand(() => DoAction(systemStateItem.Action)); _shutdownItems.Add(item); } } _shutdownItems.FireChange(); }
protected void UpdatePrograms() { UpdateGuiProperties(); _programsList.Clear(); IChannel channel = CurrentChannel; if (channel != null) { if (_tvHandler.ProgramInfo.GetPrograms(channel, DateTime.Now.AddHours(-2), DateTime.Now.AddHours(24), out _programs)) { foreach (IProgram program in _programs) { // Use local variable, otherwise delegate argument is not fixed ProgramProperties programProperties = new ProgramProperties(); IProgram currentProgram = program; programProperties.SetProgram(currentProgram, channel); ProgramListItem item = new ProgramListItem(programProperties) { Command = new MethodDelegateCommand(() => ShowProgramActions(currentProgram)) }; item.AdditionalProperties["PROGRAM"] = currentProgram; _programsList.Add(item); } } ProgramsList.FireChange(); } else { _programs = null; } }
protected static async Task FillListAsync(IContentDirectory contentDirectory, Guid[] necessaryMIATypeIds, ItemsList list, MediaItemToListItemAction converterAction) { MediaItemQuery query = new MediaItemQuery(necessaryMIATypeIds, null) { Limit = QUERY_LIMIT, // Last 5 imported items SortInformation = new List <ISortInformation> { new AttributeSortInformation(ImporterAspect.ATTR_DATEADDED, SortDirection.Descending) } }; Guid? userProfile = null; IUserManagement userProfileDataManagement = ServiceRegistration.Get <IUserManagement>(); if (userProfileDataManagement != null && userProfileDataManagement.IsValidUser) { userProfile = userProfileDataManagement.CurrentUser.ProfileId; } bool showVirtual = VirtualMediaHelper.ShowVirtualMedia(necessaryMIATypeIds); var items = await contentDirectory.SearchAsync(query, false, userProfile, showVirtual); list.Clear(); foreach (MediaItem mediaItem in items) { PlayableMediaItem listItem = converterAction(mediaItem); listItem.Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(listItem.MediaItem)); list.Add(listItem); } list.FireChange(); }
/// <summary> /// Fill the List and set the Labels /// </summary> public static void FillItemList(List <MyStream> list) { AllRadioStreams.Clear(); var indx = 0; foreach (var ms in list) { indx += 1; SetFallbackValues(ms); var item = new ListItem { AdditionalProperties = { [STREAM_URL] = ms.StreamUrls[0].StreamUrl } }; item.SetLabel("Name", ms.Title); item.SetLabel("Country", "[Country." + ms.Country + "]"); item.SetLabel("CountryCode", ms.Country); item.SetLabel("City", ms.City); item.SetLabel("Genres", ms.Genres); item.SetLabel("Bitrate", ms.StreamUrls[0].Bitrate); item.SetLabel("StreamProvider", ms.StreamUrls[0].Provider); item.SetLabel("StreamFrequenz", ms.StreamUrls[0].Frequenz); item.SetLabel("StreamMode", ms.StreamUrls[0].Mode); item.SetLabel("StreamName", ms.StreamUrls[0].Name); item.SetLabel("StreamTyp", ms.StreamUrls[0].Typ); item.SetLabel("Logo", SetStreamLogo(ms)); item.SetLabel("ImageSrc", SetStreamLogo(ms)); item.SetLabel("Description", SetStreamDescription(ms)); item.SetLabel("Language", "[Language." + ms.Language + "]"); item.SetLabel("LanguageCode", ms.Language); item.SetLabel("Indx", indx + "/" + list.Count); AllRadioStreams.Add(item); } AllRadioStreams.FireChange(); }
protected void UpdateLocalCoreItems() { var sm = ServiceRegistration.Get <ISettingsManager>(); var settings = sm.Load <LibRetroSettings>(); string coresDirectory = settings.GetPlatformSpecificCoresDirectory(); _localCoreItems.Clear(); try { if (Directory.Exists(coresDirectory)) { foreach (string path in Directory.EnumerateFiles(coresDirectory, "*.dll")) { string coreName = Path.GetFileName(path); CoreInfo coreInfo = CoreHandler.LoadCoreInfo(coreName, settings.InfoDirectory); if (coreInfo != null) { coreName = coreInfo.DisplayName; } ListItem item = new ListItem(Consts.KEY_NAME, coreName); item.SetLabel(Consts.KEY_PATH, path); item.SelectedProperty.Attach(OnCoreItemSelectionChanged); _localCoreItems.Add(item); } } } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error("EmulatorConfigurationModel: Exception loading cores from '{0}'", ex, coresDirectory); } _localCoreItems.FireChange(); }
protected void UpdateMenuItems() { _menuItems.Clear(); List <SystemStateItem> shutdownItems = _settings.Settings.ShutdownItemList; if (shutdownItems != null) { bool timerActive = false; SleepTimerModel stm = ServiceRegistration.Get <IWorkflowManager>().GetModel(Consts.WF_STATE_ID_SLEEP_TIMER_MODEL) as SleepTimerModel; if (stm != null && stm.IsSleepTimerActive) { timerActive = true; } foreach (SystemStateItem shutdownItem in shutdownItems) { if (!shutdownItem.Enabled) { continue; } ListItem item = new ListItem(Consts.KEY_NAME, Consts.GetResourceIdentifierForMenuItem(shutdownItem.Action, timerActive)); item.AdditionalProperties[KEY_SHUTDOWN_ACTION] = shutdownItem.Action; item.Command = new MethodDelegateCommand(() => SelectItem(item)); _menuItems.Add(item); } } _menuItems.FireChange(); }
protected override void UpdateChannels() { base.UpdateChannels(); if (_webChannelGroupIndex < _channelGroups.Count) { IChannelGroup currentGroup = _channelGroups[_webChannelGroupIndex]; CurrentGroupName = currentGroup.Name; } _channelList.Clear(); if (_channels == null) { return; } foreach (IChannel channel in _channels) { // Use local variable, otherwise delegate argument is not fixed IChannel currentChannel = channel; ChannelProgramListItem item = new ChannelProgramListItem(currentChannel, GetNowAndNextProgramsList(currentChannel)) { Command = new MethodDelegateCommand(() => Tune(currentChannel)) }; item.AdditionalProperties["CHANNEL"] = channel; _channelList.Add(item); } CurrentGroupChannels.FireChange(); }
protected override void SettingChanged() { _items.Clear(); SkinConfigSetting skinSetting = (SkinConfigSetting)_setting; foreach (SkinManagement.Skin skin in skinSetting.Skins) { ListItem skinItem = new ListItem(KEY_NAME, skin.ShortDescription); skinItem.SetLabel(KEY_TECHNAME, skin.Name); ISkinResourceBundle resourceBundle; string preview = skin.GetResourceFilePath(skin.PreviewResourceKey, false, out resourceBundle); if (preview == null) { Theme defaultTheme = skin.DefaultTheme; if (defaultTheme != null) { preview = defaultTheme.GetResourceFilePath(skin.PreviewResourceKey, false, out resourceBundle); } } skinItem.SetLabel(KEY_IMAGESRC, preview); _items.Add(skinItem); if (skinSetting.CurrentSkinName == skin.Name) { skinItem.Selected = true; _choosenItem = skinItem; } } _items.FireChange(); base.SettingChanged(); }
protected void UpdatePlaylist() { IPlayerContextManager playerContextManager = ServiceRegistration.Get <IPlayerContextManager>(); IPlayerContext pc = playerContextManager.GetPlayerContext(PlayerChoice.CurrentPlayer); IPlaylist playlist = pc == null ? null : pc.Playlist; UpdatePlaylistHeader(pc == null ? null : (AVType?)pc.AVType, pc == null ? true : pc.IsPrimaryPlayerContext); lock (_syncObj) { _playlist = playlist; _playlistItems.Clear(); if (playlist != null) { int ct = 0; int currentItemIdx = playlist.ItemListIndex; foreach (MediaItem mediaItem in playlist.ItemList) { int idx = ct++; PlayableMediaItem item = PlayableMediaItem.CreateItem(mediaItem); item.SetLabel(Consts.KEY_NUMBERSTR, (idx + 1) + "."); item.AdditionalProperties[Consts.KEY_INDEX] = idx; item.AdditionalProperties[Consts.KEY_IS_CURRENT_ITEM] = currentItemIdx == idx; _playlistItems.Add(item); } } IsPlaylistEmpty = _playlistItems.Count == 0; NumPlaylistItemsStr = Utils.BuildNumItemsStr(_playlistItems.Count, null); } _playlistItems.FireChange(); }
private void FillWASAPIDeviceList() { _WASAPIDevices.Clear(); BassPlayerSettings settings = Controller.GetSettings(); BASS_WASAPI_DEVICEINFO[] deviceDescriptions = BassWasapi.BASS_WASAPI_GetDeviceInfos(); for (int i = 0; i < deviceDescriptions.Length; i++) { // Skip input devices, they have same name as output devices. BASS_WASAPI_DEVICEINFO deviceInfo = deviceDescriptions[i]; bool skip = !WASAPIOutputDevice.IsValidDevice(deviceInfo); ServiceRegistration.Get <ILogger>().Debug("{5} WASAPI Device {0}: '{1}' Flags: {2} Device path: [{3}] Ch: {4}", i, deviceInfo.name, deviceInfo.flags, deviceInfo.id, deviceInfo.mixchans, skip ? "Skip" : "Use "); if (skip) { continue; } ListItem deviceItem = new ListItem(Consts.KEY_NAME, deviceInfo.name) { Selected = deviceInfo.name == settings.WASAPIDevice }; deviceItem.SelectedProperty.Attach(delegate { var selected = _WASAPIDevices.FirstOrDefault(d => d.Selected); WASAPIDevice = selected != null ? selected.Labels[Consts.KEY_NAME].ToString() : string.Empty; }); deviceItem.SetLabel(KEY_GROUP, "WASAPI"); _WASAPIDevices.Add(deviceItem); } _WASAPIDevices.FireChange(); }
protected void UpdateGroupingsList() { _groupingItemsList.Clear(); NavigationData navigationData = GetCurrentNavigationData(); ICollection <Sorting.Sorting> groupings = navigationData.AvailableGroupings; if (groupings == null) { return; } ListItem groupingItem = new ListItem(Consts.KEY_NAME, Consts.RES_NO_GROUPING) { Command = new MethodDelegateCommand(() => navigationData.CurrentGrouping = null), Selected = navigationData.CurrentGrouping == null }; groupingItem.AdditionalProperties[Consts.KEY_GROUPING] = null; _groupingItemsList.Add(groupingItem); foreach (Sorting.Sorting grouping in groupings.Where(g => g.IsAvailable(navigationData.CurrentScreenData))) { Sorting.Sorting groupingCopy = grouping; groupingItem = new ListItem(Consts.KEY_NAME, grouping.GroupByDisplayName) { Command = new MethodDelegateCommand(() => navigationData.CurrentGrouping = groupingCopy), Selected = navigationData.CurrentGrouping == groupingCopy }; groupingItem.AdditionalProperties[Consts.KEY_GROUPING] = groupingCopy; _groupingItemsList.Add(groupingItem); } _groupingItemsList.FireChange(); }
private void FillProgramsList() { _programsList.Clear(); foreach (IProgram program in _programs) { // Use local variable, otherwise delegate argument is not fixed ProgramProperties programProperties = new ProgramProperties(); IProgram currentProgram = program; programProperties.SetProgram(currentProgram); ProgramListItem item = new ProgramListItem(programProperties) { Command = new MethodDelegateCommand(() => { var isSingle = programProperties.IsScheduled; var isSeries = programProperties.IsSeriesScheduled; if (isSingle || isSeries) { CancelSchedule(currentProgram); } else { RecordSeries(currentProgram); } }) }; item.AdditionalProperties["PROGRAM"] = currentProgram; item.Selected = _lastProgramId == program.ProgramId; // Restore focus _programsList.Add(item); } _programsList.FireChange(); }
protected async Task <bool> FillItemsList(MediaItem mediaItem) { _mediaItemActionItems.Clear(); foreach (MediaItemActionExtension action in _actions.OrderBy(a => a.Sort)) { if (!await action.Action.IsAvailableAsync(mediaItem)) { continue; } // Some actions can be restricted to users. IUserRestriction restriction = action.Action as IUserRestriction; if (restriction != null) { if (!ServiceRegistration.Get <IUserManagement>().CheckUserAccess(restriction)) { continue; } } ListItem item = new ListItem(Consts.KEY_NAME, action.Caption); item.AdditionalProperties[Consts.KEY_MEDIA_ITEM] = mediaItem; item.AdditionalProperties[Consts.KEY_MEDIA_ITEM_ACTION] = action.Action; _mediaItemActionItems.Add(item); } _mediaItemActionItems.FireChange(); return(_mediaItemActionItems.Count > 0); }
protected static ItemsList UpdateNavigationItems(NavigationContext context) { try { ItemsList navigationItems = GetOrCreateNavigationItems(context); Stack <NavigationContext> contextStack = ServiceRegistration.Get <IWorkflowManager>().NavigationContextStack; List <NavigationContext> contexts = new List <NavigationContext>(contextStack); contexts.Reverse(); navigationItems.Clear(); for (int index = 0; index < contexts.Count; index++) { NavigationContext ctx = contexts[index]; ListItem item = new ListItem(KEY_NAME, ctx.DisplayLabel); item.AdditionalProperties[KEY_ISFIRST] = index == 0; item.AdditionalProperties[KEY_ISLAST] = index == contexts.Count - 1; NavigationContext contextCopy = ctx; item.Command = new MethodDelegateCommand(() => WorkflowPopToState(contextCopy.WorkflowState.StateId)); navigationItems.Add(item); } navigationItems.FireChange(); return(navigationItems); } catch (Exception e) { ServiceRegistration.Get <ILogger>().Warn("WorkflowNavigationBar: Error updating properties", e); return(null); } }
protected void ExitContext(NavigationContext oldContext) { _messageQueue.Shutdown(); if (oldContext.WorkflowState.StateId == Consts.WF_STATE_ID_PLAYER_CONFIGURATION_DIALOG) { _inPlayerConfigurationDialog = false; _playerConfigurationMenu.Clear(); } else if (oldContext.WorkflowState.StateId == Consts.WF_STATE_ID_CHOOSE_AUDIO_STREAM_DIALOG) { _inChooseAudioStreamDialog = false; _audioStreamsMenu.Clear(); } else if (oldContext.WorkflowState.StateId == Consts.WF_STATE_ID_PLAYER_AUDIO_MENU_DIALOG) { _inPlayerSlotAudioMenuDialog = false; _playerSlotAudioMenu.Clear(); } else if (oldContext.WorkflowState.StateId == Consts.WF_STATE_ID_PLAYER_CHOOSE_GEOMETRY_MENU_DIALOG) { _inPlayerChooseGeometryMenuDialog = false; _playerChooseGeometryMenu.Clear(); } else if (oldContext.WorkflowState.StateId == Consts.WF_STATE_ID_PLAYER_CHOOSE_EFFECT_MENU_DIALOG) { _inPlayerChooseEffectMenuDialog = false; _playerChooseEffectMenu.Clear(); } }
protected void LoadSchedules() { UpdateScheduleDetails(null); if (_tvHandler.ScheduleControl == null) { return; } IList <ISchedule> schedules; if (!_tvHandler.ScheduleControl.GetSchedules(out schedules)) { return; } _schedulesList.Clear(); foreach (ISchedule schedule in schedules) { ISchedule currentSchedule = schedule; ListItem item = new ListItem("Name", schedule.Name) { Command = new MethodDelegateCommand(() => ShowActions(currentSchedule)) }; IChannel channel; if (_tvHandler.ChannelAndGroupInfo.GetChannel(currentSchedule.ChannelId, out channel)) { item.SetLabel("ChannelName", channel.Name); } item.SetLabel("StartTime", schedule.StartTime.FormatProgramTime()); item.SetLabel("ScheduleType", string.Format("[SlimTvClient.ScheduleRecordingType_{0}]", schedule.RecordingType)); item.AdditionalProperties["SCHEDULE"] = currentSchedule; _schedulesList.Add(item); } _schedulesList.FireChange(); }
private void FillWASAPIDeviceList() { _WASAPIDevices.Clear(); BassPlayerSettings settings = Controller.GetSettings(); BASS_WASAPI_DEVICEINFO[] deviceDescriptions = BassWasapi.BASS_WASAPI_GetDeviceInfos(); for (int i = 0; i < deviceDescriptions.Length; i++) { // Skip input devices, they have same name as output devices. BASS_WASAPI_DEVICEINFO deviceInfo = deviceDescriptions[i]; if ((deviceInfo.flags & (BASSWASAPIDeviceInfo.BASS_DEVICE_INPUT | BASSWASAPIDeviceInfo.BASS_DEVICE_DISABLED /*| BASSWASAPIDeviceInfo.BASS_DEVICE_UNPLUGGED */)) != 0) { continue; } ListItem deviceItem = new ListItem(Consts.KEY_NAME, deviceInfo.name) { Selected = deviceInfo.name == settings.WASAPIDevice }; deviceItem.SelectedProperty.Attach(delegate { var selected = _WASAPIDevices.FirstOrDefault(d => d.Selected); WASAPIDevice = selected != null ? selected.Labels[Consts.KEY_NAME].ToString() : string.Empty; }); deviceItem.SetLabel(KEY_GROUP, "WASAPI"); _WASAPIDevices.Add(deviceItem); } _WASAPIDevices.FireChange(); }
protected void UpdateSharesList_NoLock(ItemsList list, List<Share> shareDescriptors, ShareOrigin origin, bool selectFirstItem) { list.Clear(); bool selectShare = selectFirstItem; shareDescriptors.Sort((a, b) => a.Name.CompareTo(b.Name)); foreach (Share share in shareDescriptors) { ListItem shareItem = new ListItem(Consts.KEY_NAME, share.Name); shareItem.AdditionalProperties[Consts.KEY_SHARE] = share; try { string path = origin == ShareOrigin.Local ? LocalShares.GetLocalResourcePathDisplayName(share.BaseResourcePath) : ServerShares.GetServerResourcePathDisplayName(share.BaseResourcePath); if (string.IsNullOrEmpty(path)) // Error case: The path is invalid path = LocalizationHelper.Translate(Consts.RES_INVALID_PATH, share.BaseResourcePath); shareItem.SetLabel(Consts.KEY_PATH, path); Guid? firstResourceProviderId = SharesProxy.GetBaseResourceProviderId(share.BaseResourcePath); if (firstResourceProviderId.HasValue) { ResourceProviderMetadata firstResourceProviderMetadata = origin == ShareOrigin.Local ? LocalShares.GetLocalResourceProviderMetadata(firstResourceProviderId.Value) : ServerShares.GetServerResourceProviderMetadata(firstResourceProviderId.Value); shareItem.AdditionalProperties[Consts.KEY_RESOURCE_PROVIDER_METADATA] = firstResourceProviderMetadata; } string categories = StringUtils.Join(", ", share.MediaCategories); shareItem.SetLabel(Consts.KEY_MEDIA_CATEGORIES, categories); Share shareCopy = share; shareItem.Command = new MethodDelegateCommand(() => ShowShareInfo(shareCopy, origin)); } catch (NotConnectedException) { throw; } catch (Exception e) { ServiceRegistration.Get<ILogger>().Warn("Problems building share item '{0}' (path '{1}')", e, share.Name, share.BaseResourcePath); } if (selectShare) { selectShare = false; shareItem.Selected = true; } shareItem.SelectedProperty.Attach(OnShareItemSelectionChanged); lock (_syncObj) list.Add(shareItem); } list.FireChange(); }
protected void RefreshResourceProviderPathList(ItemsList items, ResourcePath path) { items.Clear(); IEnumerable<ResourcePathMetadata> res = GetChildDirectoriesData(path); if (res != null) { List<ResourcePathMetadata> directories = new List<ResourcePathMetadata>(res); directories.Sort((a, b) => a.ResourceName.CompareTo(b.ResourceName)); foreach (ResourcePathMetadata childDirectory in directories) { TreeItem directoryItem = new TreeItem(Consts.KEY_NAME, childDirectory.ResourceName); directoryItem.AdditionalProperties[Consts.KEY_RESOURCE_PATH] = childDirectory.ResourcePath; directoryItem.SetLabel(Consts.KEY_PATH, childDirectory.HumanReadablePath); if (ChoosenResourcePath == childDirectory.ResourcePath) directoryItem.Selected = true; directoryItem.SelectedProperty.Attach(OnTreePathSelectionChanged); directoryItem.AdditionalProperties[Consts.KEY_EXPANSION] = new ExpansionHelper(directoryItem, this); items.Add(directoryItem); } } items.FireChange(); }
protected void UpdatePlaylists(ItemsList list, List<PlaylistBase> playlistsData, bool selectFirstItem) { list.Clear(); bool selectPlaylist = selectFirstItem; playlistsData.Sort((a, b) => a.Name.CompareTo(b.Name)); foreach (PlaylistBase playlistData in playlistsData) { AVType? avType = ConvertPlaylistTypeToAVType(playlistData.PlaylistType); if (!avType.HasValue) continue; ListItem playlistItem = new ListItem(Consts.KEY_NAME, playlistData.Name); playlistItem.AdditionalProperties[Consts.KEY_PLAYLIST_AV_TYPE] = avType.Value; playlistItem.AdditionalProperties[Consts.KEY_PLAYLIST_NUM_ITEMS] = playlistData.NumItems; playlistItem.AdditionalProperties[Consts.KEY_PLAYLIST_DATA] = playlistData; PlaylistBase plCopy = playlistData; playlistItem.Command = new MethodDelegateCommand(() => ShowPlaylistInfo(plCopy)); if (selectPlaylist) { selectPlaylist = false; playlistItem.Selected = true; } playlistItem.SelectedProperty.Attach(OnPlaylistItemSelectionChanged); lock (_syncObj) list.Add(playlistItem); } list.FireChange(); }
protected void BuildCategoriesTree(ItemsList contents, TreeItem parentItem, ICollection<string> categories, ICollection<string> allSelectedCategories, IDictionary<string, ICollection<string>> categories2Children, IDictionary<string, MediaCategory> allCategories) { contents.Clear(); List<string> categoriesSorted = new List<string>(categories); categoriesSorted.Sort(); foreach (string mediaCategory in categoriesSorted) { TreeItem categoryItem = new TreeItem(Consts.KEY_NAME, mediaCategory); categoryItem.AdditionalProperties[Consts.KEY_MEDIA_CATEGORY] = allCategories[mediaCategory]; categoryItem.AdditionalProperties[Consts.KEY_PARENT_ITEM] = parentItem; if (allSelectedCategories.Contains(mediaCategory)) categoryItem.Selected = true; PropertyChangedHandler handler = (property, oldValue) => OnMediaCategoryItemSelectionChanged(categoryItem); categoryItem.SelectedProperty.Attach(handler); categoryItem.AdditionalProperties["HandlerStrongReference"] = handler; // SelectedProperty only manages weak references to its handlers -> avoid handler to be removed ICollection<string> childCategories; if (!categories2Children.TryGetValue(mediaCategory, out childCategories)) childCategories = new List<string>(); BuildCategoriesTree(categoryItem.SubItems, categoryItem, childCategories, allSelectedCategories, categories2Children, allCategories); contents.Add(categoryItem); } }
/// <summary> /// Rebuilds all items of the current menu in the given <paramref name="context"/>. /// </summary> /// <remarks> /// This method locks the synchronization object of the <paramref name="menuItems"/> list and thus must not call /// change handlers. /// After executing this method, the returned <see cref="ItemsList"/>'s <see cref="ItemsList.FireChange"/> /// method must be called. /// </remarks> /// <param name="context">Workflow navigation context the menu should be built for.</param> /// <param name="menuItems">Menu items list to rebuild.</param> /// <param name="newActions">Preprocessed list (sorted etc.) of actions to be used for the new menu.</param> protected void RebuildMenuEntries(NavigationContext context, ItemsList menuItems, IList<WorkflowAction> newActions) { UnregisterActionChangeHandlers(context); lock (menuItems.SyncRoot) { menuItems.Clear(); foreach (WorkflowAction action in newActions) { RegisterActionChangeHandler(context, action); if (!action.IsVisible(context)) continue; ListItem item = new ListItem("Name", action.DisplayTitle) { Command = new MethodDelegateCommand(action.Execute), Enabled = action.IsEnabled(context), }; item.AdditionalProperties[Consts.KEY_ITEM_ACTION] = action; menuItems.Add(item); } } }
protected void FillList(IContentDirectory contentDirectory, Guid[] necessaryMIAs, ItemsList list, MediaItemToListItemAction converterAction) { MediaItemQuery query = new MediaItemQuery(necessaryMIAs, null) { Limit = (uint)QueryLimit, // Last 5 imported items SortInformation = new List<SortInformation> { new SortInformation(ImporterAspect.ATTR_DATEADDED, SortDirection.Descending) } }; var items = contentDirectory.Search(query, false); list.Clear(); foreach (MediaItem mediaItem in items) { PlayableMediaItem listItem = converterAction(mediaItem); listItem.Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(listItem.MediaItem)); list.Add(listItem); } list.FireChange(); }
protected void RefreshResourceProviderPathList(ItemsList items, ResourcePath path) { items.Clear(); IEnumerable<ResourcePathMetadata> res = GetChildDirectoriesData(path); if (res != null) AddResources(res, items); if (_enumerateFiles) { res = GetFilesData(path); if (res != null) AddResources(res, items); } items.FireChange(); }
private void InitList(ItemsList targetList, string selectedEffect, SimpleStringDelegate command) { targetList.Clear(); IGeometryManager geometryManager = ServiceRegistration.Get<IGeometryManager>(); string standardEffectFile = geometryManager.StandardEffectFile; foreach (KeyValuePair<string, string> nameToEffect in geometryManager.AvailableEffects) { string file = nameToEffect.Key; string effectFile = selectedEffect ?? standardEffectFile; string effectName = nameToEffect.Value; ListItem item = new ListItem(Consts.KEY_NAME, effectName) { Command = new MethodDelegateCommand(() => command(effectName, file)), Selected = file == effectFile, }; targetList.Add(item); } targetList.FireChange(); }