Ejemplo n.º 1
0
        public static ListCollectionView GetCategoriesView(OnlineVideosMainWindow window, IList <OnlineVideos.Category> categories, string preselectedCategoryName = null)
        {
            int?            indexToSelect       = null;
            List <Category> convertedCategories = new List <Category>();
            int             i = 0;

            if (categories != null)
            {
                foreach (var c in categories)
                {
                    if (preselectedCategoryName != null && c.Name == preselectedCategoryName)
                    {
                        indexToSelect = i;
                    }
                    convertedCategories.Add(new Category(c));
                    i++;
                }
            }
            ListCollectionView view = new ListCollectionView(convertedCategories)
            {
                Filter = new Predicate <object>(cat => (((Category)cat).Name ?? "").ToLower().Contains(window.CurrentFilter))
            };

            if (indexToSelect != null)
            {
                view.MoveCurrentToPosition(indexToSelect.Value);
            }
            return(view);
        }
Ejemplo n.º 2
0
        private void ReloadItems(bool isInitialLoad)
        {
            // Record the current item
            var currentItem = _listCollectionView.CurrentItem as ServerInfoViewModel;

            int?selectedIndex = null;

            if (isInitialLoad)
            {
                selectedIndex = 0;
            }
            else if (currentItem != null)
            {
                var index = Array.FindIndex(_servers.ToArray(), i => string.Equals(i.Id, currentItem.Server.Id));

                if (index != -1)
                {
                    selectedIndex = index;
                }
            }

            _listItems.Clear();

            _listItems.AddRange(_servers.Select(i => new ServerInfoViewModel()
            {
                Server = i
            }));

            if (selectedIndex.HasValue)
            {
                ListCollectionView.MoveCurrentToPosition(selectedIndex.Value);
            }
        }
Ejemplo n.º 3
0
        public ChangeCarParentDialog(CarObject car)
        {
            InitializeComponent();
            DataContext = this;

            Buttons = new[] {
                OkButton,
                CreateExtraDialogButton(ControlsStrings.CarParent_MakeIndependent, () => {
                    Car.ParentId = null;
                    Close();
                }),
                CancelButton
            };

            Car    = car;
            Filter = car.Brand == null ? "" : @"brand:" + car.Brand;

            CarsListView = new ListCollectionView(CarsManager.Instance.Loaded.Where(x => x.ParentId == null && x.Id != Car.Id).ToList())
            {
                CustomSort = this
            };

            UpdateFilter();
            if (car.Parent == null)
            {
                CarsListView.MoveCurrentToPosition(0);
            }
            else
            {
                CarsListView.MoveCurrentTo(car.Parent);
            }

            Closing += CarParentEditor_Closing;
        }
Ejemplo n.º 4
0
        public static ListCollectionView GetSitesView(OnlineVideosMainWindow window, string preselectedSiteName = null)
        {
            int?        indexToSelect  = null;
            List <Site> convertedSites = new List <Site>();
            int         i = 0;

            foreach (var s in OnlineVideos.OnlineVideoSettings.Instance.SiteUtilsList.Values)
            {
                if (preselectedSiteName != null && s.Settings.Name == preselectedSiteName)
                {
                    indexToSelect = i;
                }
                convertedSites.Add(new Site(s));
                i++;
            }
            ListCollectionView view = new ListCollectionView(convertedSites)
            {
                Filter = new Predicate <object>(s => ((ViewModels.Site)s).Name.ToLower().Contains(window.CurrentFilter)),
            };

            if (indexToSelect != null)
            {
                view.MoveCurrentToPosition(indexToSelect.Value);
            }
            return(view);
        }
Ejemplo n.º 5
0
        private void EnsureActiveStreamIsVisible()
        {
            var xxx             = _listItems.FirstOrDefault(i => i.IsActive);
            var activeItemIndex = _listItems.IndexOf(_listItems.FirstOrDefault(i => i.IsActive));

            Debug.WriteLine(String.Format("Ensure Active Stream is Visible {0} {1}", xxx.Name, activeItemIndex));
            _presentationManager.Window.Dispatcher.InvokeAsync(() => ListCollectionView.MoveCurrentToPosition(activeItemIndex));
        }
        private void Load(int POS)
        {
            //ListCollectionView zur übergebenen Postition
            List <Produkte> PListe = ctx.Produkte.ToList();

            ListCollectionView = new ListCollectionView(PListe);
            ListCollectionView.MoveCurrentToPosition(POS);
            ParentGrid.DataContext = ListCollectionView;
        }
Ejemplo n.º 7
0
 public CustomerListModel(List <Customer> data)
 {
     _data                      = data;
     _customers                 = (ListCollectionView)CollectionViewSource.GetDefaultView(_data);
     _customers.Filter          = FilterCustomers;
     _customers.CurrentChanged += CustomerChanged;
     _customers.CustomSort      = new CustomerSorter();
     _customers.MoveCurrentToPosition(-1);
 }
Ejemplo n.º 8
0
        private void RefreshTemplates()
        {
            try
            {
                var templates = _templateService.LoadTemplates(_localTemplateFolder);

                bool restore  = Templates != null;
                int  savedPos = 0;
                if (restore)
                {
                    Templates.CurrentChanged -= TemplatesOnCurrentChanged;
                    Templates.Filter          = null;

                    // Save state of ListCollectionView to restore later.
                    savedPos = Templates.CurrentPosition;
                }

                _templatesSource = new ObservableCollection <TemplateDialogViewModel>(templates.Select(t => TemplateDialogViewModel.CreateFrom(Container, t)));
                Templates        = new ListCollectionView(_templatesSource)
                {
                    Filter = TemplateFilter
                };
                Templates.CurrentChanged += TemplatesOnCurrentChanged;

                if (restore)
                {
                    if (Templates.Count > savedPos)
                    {
                        Templates.MoveCurrentToPosition(savedPos);
                    }
                }
                else if (Templates.Count > 0)
                {
                    Templates.MoveCurrentToPosition(0);
                }

                RefreshFrameworksFilter();
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 9
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            MyClass selectedItem = this.lb.SelectedItem as MyClass;
            int     index        = this.items.IndexOf(selectedItem);

            this.items[index] = new MyClass()
            {
                Name = "NewItem" + ctr++.ToString()
            };
            lcv.MoveCurrentToPosition(index);
        }
Ejemplo n.º 10
0
 internal void SetData(ObservableCollection <DataEntry> value)
 {
     _allDataEntries = new ObservableCollection <DataEntry>(value);
     _allDataEntries.Insert(0, _replaceAllDataEntries[0]);
     CollectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(_allDataEntries);
     if (_allDataEntries.Count > 0)
     {
         CollectionView.MoveCurrentToPosition(0);
     }
     RaisePropertyChanged(nameof(CollectionView));
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="mainViewModel">The primary view model of the program.</param>
        public ManageVotesWindow(MainViewModel mainViewModel)
        {
            InitializeComponent();

            MainViewModel = mainViewModel;

            MainViewModel.PropertyChanged += MainViewModel_PropertyChanged;

            // Create filtered, sortable views into the collection for display in the window.
            VoteView1 = new ListCollectionView(MainViewModel.AllVotesCollection);
            VoteView2 = new ListCollectionView(MainViewModel.AllVotesCollection);

            if (VoteView1.CanSort)
            {
                IComparer voteCompare = new CustomVoteSort();
                //IComparer voteCompare = StringComparer.InvariantCultureIgnoreCase;
                VoteView1.CustomSort = voteCompare;
                VoteView2.CustomSort = voteCompare;
            }

            if (VoteView1.CanFilter)
            {
                VoteView1.Filter = (a) => FilterVotes1(a.ToString());
                VoteView2.Filter = (a) => FilterVotes2(a.ToString());
            }

            // Initialize starting selected positions
            VoteView1.MoveCurrentToPosition(-1);
            VoteView2.MoveCurrentToFirst();


            // Create filtered views for display in the window.
            VoterView1 = new ListCollectionView(MainViewModel.AllVotersCollection);
            VoterView2 = new ListCollectionView(MainViewModel.AllVotersCollection);

            VoterView1.Filter = (a) => FilterVoters(VoteView1, a.ToString());
            VoterView2.Filter = (a) => FilterVoters(VoteView2, a.ToString());

            // Update the voters to match the votes.
            VoterView1.Refresh();
            VoterView2.Refresh();

            // Populate the context menu with known tasks.
            CreateContextMenuCommands();
            InitKnownTasks();
            UpdateContextMenu();

            // Set the data context for binding.
            DataContext = this;

            Filter1String = "";
            Filter2String = "";
        }
Ejemplo n.º 12
0
 public InventoryAreasViewModel()
 {
     InventoryAreaCollectionView = Application.Current.Resources["InventoryAreaCollectionView"] as ListCollectionView;
     InventoryAreaCollectionView.MoveCurrentToPosition(0);
     //InventoryAreaUIView = new List<InventoryContentsView>();
     //foreach (InventoryArea box in InventoryAreaCollectionView.SourceCollection as IList<InventoryArea>)
     //{
     //    InventoryContentsView boxview = new InventoryContentsView();
     //    boxview.DataContext = box;
     //    InventoryAreaUIView.Add(boxview);
     //}
 }
Ejemplo n.º 13
0
 internal void SetData(ObservableCollection <DataEntry> value)
 {
     if (_dataEntries == value)
     {
         return;
     }
     _dataEntries   = value;
     CollectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(_dataEntries);
     if (_dataEntries.Count > 0)
     {
         CollectionView.MoveCurrentToPosition(0);
     }
     RaisePropertyChanged(nameof(CollectionView));
 }
        public StationSelectorViewModel()
        {
            StationsView = new ListCollectionView(Environment.Stations);
            StationsView.MoveCurrentToPosition(-1); // No selection by default plz
            StationsView.CurrentChanged += (sender, e) => RaisePropertyChanged("SelectedStation");
            StationsView.SortDescriptions.Add(new SortDescription("Star.Name", ListSortDirection.Ascending));

            SelectAnyCommand     = new RelayCommand(SelectAny);
            SelectCurrentCommand = new RelayCommand(SelectCurrent, CanSelectCurrent);

            Environment.CurrentSituation.PropertyChanged += CurrentSituation_PropertyChanged;

            IsSelectAnyEnabled     = true;
            IsSelectCurrentEnabled = true;
        }
Ejemplo n.º 15
0
        private void SelectLineByIndex(int index)
        {
            if (diffLinesView == null)
            {
                return;
            }
            diffLinesView.MoveCurrentToPosition(index);
            if (presenter == null)
            {
                return;
            }
            var item = diffLinesView.GetItemAt(index);

            presenter.ScrollIntoView(item);
        }
Ejemplo n.º 16
0
        public DataSheetsHomeViewModel()
        {
            CommodityDetails = new CommodityDetailsViewModel();
            PlaceDetails     = new PlaceDetailsViewModel();

            CommoditiesView = new ListCollectionView(Environment.Commodities);
            CommoditiesView.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
            CommoditiesView.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            CommoditiesView.CurrentChanged += CommoditiesViewCurrentChanged;

            PlacesView = new ListCollectionView(Environment.Objects);
            PlacesView.GroupDescriptions.Add(new PropertyGroupDescription("Star"));
            PlacesView.SortDescriptions.Add(new SortDescription("Star.Name", ListSortDirection.Ascending));
            PlacesView.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            CommoditiesView.MoveCurrentToPosition(0);
            PlacesView.CurrentChanged += PlacesViewCurrentChanged;
        }
Ejemplo n.º 17
0
        private async void ReloadUsers(bool isInitialLoad)
        {
            // Record the current item
            var currentItem = _listCollectionView.CurrentItem as UserDtoViewModel;

            var apiClient = SessionManager.ActiveApiClient;

            try
            {
                var users = await apiClient.GetPublicUsersAsync();

                int?selectedIndex = null;

                if (isInitialLoad)
                {
                    selectedIndex = 0;
                }
                else if (currentItem != null)
                {
                    var index = Array.FindIndex(users, i => string.Equals(i.Id, currentItem.User.Id));

                    if (index != -1)
                    {
                        selectedIndex = index;
                    }
                }

                _listItems.Clear();

                _listItems.AddRange(users.Select(i => new UserDtoViewModel(apiClient, ImageManager, SessionManager)
                {
                    User = i
                }));

                if (selectedIndex.HasValue)
                {
                    ListCollectionView.MoveCurrentToPosition(selectedIndex.Value);
                }

                AddCustomEntries();
            }
            catch (Exception)
            {
                PresentationManager.ShowDefaultErrorMessage();
            }
        }
Ejemplo n.º 18
0
        /* コマンド、プロパティの定義にはそれぞれ
         *
         *  lvcom   : ViewModelCommand
         *  lvcomn  : ViewModelCommand(CanExecute無)
         *  llcom   : ListenerCommand(パラメータ有のコマンド)
         *  llcomn  : ListenerCommand(パラメータ有のコマンド・CanExecute無)
         *  lprop   : 変更通知プロパティ(.NET4.5ではlpropn)
         *
         * を使用してください。
         *
         * Modelが十分にリッチであるならコマンドにこだわる必要はありません。
         * View側のコードビハインドを使用しないMVVMパターンの実装を行う場合でも、ViewModelにメソッドを定義し、
         * LivetCallMethodActionなどから直接メソッドを呼び出してください。
         *
         * ViewModelのコマンドを呼び出せるLivetのすべてのビヘイビア・トリガー・アクションは
         * 同様に直接ViewModelのメソッドを呼び出し可能です。
         */

        /* ViewModelからViewを操作したい場合は、View側のコードビハインド無で処理を行いたい場合は
         * Messengerプロパティからメッセージ(各種InteractionMessage)を発信する事を検討してください。
         */

        /* Modelからの変更通知などの各種イベントを受け取る場合は、PropertyChangedEventListenerや
         * CollectionChangedEventListenerを使うと便利です。各種ListenerはViewModelに定義されている
         * CompositeDisposableプロパティ(LivetCompositeDisposable型)に格納しておく事でイベント解放を容易に行えます。
         *
         * ReactiveExtensionsなどを併用する場合は、ReactiveExtensionsのCompositeDisposableを
         * ViewModelのCompositeDisposableプロパティに格納しておくのを推奨します。
         *
         * LivetのWindowテンプレートではViewのウィンドウが閉じる際にDataContextDisposeActionが動作するようになっており、
         * ViewModelのDisposeが呼ばれCompositeDisposableプロパティに格納されたすべてのIDisposable型のインスタンスが解放されます。
         *
         * ViewModelを使いまわしたい時などは、ViewからDataContextDisposeActionを取り除くか、発動のタイミングをずらす事で対応可能です。
         */

        /* UIDispatcherを操作する場合は、DispatcherHelperのメソッドを操作してください。
         * UIDispatcher自体はApp.xaml.csでインスタンスを確保してあります。
         *
         * LivetのViewModelではプロパティ変更通知(RaisePropertyChanged)やDispatcherCollectionを使ったコレクション変更通知は
         * 自動的にUIDispatcher上での通知に変換されます。変更通知に際してUIDispatcherを操作する必要はありません。
         */

        public void Initialize()
        {
            // modelから情報の取得
            model          = new ExampleModel("Hello, world.");;
            ExampleMessage = model.Text;

            RevisionList revisions = new RevisionList();

            allCommits = revisions.GetAllCommentList();

            PendingCommits  = new ListCollectionView(revisions.GetPendingCommentList());
            BuildingCommits = new ListCollectionView(revisions.GetBuildingCommentList());
            FailureCommits  = new ListCollectionView(revisions.GetFailureCommentList());

            PendingCommits.MoveCurrentToPosition(-1);
            BuildingCommits.MoveCurrentToPosition(-1);
            FailureCommits.MoveCurrentToPosition(-1);
        }
Ejemplo n.º 19
0
        public void SetPositionTicks(long ticks)
        {
            var newIndex = 0;

            var chapters = Chapters.ToList();

            for (var i = 0; i < chapters.Count; i++)
            {
                if (ticks >= chapters[i].Chapter.StartPositionTicks)
                {
                    newIndex = i;
                }
                else
                {
                    break;
                }
            }

            ListCollectionView.MoveCurrentToPosition(newIndex);
        }
 public void Load(int pos)
 {
     //ListCollectionView zur übergebenen Postition
     LieferList  = ctx.Lieferer.ToList();
     displaylist = new ListCollectionView(ctx.Lieferer.ToList());
     displaylist.MoveCurrentToPosition(pos);
     ParentGrid.DataContext = displaylist;
     //Werte der ComboBox entsprechend anzeigen
     if (LieferList[pos].LAnsprechpartner.AnspAnrede == "Herr")
     {
         cobxcustomizeDelivererAAnrede.SelectedIndex = 0;
     }
     else if (LieferList[pos].LAnsprechpartner.AnspAnrede == "Frau")
     {
         cobxcustomizeDelivererAAnrede.SelectedIndex = 1;
     }
     else
     {
         cobxcustomizeDelivererAAnrede.SelectedIndex = 2;
     }
 }
 private void Load(int pos)
 {
     //Lasse das ListCollectionView an die übergebene Position gehen
     KundenListe = ctx.Kunde.ToList();
     displaylist = new ListCollectionView(ctx.Kunde.ToList());
     displaylist.MoveCurrentToPosition(pos);
     ParentGrid.DataContext = displaylist;
     //Combobox Werte entsprechend anzeigen
     if (KundenListe[pos].KAnsprechpartner.AnspAnrede == "Herr")
     {
         cobxcustomizeCustomerAAnrede.SelectedIndex = 0;
     }
     else if (KundenListe[pos].KAnsprechpartner.AnspAnrede == "Frau")
     {
         cobxcustomizeCustomerAAnrede.SelectedIndex = 1;
     }
     else
     {
         cobxcustomizeCustomerAAnrede.SelectedIndex = 2;
     }
 }
Ejemplo n.º 22
0
        private void ReloadList(BaseItemDto item)
        {
            if (item == null)
            {
                _listItems.Clear();
                return;
            }

            // Record the current item
            var currentItem = _listCollectionView.CurrentItem as ItemPersonViewModel;

            var people = item.People ?? new BaseItemPerson[] { };

            people = people.Where(i => i.HasPrimaryImage).ToArray();

            int?selectedIndex = null;

            if (currentItem != null)
            {
                var index = Array.FindIndex(people, i => string.Equals(i.Name, currentItem.Name, StringComparison.OrdinalIgnoreCase));

                if (index != -1)
                {
                    selectedIndex = index;
                }
            }

            _listItems.Clear();

            _listItems.AddRange(people.Select(i => new ItemPersonViewModel(i, _apiClient, _imageManager)
            {
                ImageWidth  = ImageWidth,
                ImageHeight = ImageHeight
            }));

            if (selectedIndex.HasValue)
            {
                ListCollectionView.MoveCurrentToPosition(selectedIndex.Value);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 選択中のモジュールを削除
        /// </summary>
        /// <param name="dataGrid"></param>
        private void DeleteModules(DataGrid dataGrid)
        {
            var currPos = _CollectionView.CurrentPosition;

            // モジュール数を編集した後に削除するとcurrPosが-1になる場合があるため、
            // ここで最初に選択されている表示上のモジュールの要素番号を取得する
            if (currPos == -1)
            {
                var cnt = 0;
                foreach (var module in _CollectionView.OfType <ModulesGridItem>())
                {
                    if (module.IsSelected)
                    {
                        currPos = cnt;
                        break;
                    }
                    cnt++;
                }
            }

            var items = CollectionViewSource.GetDefaultView(_CollectionView)
                        .Cast <ModulesGridItem>()
                        .Where(x => x.IsSelected);

            _ModulesInfo.Modules.RemoveRange(items);

            // 削除後に全部の選択状態を外さないと余計なものまで選択される
            foreach (var module in _ModulesInfo.Modules)
            {
                module.IsSelected = false;
            }

            // 選択行を設定
            if (currPos < 0)
            {
                // 先頭行を削除した場合
                _CollectionView.MoveCurrentToFirst();
            }
            else if (_CollectionView.Count <= currPos)
            {
                // 最後の行を消した場合、選択行を最後にする
                _CollectionView.MoveCurrentToLast();
            }
            else
            {
                // 中間行の場合
                _CollectionView.MoveCurrentToPosition(currPos);
            }

            // 再度選択
            if (_CollectionView.CurrentItem is ModulesGridItem item)
            {
                item.IsSelected = true;
            }

            // セルフォーカス
            if (dataGrid.CurrentCell.Column is not null)
            {
                CellFocusCommand?.Execute(new Tuple <DataGrid, int, int>(dataGrid, _CollectionView.CurrentPosition, dataGrid.CurrentCell.Column.DisplayIndex));
            }
        }
Ejemplo n.º 24
0
 public bool MoveCurrentToPosition(int position)
 {
     return(view.MoveCurrentToPosition(position));
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="mainViewModel">The primary view model of the program.</param>
        public ManageVotesWindow(ViewModel mainViewModel, IoCNavigationService navigationService, ILogger <ManageVotesWindow> logger)
        {
            this.mainViewModel     = mainViewModel;
            this.navigationService = navigationService;
            this.logger            = logger;

            InitializeComponent();

            this.mainViewModel.PropertyChanged += MainViewModel_PropertyChanged;

            // Create filtered, sortable views into the collection for display in the window.
            VoteView1 = new ListCollectionView(this.mainViewModel.AllVotesCollection);
            VoteView2 = new ListCollectionView(this.mainViewModel.AllVotesCollection);

            PropertyGroupDescription groupDescription = new PropertyGroupDescription("Category");

            VoteView1.GroupDescriptions.Add(groupDescription);
            VoteView2.GroupDescriptions.Add(groupDescription);

            if (VoteView1.CanSort && VoteView2.CanSort)
            {
                IComparer voteCompare = new CustomVoteSort();
                VoteView1.CustomSort = voteCompare;
                VoteView2.CustomSort = voteCompare;
            }

            if (VoteView1.CanFilter && VoteView2.CanFilter)
            {
                VoteView1.Filter = (a) => FilterVotes(Filter1String, a as VoteLineBlock);
                VoteView2.Filter = (a) => FilterVotes(Filter2String, a as VoteLineBlock);
            }

            // Initialize starting selected positions
            VoteView1.MoveCurrentToPosition(-1);
            VoteView2.MoveCurrentToFirst();


            // Create filtered views for display in the window.
            VoterView1 = new ListCollectionView(this.mainViewModel.AllVotersCollection);
            VoterView2 = new ListCollectionView(this.mainViewModel.AllVotersCollection);

            VoterView1.CustomSort = Comparer.Default;
            VoterView2.CustomSort = Comparer.Default;

            VoterView1.Filter = (a) => FilterVoters(VoteView1, a as Origin);
            VoterView2.Filter = (a) => FilterVoters(VoteView2, a as Origin);

            // Update the voters to match the votes.
            VoterView1.Refresh();
            VoterView2.Refresh();

            // Populate the context menu with known tasks.
            CreateContextMenuCommands();
            InitKnownTasks();
            UpdateContextMenu();

            // Set the data context for binding.
            DataContext = this;

            Filter1String = "";
            Filter2String = "";
        }
Ejemplo n.º 26
0
 public bool MoveCurrentToPosition(int position)
 {
     return(_collectionView.MoveCurrentToPosition(position));
 }
        private async Task ReloadItems(bool isInitialLoad)
        {
            if (HasIndexOptions && CurrentIndexOption == null)
            {
                return;
            }

            if (ShowLoadingAnimation)
            {
                _presentationManager.ShowLoadingAnimation();
            }

            try
            {
                var result = await _getItemsDelegate(this);

                var items = result.Items;

                int?selectedIndex = null;

                if (isInitialLoad && AutoSelectFirstItem)
                {
                    selectedIndex = 0;
                }

                MedianPrimaryImageAspectRatio = result.Items.MedianPrimaryImageAspectRatio();

                _listItems.Clear();

                var imageTypes = GetPreferredImageTypes();

                var childWidth         = Convert.ToInt32(ImageDisplayWidth);
                var imageDisplayHeight = Convert.ToInt32(GetImageDisplayHeight());

                var viewModels = items.Select(
                    i =>
                {
                    var vm = new ItemViewModel(_apiClient, _imageManager, _playbackManager,
                                               _presentationManager, _logger, _serverEvents)
                    {
                        DownloadPrimaryImageAtExactSize = DownloadImageAtExactSize ?? IsCloseToMedianPrimaryImageAspectRatio(i),
                        ImageHeight = imageDisplayHeight,
                        ImageWidth  = childWidth,
                        Item        = i,
                        ViewType    = ViewType,
                        DisplayName = DisplayNameGenerator == null ? i.Name : DisplayNameGenerator(i),
                        DownloadImagesAtExactSize = DownloadImageAtExactSize ?? true,
                        PreferredImageTypes       = imageTypes,
                        ListType  = ListType,
                        ShowTitle = ShowTitle
                    };

                    var stretch = ImageStretch;

                    if (!stretch.HasValue && imageTypes.Length > 0)
                    {
                        var exact = imageTypes[0] == ImageType.Primary ? vm.DownloadPrimaryImageAtExactSize : vm.DownloadImagesAtExactSize;
                        stretch   = exact ? Stretch.UniformToFill : Stretch.Uniform;
                    }

                    if (stretch.HasValue)
                    {
                        vm.ImageStretch = stretch.Value;
                    }

                    return(vm);
                }
                    ).ToList();

                _listItems.AddRange(viewModels);

                ItemCount = items.Length;

                UpdateContainerSizes();

                if (selectedIndex.HasValue)
                {
                    ListCollectionView.MoveCurrentToPosition(selectedIndex.Value);
                }
            }
            catch (Exception)
            {
                _presentationManager.ShowDefaultErrorMessage();
            }
            finally
            {
                if (ShowLoadingAnimation)
                {
                    _presentationManager.HideLoadingAnimation();
                }
            }
        }