Exemplo n.º 1
0
        /// <summary>
        /// Изменить выбранный м/ф и все связанные данные
        /// </summary>
        /// <param name="value">Конечное значение м/ф</param>
        private void ChangeSelectedCartoon(Cartoon value)
        {
            if (IsDesignTime)
            {
                _selectedCartoon = value;
                NotifyOfPropertyChange(() => SelectedCartoon);
                return;
            }

            CartoonIndexes.CurrentIndex = value == null
                                ? -1
                                : Cartoons.IndexOf(value);
            NotifyOfPropertyChange(() => CanSelectNextCartoon);
            NotifyOfPropertyChange(() => CanSelectPreviousCartoon);

            if (_selectedCartoon == value)
            {
                return;
            }

            IdList.CartoonId         = value?.CartoonId ?? 0;
            SelectedCartoonVoiceOver = null;
            ChangeSelectedSeason(null);


            if (value == null)
            {
                _selectedCartoon = null;
                NotifyCartoonData();
            }
            else
            {
                LoadData();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Загрузка из базы данных всех необходимых данных
        /// </summary>
        private void LoadData()
        {
            // --Начальная, когда ни один мульсериал не выбран
            if (_selectedCartoon == null)
            {
                LoadCartoonList();

                // --При загруженных с конструктора данных мультсериала
                if (IdList.CartoonId > 0)
                {
                    var tempId = 0;
                    if (_selectedCartoon != null)
                    {
                        tempId = _selectedCartoon.CartoonId;
                    }

                    _selectedCartoon = _cartoons.FirstOrDefault(c => c.CartoonId == IdList.CartoonId);

                    if (_selectedCartoon == null)
                    {
                        IdList.CartoonId = tempId;
                        _selectedCartoon = _cartoons.FirstOrDefault(c => c.CartoonId == IdList.CartoonId);
                    }

                    CartoonIndexes.CurrentIndex = Cartoons.IndexOf(_selectedCartoon);
                    LoadData();
                }
                else
                {
                    SelectedCartoon = _cartoons.FirstOrDefault();
                }

                NotifyCartoonData();
                return;
            }

            // --При выборе мультсериала
            if (_selectedSeason == null)
            {
                LoadCartoonVoiceOverList();
                LoadSeasonList();

                // установка значения выбранному мультфильму при смене его на другой
                _selectedCartoon            = _cartoons.FirstOrDefault(c => c.CartoonId == IdList.CartoonId);
                CartoonIndexes.CurrentIndex = Cartoons.IndexOf(_selectedCartoon);
                NotifyCartoonData();

                if (IdList.SeasonId > 0)
                {
                    var tempId = 0;
                    if (_selectedSeason != null)
                    {
                        tempId = _selectedSeason.CartoonSeasonId;
                    }

                    _selectedSeason = _seasons.FirstOrDefault(cs => cs.CartoonSeasonId == IdList.SeasonId);

                    if (_selectedSeason == null)
                    {
                        IdList.SeasonId = tempId;
                        _selectedSeason = _seasons.FirstOrDefault(cs => cs.CartoonSeasonId == IdList.SeasonId);
                    }

                    SeasonIndexes.CurrentIndex = Seasons.IndexOf(_selectedSeason);
                    LoadData();
                }
                else
                {
                    SelectedSeason = _seasons.FirstOrDefault();
                }

                NotifySeasonData();
                return;
            }

            // --При выборе сезона
            if (_selectedEpisode == null)
            {
                LoadEpisodeList();

                _selectedSeason            = _seasons.FirstOrDefault(cs => cs.CartoonSeasonId == IdList.SeasonId);
                SeasonIndexes.CurrentIndex = Seasons.IndexOf(_selectedSeason);
                NotifySeasonData();

                if (IdList.EpisodeId > 0)
                {
                    var tempId = 0;
                    if (_selectedEpisode != null)
                    {
                        tempId = _selectedEpisode.CartoonEpisodeId;
                    }

                    _selectedEpisode = _episodes.FirstOrDefault(ce => ce.CartoonEpisodeId == IdList.EpisodeId);

                    if (_selectedEpisode == null)
                    {
                        IdList.EpisodeId = tempId;
                        _selectedEpisode = _episodes.FirstOrDefault(ce => ce.CartoonEpisodeId == IdList.EpisodeId);
                    }

                    EpisodeIndexes.CurrentIndex = Episodes.IndexOf(_selectedEpisode);
                    LoadData();
                }
                else
                {
                    SelectedEpisode = _episodes.FirstOrDefault();
                }

                NotifyEpisodeData();
                return;
            }

            // --При выборе эпизода
            LoadEpisodeVoiceOverList();
            _selectedEpisode            = _episodes.FirstOrDefault(ce => ce.CartoonEpisodeId == IdList.EpisodeId);
            EpisodeIndexes.CurrentIndex = Episodes.IndexOf(_selectedEpisode);
            NotifyEpisodeData();
        }