Exemplo n.º 1
0
        ItemsList CreateContextMenuEntries()
        {
            var site       = OnlineVideoSettings.Instance.SiteUtilsList[SiteName];
            var ctxEntries = new ItemsList();

            if (VideoInfo != null)
            {
                if (SiteUtilName != "DownloadedVideo" && (IsDetailsVideo || !(VideoInfo.HasDetails & site is Sites.IChoice)))
                {
                    ctxEntries.Add(
                        new ListItem(Consts.KEY_NAME, string.Format("{0} ({1})", Translation.Instance.Download, Translation.Instance.Concurrent))
                    {
                        Command = new MethodDelegateCommand(() => DownloadConcurrent())
                    });
                    ctxEntries.Add(
                        new ListItem(Consts.KEY_NAME, string.Format("{0} ({1})", Translation.Instance.Download, Translation.Instance.Queued))
                    {
                        Command = new MethodDelegateCommand(() => DownloadQueued())
                    });
                }
                foreach (var entry in site.GetContextMenuEntries(Category, VideoInfo))
                {
                    var entry_for_closure = entry;
                    var item = new ListItem(Consts.KEY_NAME, entry.DisplayText);
                    item.Command = new MethodDelegateCommand(() => HandleCustomContextMenuEntry(entry_for_closure));
                    ctxEntries.Add(item);
                }
            }
            return(ctxEntries);
        }
Exemplo n.º 2
0
        public LayoutTypeModel()
        {
            items = new ItemsList();

            ListItem listItem = new ListItem(Consts.KEY_NAME, "List")
            {
                Command = new MethodDelegateCommand(() => UpdateLayout(LayoutType.List))
            };
            listItem.AdditionalProperties[KEY_LAYOUT_TYPE] = LayoutType.List;
            items.Add(listItem);

            ListItem gridItem = new ListItem(Consts.KEY_NAME, "Grid")
            {
                Command = new MethodDelegateCommand(() => UpdateLayout(LayoutType.Icons))
            };
            gridItem.AdditionalProperties[KEY_LAYOUT_TYPE] = LayoutType.Icons;
            items.Add(gridItem);

            ListItem coversItem = new ListItem(Consts.KEY_NAME, "Covers")
            {
                Command = new MethodDelegateCommand(() => UpdateLayout(LayoutType.Cover))
            };
            coversItem.AdditionalProperties[KEY_LAYOUT_TYPE] = LayoutType.Cover;
            items.Add(coversItem);
        }
Exemplo n.º 3
0
        protected ItemsList GetProgramsList(IChannel channel, DateTime referenceStart, DateTime referenceEnd)
        {
            ItemsList channelPrograms = new ItemsList();

            if (_tvHandler.ProgramInfo.GetPrograms(channel, referenceStart, referenceEnd, out _programs))
            {
                foreach (IProgram program in _programs)
                {
                    // Use local variable, otherwise delegate argument is not fixed
                    ProgramProperties programProperties = new ProgramProperties(GuideStartTime, GuideEndTime);
                    IProgram          currentProgram    = program;
                    programProperties.SetProgram(currentProgram);

                    ProgramListItem item = new ProgramListItem(programProperties)
                    {
                        Command = new MethodDelegateCommand(() => ShowProgramActions(currentProgram))
                    };
                    item.AdditionalProperties["PROGRAM"] = currentProgram;

                    channelPrograms.Add(item);
                }
            }
            else
            {
                channelPrograms.Add(NoProgramPlaceholder());
            }
            return(channelPrograms);
        }
Exemplo n.º 4
0
        protected void Update()
        {
            ClearAll();
            var contentDirectory = ServiceRegistration.Get <IServerConnectionManager>().ContentDirectory;

            if (contentDirectory == null)
            {
                return;
            }

            ItemsList l1 = new ItemsList();
            ItemsList l2 = new ItemsList();
            ItemsList l3 = new ItemsList();
            ItemsList l4 = new ItemsList();
            var       t1 = FillListAsync(contentDirectory, Consts.NECESSARY_MOVIES_MIAS, l1, item => new MovieItem(item));
            var       t2 = FillListAsync(contentDirectory, Consts.NECESSARY_EPISODE_MIAS, l2, item => new EpisodeItem(item));
            var       t3 = FillListAsync(contentDirectory, Consts.NECESSARY_IMAGE_MIAS, l3, item => new ImageItem(item));
            var       t4 = FillListAsync(contentDirectory, Consts.NECESSARY_AUDIO_MIAS, l4, item => new AudioItem(item));

            Task.WaitAll(t1, t2, t3, t4);
            AllItems.Add(new TitledItem("[Media.MoviesMenuItem]", l1));
            AllItems.Add(new TitledItem("[Media.SeriesMenuItem]", l2));
            AllItems.Add(new TitledItem("[Media.ImagesMenuItem]", l3));
            AllItems.Add(new TitledItem("[Media.AudioMenuItem]", l4));

            AllItems.FireChange();
        }
Exemplo n.º 5
0
        internal void InsertNewItemRow(DataGrid grdItems, dhSaleItem newItem)
        {
            ItemsList updatedList = new ItemsList();

            var    itemsSource   = grdItems.ItemsSource as IEnumerable;
            int    SerialCounter = 1;
            double total         = 0;

            // add the total ammount
            total = total + Convert.ToDouble(newItem.FGrossAmount);
            if (null != itemsSource)
            {
                IEnumerable <DataGridRow> row = blUtil.GetDataGridRows(grdItems);
                //updatedList.Remove(
                /// go through each row in the datagrid
                foreach (DataGridRow r in row)
                {
                    if (r != null)
                    {
                        dhSaleItem gridRowObject = (dhSaleItem)r.Item;
                        gridRowObject.ISerialNumber = SerialCounter;
                        SerialCounter = SerialCounter + 1;
                        total         = total + Convert.ToDouble(gridRowObject.FGrossAmount);
                        updatedList.Add(gridRowObject);
                    }
                }
            }
            newItem.ISerialNumber = SerialCounter;
            updatedList.Add(newItem);
            grdItems.ItemsSource = updatedList;
        }
Exemplo n.º 6
0
        ItemsList CreatePossibleValuesList()
        {
            var result = new ItemsList();

            if (PropertyDescriptor.IsBool)
            {
                var item = new ListItem(Consts.KEY_NAME, new StringId("[System.Yes]"))
                {
                    Selected = Value == true.ToString()
                };
                item.AdditionalProperties.Add(KEY_VALUE, true.ToString());
                result.Add(item);

                item = new ListItem(Consts.KEY_NAME, new StringId("[System.No]"))
                {
                    Selected = Value == false.ToString()
                };
                item.AdditionalProperties.Add(KEY_VALUE, false.ToString());
                result.Add(item);
            }
            else if (PropertyDescriptor.IsEnum)
            {
                foreach (string e in PropertyDescriptor.GetEnumValues())
                {
                    var item = new ListItem(Consts.KEY_NAME, e)
                    {
                        Selected = Value == e
                    };
                    item.AdditionalProperties.Add(KEY_VALUE, e);
                    result.Add(item);
                }
            }
            return(result);
        }
        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();
        }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
    protected void Update()
    {
      ClearAll();
      var contentDirectory = ServiceRegistration.Get<IServerConnectionManager>().ContentDirectory;
      if (contentDirectory == null)
      {
        return;
      }

      ItemsList list = new ItemsList();
      FillList(contentDirectory, Consts.NECESSARY_MOVIES_MIAS, list, item => new MovieItem(item));
      AllItems.Add(new TitledItem("[Media.MoviesMenuItem]", list));

      list = new ItemsList();
      FillList(contentDirectory, Consts.NECESSARY_SERIES_MIAS, list, item => new SeriesItem(item));
      AllItems.Add(new TitledItem("[Media.SeriesMenuItem]", list));

      list = new ItemsList();
      FillList(contentDirectory, Consts.NECESSARY_IMAGE_MIAS, list, item => new ImageItem(item));
      AllItems.Add(new TitledItem("[Media.ImagesMenuItem]", list));

      list = new ItemsList();
      FillList(contentDirectory, Consts.NECESSARY_AUDIO_MIAS, list, item => new AudioItem(item));
      AllItems.Add(new TitledItem("[Media.AudioMenuItem]", list));

      AllItems.FireChange();
    }
Exemplo n.º 10
0
        protected void UpdateSystemsList_NoLock()
        {
            lock (_syncObj)
            {
                _systemsList = new ItemsList();

                if (_enableLocalShares)
                {
                    ListItem localSystemItem = new ListItem(Consts.KEY_NAME, Consts.RES_SHARES_CONFIG_LOCAL_SHARE);
                    localSystemItem.AdditionalProperties[Consts.KEY_SHARES_PROXY] = new LocalShares();
                    localSystemItem.SelectedProperty.Attach(OnSystemSelectionChanged);
                    _systemsList.Add(localSystemItem);
                }

                if (_enableServerShares)
                {
                    ListItem serverSystemItem = new ListItem(Consts.KEY_NAME, Consts.RES_SHARES_CONFIG_GLOBAL_SHARE);
                    serverSystemItem.AdditionalProperties[Consts.KEY_SHARES_PROXY] = new ServerShares();
                    serverSystemItem.SelectedProperty.Attach(OnSystemSelectionChanged);
                    _systemsList.Add(serverSystemItem);
                }

                if (_systemsList.Count > 0)
                {
                    _systemsList[0].Selected = true;
                }
            }
            _systemsList.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();
        }
Exemplo n.º 12
0
        private void CreateRegularGroupItems()
        {
            var defaultMenuGroupId = _menuSettings.Settings.DefaultMenuGroupId;

            foreach (var group in _menuSettings.Settings.MainMenuGroupNames)
            {
                string groupId = group.Id.ToString();
                bool   isHome  = groupId.Equals(MenuSettings.MENU_ID_HOME, StringComparison.CurrentCultureIgnoreCase);
                if (isHome && _menuSettings.Settings.DisableHomeTab)
                {
                    continue;
                }

                string groupName = group.Name;
                var    groupItem = new GroupMenuListItem(Consts.KEY_NAME, groupName);
                if (_menuSettings.Settings.DisableAutoSelection)
                {
                    groupItem.Command = new MethodDelegateCommand(() => SetGroup(groupId));
                }

                groupItem.AdditionalProperties["Id"]   = groupId;
                groupItem.AdditionalProperties["Item"] = group;
                if (groupId == defaultMenuGroupId)
                {
                    IsHome             = isHome;
                    groupItem.IsActive = true;
                    groupItem.Selected = true;
                }
                _mainMenuGroupList.Add(groupItem);
            }
        }
Exemplo n.º 13
0
        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());
        }
Exemplo n.º 14
0
        public UserLanguageModel()
        {
            _isHomeServerConnectedProperty = new WProperty(typeof(bool), false);
            _isRestrictedToOwnProperty     = new WProperty(typeof(bool), false);
            _isUserSelectedProperty        = new WProperty(typeof(bool), false);

            List <CultureInfo> cultures = new List <CultureInfo>(CultureInfo.GetCultures(CultureTypes.SpecificCultures));

            cultures.Sort(CompareByName);

            _langaugeList = new ItemsList();
            ListItem item = new ListItem();

            item.SetLabel(Consts.KEY_NAME, LocalizationHelper.CreateResourceString("[UserConfig.Default]"));
            item.AdditionalProperties[Consts.KEY_LANGUAGE] = "";
            _langaugeList.Add(item);
            foreach (var ci in cultures)
            {
                item = new ListItem();
                item.SetLabel(Consts.KEY_NAME, LocalizationHelper.CreateStaticString(ci.DisplayName));
                item.AdditionalProperties[Consts.KEY_LANGUAGE] = ci;
                _langaugeList.Add(item);
            }

            UserProxy = new UserProxy();
        }
Exemplo n.º 15
0
        protected void UpdateRepeatModes()
        {
            _repeatModeItems = new ItemsList();
            ListItem noneItem = new ListItem(Consts.KEY_NAME, Consts.RES_REPEATMODE_NONE)
            {
                Command = new MethodDelegateCommand(() => SetRepeatMode(RepeatMode.None))
            };

            noneItem.AdditionalProperties[Consts.KEY_REPEATMODE] = RepeatMode.None;
            _repeatModeItems.Add(noneItem);

            ListItem allItem = new ListItem(Consts.KEY_NAME, Consts.RES_REPEATMODE_ALL)
            {
                Command = new MethodDelegateCommand(() => SetRepeatMode(RepeatMode.All))
            };

            allItem.AdditionalProperties[Consts.KEY_REPEATMODE] = RepeatMode.All;
            _repeatModeItems.Add(allItem);

            ListItem oneItem = new ListItem(Consts.KEY_NAME, Consts.RES_REPEATMODE_ONE)
            {
                Command = new MethodDelegateCommand(() => SetRepeatMode(RepeatMode.One))
            };

            oneItem.AdditionalProperties[Consts.KEY_REPEATMODE] = RepeatMode.One;
            _repeatModeItems.Add(oneItem);
        }
Exemplo n.º 16
0
        protected void CreatePositionedItems(ItemsList list, string currentKey, IDictionary <Guid, GridPosition> gridPositions)
        {
            list.Clear();

            int       x         = 0;
            ItemsList menuItems = GetHomeMenuItems();

            lock (menuItems.SyncRoot)
            {
                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;
                    }

                    // Under "others" all items are places, that do not fit into any other category
                    if (currentKey == MenuSettings.MENU_NAME_OTHERS)
                    {
                        bool found = IsManuallyPositioned(wfAction);
                        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,
                            };
                            list.Add(gridItem);
                            x += MenuSettings.DEFAULT_COLSPAN_SMALL;
                        }
                    }
                    else
                    {
                        GridPosition gridPosition;
                        if (gridPositions.TryGetValue(wfAction.ActionId, out gridPosition))
                        {
                            GridListItem gridItem = new GridListItem(menuItem)
                            {
                                GridRow        = gridPosition.Row,
                                GridColumn     = gridPosition.Column,
                                GridRowSpan    = gridPosition.RowSpan,
                                GridColumnSpan = gridPosition.ColumnSpan,
                            };
                            list.Add(gridItem);
                        }
                    }
                }
            }
            list.FireChange();
        }
Exemplo n.º 17
0
 protected void CreateShareLocations()
 {
     _shareLocations          = new ItemsList();
     _localShareLocationItem  = new ListItem(Consts.KEY_NAME, Consts.RES_LOCAL_SHARE_LOCATION);
     _serverShareLocationItem = new ListItem(Consts.KEY_NAME, Consts.RES_SERVER_SHARE_LOCATION);
     _shareLocations.Add(_localShareLocationItem);
     _shareLocations.Add(_serverShareLocationItem);
     // Initial selection will be filled by LoadSettings()
 }
Exemplo n.º 18
0
        protected void CreatePositionedItems()
        {
            _positionedItems.Clear();
            int       x         = 0;
            ItemsList menuItems = MenuItems;

            lock (menuItems.SyncRoot)
            {
                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;
                    }

                    // Under "others" all items are places, that do not fit into any other category
                    if (CurrentKey == MenuSettings.MENU_NAME_OTHERS)
                    {
                        bool found = _menuSettings.MenuItems.Keys.Any(key => _menuSettings.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();
        }
Exemplo n.º 19
0
        protected internal async Task UpdateUserLists_NoLock(bool create, Guid?selectedUserId = null)
        {
            lock (_syncObj)
            {
                if (_updatingProperties)
                {
                    return;
                }
                _updatingProperties = true;
                if (create)
                {
                    _userList = new ItemsList();
                }
            }
            try
            {
                IUserManagement userManagement = ServiceRegistration.Get <IUserManagement>();
                if (userManagement == null || userManagement.UserProfileDataManagement == null)
                {
                    return;
                }

                // add users to expose them
                var users = await userManagement.UserProfileDataManagement.GetProfilesAsync();

                _userList.Clear();
                ListItem item = new ListItem();
                item.SetLabel(Consts.KEY_NAME, LocalizationHelper.Translate(Consts.RES_NOUSER));
                item.AdditionalProperties[Consts.KEY_USER] = new UserProfile(Guid.Empty, LocalizationHelper.Translate(Consts.RES_NOUSER));
                lock (_syncObj)
                    _userList.Add(item);
                foreach (UserProfile user in users)
                {
                    item = new ListItem();
                    item.SetLabel(Consts.KEY_NAME, user.Name);
                    item.AdditionalProperties[Consts.KEY_USER] = user;
                    lock (_syncObj)
                        _userList.Add(item);
                }
                _userList.FireChange();
            }
            catch (NotConnectedException)
            {
                throw;
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Warn("ClientConfigModel: Problems updating users", e);
            }
            finally
            {
                lock (_syncObj)
                    _updatingProperties = false;
            }
        }
Exemplo n.º 20
0
 public void Add(ListItem item)
 {
     if (_items.Contains(item))
     {
         return;
     }
     _items.Add(item);
     ResetActionItemProperties(_items);
     _items.FireChange();
     UpdateOtherItems();
 }
Exemplo n.º 21
0
        /// <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();
        }
Exemplo n.º 22
0
        public ViewModeModel()
        {
            ViewSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <ViewSettings>();

            _layoutTypeProperty = new WProperty(typeof(LayoutType), settings.LayoutType);
            _layoutSizeProperty = new WProperty(typeof(LayoutSize), settings.LayoutSize);

            ListItem smallList = new ListItem(Consts.KEY_NAME, Consts.RES_SMALL_LIST)
            {
                Command = new MethodDelegateCommand(() => SetViewMode(LayoutType.ListLayout, LayoutSize.Small)),
            };

            smallList.AdditionalProperties[Consts.KEY_LAYOUT_TYPE] = LayoutType.ListLayout;
            smallList.AdditionalProperties[Consts.KEY_LAYOUT_SIZE] = LayoutSize.Small;
            _viewModeItemsList.Add(smallList);

            ListItem mediumlList = new ListItem(Consts.KEY_NAME, Consts.RES_MEDIUM_LIST)
            {
                Command = new MethodDelegateCommand(() => SetViewMode(LayoutType.ListLayout, LayoutSize.Medium))
            };

            mediumlList.AdditionalProperties[Consts.KEY_LAYOUT_TYPE] = LayoutType.ListLayout;
            mediumlList.AdditionalProperties[Consts.KEY_LAYOUT_SIZE] = LayoutSize.Medium;
            _viewModeItemsList.Add(mediumlList);

            ListItem largeList = new ListItem(Consts.KEY_NAME, Consts.RES_LARGE_LIST)
            {
                Command = new MethodDelegateCommand(() => SetViewMode(LayoutType.ListLayout, LayoutSize.Large))
            };

            largeList.AdditionalProperties[Consts.KEY_LAYOUT_TYPE] = LayoutType.ListLayout;
            largeList.AdditionalProperties[Consts.KEY_LAYOUT_SIZE] = LayoutSize.Large;
            _viewModeItemsList.Add(largeList);

            ListItem largeGrid = new ListItem(Consts.KEY_NAME, Consts.RES_LARGE_GRID)
            {
                Command = new MethodDelegateCommand(() => SetViewMode(LayoutType.GridLayout, LayoutSize.Large))
            };

            largeGrid.AdditionalProperties[Consts.KEY_LAYOUT_TYPE] = LayoutType.GridLayout;
            largeGrid.AdditionalProperties[Consts.KEY_LAYOUT_SIZE] = LayoutSize.Large;
            _viewModeItemsList.Add(largeGrid);

            ListItem coverLarge = new ListItem(Consts.KEY_NAME, Consts.RES_LARGE_COVER)
            {
                Command = new MethodDelegateCommand(() => SetViewMode(LayoutType.CoverLayout, LayoutSize.Large))
            };

            coverLarge.AdditionalProperties[Consts.KEY_LAYOUT_TYPE] = LayoutType.CoverLayout;
            coverLarge.AdditionalProperties[Consts.KEY_LAYOUT_SIZE] = LayoutSize.Large;
            _viewModeItemsList.Add(coverLarge);
        }
Exemplo n.º 23
0
 protected void InitializeTree()
 {
   _tree = new ItemsList();
   TreeItem item = new TreeItem("Name", "First item");
   CreateChildren(item, 2, 3);
   _tree.Add(item);
   item = new TreeItem("Name", "Second item");
   CreateChildren(item, 2, 4);
   _tree.Add(item);
   item = new TreeItem("Name", "Third item");
   CreateChildren(item, 2, 5);
   _tree.Add(item);
 }
Exemplo n.º 24
0
        protected void UpdateDeviceList()
        {
            _deviceList.Clear();
            MappableDeviceItem noDeviceItem = new MappableDeviceItem("[Emulators.LibRetro.InputDevice.None]", null);

            _deviceList.Add(noDeviceItem);
            foreach (IMappableDevice device in _deviceProxy.GetDevices(true))
            {
                MappableDeviceItem deviceItem = new MappableDeviceItem(device.DeviceName, device);
                _deviceList.Add(deviceItem);
            }
            _deviceList.FireChange();
        }
Exemplo n.º 25
0
        protected void InitializeTree()
        {
            _tree = new ItemsList();
            TreeItem item = new TreeItem("Name", "First item");

            CreateChildren(item, 2, 3);
            _tree.Add(item);
            item = new TreeItem("Name", "Second item");
            CreateChildren(item, 2, 4);
            _tree.Add(item);
            item = new TreeItem("Name", "Third item");
            CreateChildren(item, 2, 5);
            _tree.Add(item);
        }
        ItemsList CreateLanguagesList()
        {
            var items   = new ItemsList();
            var allItem = new ListItem(Consts.KEY_NAME, "[OnlineVideos.All]");

            allItem.AdditionalProperties[Constants.KEY_VALUE] = null;
            items.Add(allItem);
            foreach (var lang in Sites.Updater.OnlineSites.Select(s => s.Language != null ? s.Language : "--").Distinct().Select(s => new { Code = s, Name = TranslationLoader.GetLocalizedLanguageName(s) }).OrderBy(s => s.Name))
            {
                var langItem = new ListItem(Consts.KEY_NAME, lang.Name);
                langItem.AdditionalProperties[Constants.KEY_VALUE] = lang.Code;
                items.Add(langItem);
            }
            return(items);
        }
        ItemsList CreateOwnersList()
        {
            var items   = new ItemsList();
            var allItem = new ListItem(Consts.KEY_NAME, "[OnlineVideos.All]");

            allItem.AdditionalProperties[Constants.KEY_VALUE] = null;
            items.Add(allItem);
            foreach (var owner in Sites.Updater.OnlineSites.Select(s => s.Owner_FK != null ? s.Owner_FK.Substring(0, s.Owner_FK.IndexOf('@')) : "").Distinct().OrderBy(s => s))
            {
                var ownerItem = new ListItem(Consts.KEY_NAME, owner);
                ownerItem.AdditionalProperties[Constants.KEY_VALUE] = owner;
                items.Add(ownerItem);
            }
            return(items);
        }
Exemplo n.º 28
0
        protected void AddScreen(WorkflowAction item, string prefix)
        {
            ListItem listItem = new ListItem(Consts.KEY_NAME, $"{LocalizationHelper.Translate(RES_SCREEN_TEXT)} \"{item.DisplayTitle}\"")
            {
                Command = new MethodDelegateCommand(() => ChooseKeyAction(prefix + item.Name))
            };

            listItem.SetLabel(KEY_KEYMAP, "");
            listItem.SetLabel(KEY_KEYMAP_NAME, item.DisplayTitle);
            listItem.AdditionalProperties[KEY_KEYMAP_DATA] = prefix + item.Name;
            if (!_items.Any(i => string.Compare((string)i.AdditionalProperties[KEY_KEYMAP_DATA], (string)listItem.AdditionalProperties[KEY_KEYMAP_DATA], true) == 0))
            {
                _items.Add(listItem);
            }
        }
Exemplo n.º 29
0
        protected virtual void ShowProgramActions(IProgram program)
        {
            if (program == null)
            {
                return;
            }

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

            ItemsList actions = new ItemsList();

            // if program is over already, there is nothing to do.
            if (program.EndTime < DateTime.Now)
            {
                actions.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)
                {
                    actions.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)
                    {
                        if (isRunning && result.Result != RecordingStatus.None)
                        {
                            actions.Add(
                                new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.WatchFromBeginning]"))
                            {
                                Command = new AsyncMethodDelegateCommand(() => _tvHandler.WatchRecordingFromBeginningAsync(program))
                            });
                        }

                        AddRecordingOptions(actions, program, result.Result);
                    }
                }
            }
            SlimTvExtScheduleModel.ShowDialog("[SlimTvClient.ChooseProgramAction]", actions);
        }
Exemplo n.º 30
0
        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();
        }
        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();
        }
Exemplo n.º 32
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());
        }
Exemplo n.º 33
0
 void showContext()
 {
     ItemsList items = new ItemsList();
     items.Add(new ListItem(Consts.KEY_NAME, "[Emulators.Config.Edit]")
     {
         Command = new MethodDelegateCommand(() => ConfigureEmulatorModel.EditEmulator(emulator))
     });
     ListDialogModel.Instance().ShowDialog(emulator.Title, items);
 }
 public PlatformSelectModel()
 {
     items = new ItemsList();
     var platforms = Dropdowns.GetPlatformList();
     for (int i = -1; i < platforms.Count; i++)
     {
         string platformName = i < 0 ? "" : platforms[i].Name;
         ListItem item = new ListItem(Consts.KEY_NAME, platformName)
         {
             Command = new MethodDelegateCommand(() => UpdatePlatform(platformName))
         };
         item.AdditionalProperties[KEY_PLATFORM] = platformName;
         items.Add(item);
     }
 }
        ItemsList CreatePossibleValuesList()
        {
            var result = new ItemsList();
            if (PropertyDescriptor.IsBool)
            {
                var item = new ListItem(Consts.KEY_NAME, new StringId("[System.Yes]")) { Selected = Value == true.ToString() };
                item.AdditionalProperties.Add(KEY_VALUE, true.ToString());
                result.Add(item);

                item = new ListItem(Consts.KEY_NAME, new StringId("[System.No]")) { Selected = Value == false.ToString() };
                item.AdditionalProperties.Add(KEY_VALUE, false.ToString());
                result.Add(item);
            }
            else if (PropertyDescriptor.IsEnum)
            {
                foreach (string e in PropertyDescriptor.GetEnumValues())
                {
                    var item = new ListItem(Consts.KEY_NAME, e) { Selected = Value == e };
                    item.AdditionalProperties.Add(KEY_VALUE, e);
                    result.Add(item);
                }
            }
            return result;
        }
Exemplo n.º 36
0
 public ViewModeModel()
 {
     startupItems = new ItemsList();
     var startupStates = StartupStateSetting.StartupStates;
     foreach (string key in startupStates.Keys)
     {
         StartupState state = startupStates[key];
         if (state != StartupState.LASTUSED)
         {
             ListItem item = new ListItem(Consts.KEY_NAME, LocalizationHelper.CreateResourceString(key))
             {
                 Command = new MethodDelegateCommand(() => SetStartupState(state))
             };
             item.AdditionalProperties[KEY_STARTUP_STATE] = state;
             startupItems.Add(item);
         }
     }
 }
Exemplo n.º 37
0
        protected ItemsList GetItems()
        {
            var model = EmulatorsMainModel.Instance();
            StartupState currentState = model.StartupState;

            bool showPC = Emulator.GetPC().Games.Count > 0;
            if (!showPC && currentState == StartupState.PCGAMES)
                currentState = StartupState.EMULATORS;

            ItemsList items = new ItemsList();
            foreach (ListItem item in startupItems)
            {
                StartupState state;
                if (tryGetStartupState(item.AdditionalProperties, out state))
                {
                    if (state != StartupState.PCGAMES || showPC)
                    {
                        item.Selected = (StartupState)state == currentState;
                        items.Add(item);
                    }
                }
            }
            return items;
        }
Exemplo n.º 38
0
 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();
 }
Exemplo n.º 39
0
 protected void AddResources(IEnumerable<ResourcePathMetadata> resources, ItemsList items)
 {
   List<ResourcePathMetadata> resourcesMetadata = new List<ResourcePathMetadata>(resources);
   resourcesMetadata.Sort((a, b) => a.ResourceName.CompareTo(b.ResourceName));
   foreach (ResourcePathMetadata resourceMetadata in resourcesMetadata)
   {
     TreeItem directoryItem = new TreeItem(Consts.KEY_NAME, resourceMetadata.ResourceName);
     directoryItem.AdditionalProperties[Consts.KEY_RESOURCE_PATH] = resourceMetadata.ResourcePath;
     directoryItem.SetLabel(Consts.KEY_PATH, resourceMetadata.HumanReadablePath);
     if (ChoosenResourcePath == resourceMetadata.ResourcePath)
       directoryItem.Selected = true;
     directoryItem.SelectedProperty.Attach(OnTreePathSelectionChanged);
     directoryItem.AdditionalProperties[Consts.KEY_EXPANSION] = new ExpansionHelper(directoryItem, this);
     items.Add(directoryItem);
   }
 }
Exemplo n.º 40
0
    protected 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 MethodDelegateCommand(() =>
                    {
                      IChannel channel;
                      if (_tvHandler.ProgramInfo.GetChannel(program, out channel))
                        _tvHandler.StartTimeshift(PlayerContextIndex.PRIMARY, channel);
                    })
              });
        }

        if (_tvHandler.ScheduleControl != null)
        {
          RecordingStatus recordingStatus;
          if (_tvHandler.ScheduleControl.GetRecordingStatus(program, out recordingStatus) && recordingStatus != RecordingStatus.None)
          {
            _programActions.Add(
              new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.DeleteSchedule]"))
                {
                  Command = new MethodDelegateCommand(() =>
                                                        {
                                                          if (_tvHandler.ScheduleControl.RemoveSchedule(program))
                                                            UpdateRecordingStatus(program, RecordingStatus.None);
                                                        }
                    )
                });
          }
          else
          {
            _programActions.Add(
              new ListItem(Consts.KEY_NAME, loc.ToString(isRunning ? "[SlimTvClient.RecordNow]" : "[SlimTvClient.CreateSchedule]"))
                {
                  Command = new MethodDelegateCommand(() =>
                                                        {
                                                          if (_tvHandler.ScheduleControl.CreateSchedule(program))
                                                            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);
    }
Exemplo n.º 41
0
    protected void UpdateSystemsList_NoLock()
    {
      lock (_syncObj)
      {
        _systemsList = new ItemsList();

        if (_enableLocalShares)
        {
          ListItem localSystemItem = new ListItem(Consts.KEY_NAME, Consts.RES_SHARES_CONFIG_LOCAL_SHARE);
          localSystemItem.AdditionalProperties[Consts.KEY_SHARES_PROXY] = new LocalShares();
          localSystemItem.SelectedProperty.Attach(OnSystemSelectionChanged);
          _systemsList.Add(localSystemItem);
        }

        if (_enableServerShares)
        {
          ListItem serverSystemItem = new ListItem(Consts.KEY_NAME, Consts.RES_SHARES_CONFIG_GLOBAL_SHARE);
          serverSystemItem.AdditionalProperties[Consts.KEY_SHARES_PROXY] = new ServerShares();
          serverSystemItem.SelectedProperty.Attach(OnSystemSelectionChanged);
          _systemsList.Add(serverSystemItem);
        }

        if (_systemsList.Count > 0)
          _systemsList[0].Selected = true;
      }
      _systemsList.FireChange();
    }
        protected ItemsList GetProgramsList(IChannel channel, DateTime referenceStart, DateTime referenceEnd)
        {
            ItemsList channelPrograms = new ItemsList();
              if (_tvHandler.ProgramInfo.GetPrograms(channel, referenceStart, referenceEnd, out _programs))
              {
            foreach (IProgram program in _programs)
            {
              // Use local variable, otherwise delegate argument is not fixed
              ProgramProperties programProperties = new ProgramProperties(GuideStartTime, GuideEndTime);
              IProgram currentProgram = program;
              programProperties.SetProgram(currentProgram);

              ProgramListItem item = new ProgramListItem(programProperties)
                                   {
                                     Command = new MethodDelegateCommand(() => ShowProgramActions(currentProgram))
                                   };
              item.AdditionalProperties["PROGRAM"] = currentProgram;

              channelPrograms.Add(item);
            }
              }
              else
            channelPrograms.Add(NoProgramPlaceholder());
              return channelPrograms;
        }
Exemplo n.º 43
0
    protected void UpdatePlayModes()
    {
      _playModeItems = new ItemsList();
      ListItem continuousItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAYMODE_CONTINUOUS)
        {
            Command = new MethodDelegateCommand(() => SetPlayMode(PlayMode.Continuous))
        };
      continuousItem.AdditionalProperties[Consts.KEY_PLAYMODE] = PlayMode.Continuous;
      _playModeItems.Add(continuousItem);

      ListItem shuffleItem = new ListItem(Consts.KEY_NAME, Consts.RES_PLAYMODE_SHUFFLE)
        {
            Command = new MethodDelegateCommand(() => SetPlayMode(PlayMode.Shuffle))
        };
      shuffleItem.AdditionalProperties[Consts.KEY_PLAYMODE] = PlayMode.Shuffle;
      _playModeItems.Add(shuffleItem);
    }
Exemplo n.º 44
0
    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();
    }
Exemplo n.º 45
0
 private static void CreateProgramListItem(IProgram program, ItemsList channelPrograms)
 {
     ProgramListItem item;
       if (program == null)
     item = GetNoProgramPlaceholder();
       else
       {
     ProgramProperties programProperties = new ProgramProperties();
     programProperties.SetProgram(program);
     item = new ProgramListItem(programProperties);
       }
       item.AdditionalProperties["PROGRAM"] = program;
       channelPrograms.Add(item);
 }
Exemplo n.º 46
0
		ItemsList CreateContextMenuEntries()
		{
			var site = OnlineVideoSettings.Instance.SiteUtilsList[SiteName];
			var ctxEntries = new ItemsList();
			if (VideoInfo != null)
			{
                if (SiteUtilName != "DownloadedVideo" && (IsDetailsVideo || !(VideoInfo.HasDetails & site is Sites.IChoice)))
				{
					ctxEntries.Add(
						new ListItem(Consts.KEY_NAME, string.Format("{0} ({1})", Translation.Instance.Download, Translation.Instance.Concurrent))
						{
							Command = new MethodDelegateCommand(() => DownloadConcurrent())
						});
					ctxEntries.Add(
						new ListItem(Consts.KEY_NAME, string.Format("{0} ({1})", Translation.Instance.Download, Translation.Instance.Queued))
						{
							Command = new MethodDelegateCommand(() => DownloadQueued())
						});
				}
				foreach (var entry in site.GetContextMenuEntries(Category, VideoInfo))
				{
					var entry_for_closure = entry;
					var item = new ListItem(Consts.KEY_NAME, entry.DisplayText);
					item.Command = new MethodDelegateCommand(() => HandleCustomContextMenuEntry(entry_for_closure));
					ctxEntries.Add(item);
				}
			}
			return ctxEntries;
		}
Exemplo n.º 47
0
		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;
			}
		}
Exemplo n.º 48
0
		public void ChoosePlaybackOptions(string defaultUrl, Action<string> resultHandler, bool skipDialog = false)
		{
			// with no options set, return the VideoUrl field
			if (VideoInfo.PlaybackOptions == null || VideoInfo.PlaybackOptions.Count == 0)
				resultHandler(defaultUrl);
			// with just one option set, resolve it and call handler
			else if (VideoInfo.PlaybackOptions.Count == 1)
			{
				BackgroundTask.Instance.Start<string>(
					() =>
					{
						return VideoInfo.GetPlaybackOptionUrl(VideoInfo.PlaybackOptions.First().Key);
					},
					(success, url) =>
					{
						if (success)
							resultHandler(url);
					},
					Translation.Instance.GettingPlaybackUrlsForVideo);
			}
			else
			{
				if (skipDialog)
				{
					var defaultOption = VideoInfo.PlaybackOptions.FirstOrDefault(p => p.Value == defaultUrl).Key;
					if (string.IsNullOrEmpty(defaultOption)) defaultOption = VideoInfo.PlaybackOptions.First().Key;
					BackgroundTask.Instance.Start<string>(
						() =>
						{
							return VideoInfo.GetPlaybackOptionUrl(defaultOption);
						},
						(success, url) =>
						{
							if (success)
								resultHandler(url);
						},
						Translation.Instance.GettingPlaybackUrlsForVideo);
				}
				else
				{
					var playbackOptionsItems = new ItemsList();
					foreach (var item in VideoInfo.PlaybackOptions)
					{
						var listItem = new ListItem(Consts.KEY_NAME, item.Key);
						listItem.AdditionalProperties.Add(Constants.KEY_HANDLER, resultHandler);
						listItem.Selected = item.Value == defaultUrl;
						playbackOptionsItems.Add(listItem);
					}

					ServiceRegistration.Get<IWorkflowManager>().NavigatePushTransient(
						WorkflowState.CreateTransientState("PlaybackOptions", VideoInfo.Title, true, "ovsDialogGenericItems", false, WorkflowType.Dialog),
						new NavigationContextConfig()
						{
							AdditionalContextVariables = new Dictionary<string, object>
						{
							{ Constants.CONTEXT_VAR_ITEMS, playbackOptionsItems },
							{ Constants.CONTEXT_VAR_COMMAND, new CommandContainer<ListItem>(SelectPlaybackOption) }
						}
						});
				}
			}
		}
 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();
 }
Exemplo n.º 50
0
    protected 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 MethodDelegateCommand(() =>
                    {
                      IChannel channel;
                      if (_tvHandler.ProgramInfo.GetChannel(program, out channel))
                      {
                        IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
                        SlimTvClientModel model = workflowManager.GetModel(SlimTvClientModel.MODEL_ID) as SlimTvClientModel;
                        if (model != null)
                        {
                          model.Tune(channel);
                          // Always switch to fullscreen
                          workflowManager.NavigatePush(Consts.WF_STATE_ID_FULLSCREEN_VIDEO);
                        }
                      }
                    })
              });
        }

        if (_tvHandler.ScheduleControl != null)
        {
          RecordingStatus recordingStatus;
          if (_tvHandler.ScheduleControl.GetRecordingStatus(program, out recordingStatus) && recordingStatus != RecordingStatus.None)
          {
            if (isRunning)
              _programActions.Add(
                new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.WatchFromBeginning]"))
                  {
                    Command = new MethodDelegateCommand(() => _tvHandler.WatchRecordingFromBeginning(program))
                  });

            _programActions.Add(
              new ListItem(Consts.KEY_NAME, loc.ToString(isRunning ? "[SlimTvClient.StopCurrentRecording]" : "[SlimTvClient.DeleteSchedule]", program.Title))
                {
                  Command = new MethodDelegateCommand(() =>
                                                        {
                                                          if (_tvHandler.ScheduleControl.RemoveScheduleForProgram(program, ScheduleRecordingType.Once))
                                                            UpdateRecordingStatus(program, RecordingStatus.None);
                                                        }
                    )
                });
          }
          else
          {
            _programActions.Add(
              new ListItem(Consts.KEY_NAME, loc.ToString(isRunning ? "[SlimTvClient.RecordNow]" : "[SlimTvClient.CreateSchedule]"))
                {
                  Command = new MethodDelegateCommand(() =>
                                                        {
                                                          ISchedule schedule;
                                                          bool result;
                                                          // "No Program" placeholder
                                                          if (program.ProgramId == -1)
                                                            result = _tvHandler.ScheduleControl.CreateScheduleByTime(new Channel { ChannelId = program.ChannelId }, program.StartTime, program.EndTime, out schedule);
                                                          else
                                                            result = _tvHandler.ScheduleControl.CreateSchedule(program, ScheduleRecordingType.Once, out schedule);

                                                          if (result)
                                                            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);
    }
        protected 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 MethodDelegateCommand(() =>
                                                                {
                                                                  IChannel channel;
                                                                  if (_tvHandler.ProgramInfo.GetChannel(program, out channel))
                                                                    _tvHandler.StartTimeshift(PlayerManagerConsts.PRIMARY_SLOT, channel);
                                                                })
                                });
            }

            if (_tvHandler.ScheduleControl != null)
            {
              RecordingStatus recordingStatus;
              if (_tvHandler.ScheduleControl.GetRecordingStatus(program, out recordingStatus) && recordingStatus != RecordingStatus.None)
              {
            _programActions.Add(
              new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.DeleteSchedule]"))
                {
                  Command = new MethodDelegateCommand(() =>
                                                        {
                                                          if (_tvHandler.ScheduleControl.RemoveSchedule(program))
                                                            UpdateRecordingStatus(program, RecordingStatus.None);
                                                        }
                    )
                });
              }
              else
              {
            _programActions.Add(
              new ListItem(Consts.KEY_NAME, loc.ToString(isRunning ? "[SlimTvClient.RecordNow]" : "[SlimTvClient.CreateSchedule]"))
                {
                  Command = new MethodDelegateCommand(() =>
                                                        {
                                                          if (_tvHandler.ScheduleControl.CreateSchedule(program))
                                                            UpdateRecordingStatus(program, RecordingStatus.Scheduled);
                                                        }
                    )
                });
              }
            }
              }
              IScreenManager screenManager = ServiceRegistration.Get<IScreenManager>();
              screenManager.ShowDialog(_programActionsDialogName);
        }
Exemplo n.º 52
0
 public static void ShowLoadThemeDialog()
 {
   IScreenManager screenManager = ServiceRegistration.Get<IScreenManager>();
   SkinManager skinManager = ServiceRegistration.Get<ISkinResourceManager>() as SkinManager;
   if (skinManager == null)
     return;
   string currentSkinName = screenManager.CurrentSkinResourceBundle.SkinName;
   Skin currentSkin;
   if (!skinManager.Skins.TryGetValue(currentSkinName, out currentSkin))
     return;
   ItemsList themeItems = new ItemsList();
   foreach (Theme theme in currentSkin.Themes.Values)
   {
     if (!theme.IsValid)
       continue;
     string themeName = theme.Name;
     ListItem themeItem = new ListItem(Consts.KEY_NAME, themeName)
       {
           Command = new MethodDelegateCommand(() => screenManager.SwitchSkinAndTheme(null, themeName))
       };
     themeItems.Add(themeItem);
   }
   ShowDialog(Consts.RES_LOAD_THEME_TITLE, themeItems);
 }
Exemplo n.º 53
0
        void contextCommandDelegate()
        {
            Importer importer = ServiceRegistration.Get<IEmulatorsService>().Importer;
            RomMatchStatus status = romMatch.Status;
            ItemsList items = new ItemsList();
            if ((status == RomMatchStatus.Approved || status == RomMatchStatus.NeedsInput) && romMatch.PossibleGameDetails != null && romMatch.PossibleGameDetails.Count > 0)
            {
                items.Add(new ListItem(Consts.KEY_NAME, "[Emulators.Import.Approve]")
                {
                    Command = new MethodDelegateCommand(() => { importer.Approve(romMatch); })
                });
            }

            items.Add(new ListItem(Consts.KEY_NAME, "[Emulators.Import.ManualSearch]")
            {
                Command = new MethodDelegateCommand(() => 
                {
                    TextInputModel.Instance().ShowDialog("[Emulators.Import.Search]", romMatch.Filename, "[Emulators.Import.Search]", t => 
                    {
                        if (t != romMatch.SearchTitle)
                        {
                            romMatch.SearchTitle = t;
                            importer.ReProcess(romMatch);
                        }
                    });
                })
            });

            items.Add(new ListItem(Consts.KEY_NAME, "[Emulators.Import.AddAsBlankGame]")
            {
                Command = new MethodDelegateCommand(() => { importer.Ignore(romMatch); })
            });

            items.Add(new ListItem(Consts.KEY_NAME, "[Emulators.Import.Delete]")
            {
                Command = new MethodDelegateCommand(() => 
                {
                    Game game = romMatch.Game;
                    foreach (GameDisc disc in game.Discs)
                        EmulatorsCore.Options.AddIgnoreFile(disc.Path);
                    game.Delete();
                })
            });

            ListDialogModel.Instance().ShowDialog(romMatch.Filename, items);
        }
Exemplo n.º 54
0
    protected void FillChannelGroupList()
    {
      if (_channelGroups == null)
        return;

      _channelGroupList = new ItemsList();
      for (int idx = 0; idx < _channelGroups.Count; idx++)
      {
        IChannelGroup group = _channelGroups[idx];
        int selIdx = idx;
        ListItem channelGroupItem = new ListItem(UiComponents.Media.General.Consts.KEY_NAME, group.Name)
        {
          Command = new MethodDelegateCommand(() => SetGroup(selIdx)),
          Selected = selIdx == _webChannelGroupIndex
        };
        _channelGroupList.Add(channelGroupItem);
      }
      _channelGroupList.FireChange();
    }
Exemplo n.º 55
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;
    }
Exemplo n.º 56
0
        protected 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.
            if (DateTime.Now >= program.StartTime && DateTime.Now <= program.EndTime)
            {
              _programActions.Add(new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.WatchNow]"))
                                {
                                  Command =
                                    new MethodDelegateCommand(() =>
                                    {
                                      IChannel channel;
                                      if (_tvHandler.ProgramInfo.GetChannel(program, out channel))
                                        _tvHandler.StartTimeshift(PlayerManagerConsts.PRIMARY_SLOT, channel);
                                    })
                                });
            }
            //TODO: define and implement recording info interfaces, add code again
            //if (program.IsRecording || program.IsRecordingOncePending || program.IsRecordingSeriesPending)
            //{
            //  _programActions.Add(
            //    new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.DeleteSchedule]"))
            //      {
            //        Command = new MethodDelegateCommand(() => _tvServer.TvServer.CancelSchedule(programId))
            //      });
            //}
            //else
            //{
            //  _programActions.Add(
            //    new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.CreateSchedule]"))
            //      {
            //        Command = new MethodDelegateCommand(() =>
            //                                            _tvServer.TvServer.AddSchedule(_channelID, program.Title,
            //                                                                           program.StartTime, program.EndTime, 0))
            //      });
            //}
              }
              IScreenManager screenManager = ServiceRegistration.Get<IScreenManager>();
              screenManager.ShowDialog(_programActionsDialogName);
        }
Exemplo n.º 57
0
 protected void UpdateSharesList_NoLock(bool create)
 {
   lock (_syncObj)
     if (create)
       _sharesList = new ItemsList();
     else
       _sharesList.Clear();
   try
   {
     IServerConnectionManager scm = ServiceRegistration.Get<IServerConnectionManager>();
     IContentDirectory cd = scm.ContentDirectory;
     IServerController sc = scm.ServerController;
     if (cd == null || sc == null)
       return;
     IRemoteResourceInformationService rris = ServiceRegistration.Get<IRemoteResourceInformationService>();
     ICollection<Share> allShares = cd.GetShares(null, SharesFilter.All);
     IDictionary<string, ICollection<Share>> systems2Shares = new Dictionary<string, ICollection<Share>>();
     foreach (Share share in allShares)
     {
       ICollection<Share> systemShares;
       if (systems2Shares.TryGetValue(share.SystemId, out systemShares))
         systemShares.Add(share);
       else
         systems2Shares[share.SystemId] = new List<Share> { share };
     }
     ICollection<Guid> importingShares = cd.GetCurrentlyImportingShares() ?? new List<Guid>();
     ICollection<string> onlineSystems = sc.GetConnectedClients();
     onlineSystems = onlineSystems == null ? new List<string> { scm.HomeServerSystemId } : new List<string>(onlineSystems) { scm.HomeServerSystemId };
     foreach (KeyValuePair<string, ICollection<Share>> system2Shares in systems2Shares)
     {
       string systemId = system2Shares.Key;
       ICollection<Share> systemShares = system2Shares.Value;
       string systemName;
       string hostName;
       if (systemId == scm.HomeServerSystemId)
       {
         systemName = scm.LastHomeServerName;
         hostName = scm.LastHomeServerSystem.HostName;
       }
       else
       {
         MPClientMetadata clientMetadata = ServerCommunicationHelper.GetClientMetadata(systemId);
         if (clientMetadata == null)
         {
           systemName = null;
           hostName = null;
         }
         else
         {
           systemName = clientMetadata.LastClientName;
           hostName = clientMetadata.LastSystem.HostName;
         }
       }
       ListItem systemSharesItem = new ListItem(Consts.KEY_NAME, systemName);
       systemSharesItem.AdditionalProperties[Consts.KEY_SYSTEM] = systemId;
       systemSharesItem.AdditionalProperties[Consts.KEY_HOSTNAME] = hostName;
       bool isConnected = onlineSystems.Contains(systemId);
       systemSharesItem.AdditionalProperties[Consts.KEY_IS_CONNECTED] = isConnected;
       ItemsList sharesItemsList = new ItemsList();
       foreach (Share share in systemShares)
       {
         ListItem shareItem = new ListItem(Consts.KEY_NAME, share.Name);
         shareItem.AdditionalProperties[Consts.KEY_SHARE] = share;
         string resourcePathName;
         try
         {
           bool isFileSystemResource;
           bool isFile;
           string resourceName;
           DateTime lastChanged;
           long size;
           if (!rris.GetResourceInformation(share.SystemId, share.BaseResourcePath, out isFileSystemResource, out isFile, out resourcePathName, out resourceName, out lastChanged, out size))
             // Error case: The path is invalid
             resourcePathName = LocalizationHelper.Translate(Consts.RES_INVALID_PATH, share.BaseResourcePath);
         }
         catch (Exception) // NotConnectedException when remote system is not connected at all, UPnPDisconnectedException when remote system gets disconnected during the call
         {
           resourcePathName = share.BaseResourcePath.ToString();
         }
         shareItem.SetLabel(Consts.KEY_PATH, resourcePathName);
         string categories = StringUtils.Join(", ", share.MediaCategories);
         shareItem.SetLabel(Consts.KEY_MEDIA_CATEGORIES, categories);
         UpdateShareImportState_NoLock(shareItem, importingShares.Contains(share.ShareId));
         Share shareCopy = share;
         shareItem.Command = new MethodDelegateCommand(() => ReImportShare(shareCopy));
         shareItem.AdditionalProperties[Consts.KEY_REIMPORT_ENABLED] = isConnected;
         sharesItemsList.Add(shareItem);
       }
       systemSharesItem.AdditionalProperties[Consts.KEY_SYSTEM_SHARES] = sharesItemsList;
       lock (_syncObj)
         _sharesList.Add(systemSharesItem);
     }
   }
   finally
   {
     _sharesList.FireChange();
   }
 }
Exemplo n.º 58
0
    protected void UpdateRepeatModes()
    {
      _repeatModeItems = new ItemsList();
      ListItem noneItem = new ListItem(Consts.KEY_NAME, Consts.RES_REPEATMODE_NONE)
        {
            Command = new MethodDelegateCommand(() => SetRepeatMode(RepeatMode.None))
        };
      noneItem.AdditionalProperties[Consts.KEY_REPEATMODE] = RepeatMode.None;
      _repeatModeItems.Add(noneItem);

      ListItem allItem = new ListItem(Consts.KEY_NAME, Consts.RES_REPEATMODE_ALL)
        {
            Command = new MethodDelegateCommand(() => SetRepeatMode(RepeatMode.All))
        };
      allItem.AdditionalProperties[Consts.KEY_REPEATMODE] = RepeatMode.All;
      _repeatModeItems.Add(allItem);

      ListItem oneItem = new ListItem(Consts.KEY_NAME, Consts.RES_REPEATMODE_ONE)
        {
            Command = new MethodDelegateCommand(() => SetRepeatMode(RepeatMode.One))
        };
      oneItem.AdditionalProperties[Consts.KEY_REPEATMODE] = RepeatMode.One;
      _repeatModeItems.Add(oneItem);
    }
Exemplo n.º 59
0
 public static void ShowLoadSkinDialog()
 {
   IScreenManager screenManager = ServiceRegistration.Get<IScreenManager>();
   SkinManager skinManager = ServiceRegistration.Get<ISkinResourceManager>() as SkinManager;
   if (skinManager == null)
     return;
   ItemsList skinItems = new ItemsList();
   foreach (Skin skin in skinManager.Skins.Values)
   {
     if (!skin.IsValid)
       continue;
     string skinName = skin.Name;
     ListItem skinItem = new ListItem(Consts.KEY_NAME, skinName)
       {
           Command = new MethodDelegateCommand(() => screenManager.SwitchSkinAndTheme(skinName, null))
       };
     skinItems.Add(skinItem);
   }
   ShowDialog(Consts.RES_LOAD_SKIN_TITLE, skinItems);
 }
Exemplo n.º 60
0
 /// <summary>
 /// Adds all supported settings in the specified <paramref name="sectionOrGroupNode"/> to the specified
 /// <paramref name="settingsList"/>. For each setting, a <see cref="ListItem"/> will be created
 /// with the setting text as name and a command which triggers the method <see cref="ShowConfigItem"/>
 /// with the according setting location.
 /// </summary>
 /// <param name="sectionOrGroupNode">Section or group node, whose contained settings should be added.</param>
 /// <param name="settingsList">List where the extracted settings will be added to.</param>
 protected void AddConfigSettings(IConfigurationNode sectionOrGroupNode, ItemsList settingsList)
 {
   foreach (IConfigurationNode childNode in sectionOrGroupNode.ChildNodes)
   {
     if (childNode.ConfigObj is ConfigSetting)
     {
       ConfigSetting setting = (ConfigSetting) childNode.ConfigObj;
       if (!setting.Visible || !IsSettingSupported(setting))
         continue;
       string location = childNode.Location;
       ListItem item = new ListItem(KEY_NAME, setting.SettingMetadata.Text)
       {
           Command = new MethodDelegateCommand(() => ShowConfigItem(location))
       };
       item.SetLabel(KEY_HELPTEXT, setting.SettingMetadata.HelpText);
       item.Enabled = setting.Enabled;
       TrackItemVisibleEnabledProperty(setting.VisibleProperty);
       TrackItemVisibleEnabledProperty(setting.EnabledProperty);
       settingsList.Add(item);
     }
     if (childNode.ConfigObj is ConfigGroup)
       AddConfigSettings(childNode, settingsList);
   }
 }