public LibraryBrowserEntity()
		{
            Id = Guid.NewGuid();
            Query = new LibraryQuery();
			SubItems = new List<LibraryBrowserEntity>();
		    AlbumTitles = new List<string>();
		}
		/// <summary>
        /// Selects audio files from the song cache, filtered by different parameters.
        /// </summary>
        /// <param name="query">Song browser query</param>
        /// <returns>List of AudioFiles</returns>
        public IEnumerable<AudioFile> SelectAudioFiles(LibraryQuery query)
        {
            IEnumerable<AudioFile> queryAudioFiles = null;

            if (String.IsNullOrEmpty(query.OrderBy))
            {
                queryAudioFiles = from s in AudioFiles
                                  orderby s.ArtistName, s.AlbumTitle, s.FileType, s.DiscNumber, s.TrackNumber
                                  select s;
            }
            else
            {
                if (query.OrderByAscending)
                    queryAudioFiles = from s in AudioFiles
                                      orderby GetPropertyValue(s, query.OrderBy)
                                      select s;
                else
                    queryAudioFiles = from s in AudioFiles
                                      orderby GetPropertyValue(s, query.OrderBy) descending
                                      select s;                        
            }

            if (!String.IsNullOrEmpty(query.ArtistName))
                queryAudioFiles = queryAudioFiles.Where(s => s.ArtistName == query.ArtistName);                    

            if (!String.IsNullOrEmpty(query.AlbumTitle))
                queryAudioFiles = queryAudioFiles.Where(s => s.AlbumTitle == query.AlbumTitle);                    

            if (!String.IsNullOrEmpty(query.SearchTerms))
            {
                string[] searchTermsSplit = query.SearchTerms.Split(new string[] { " " }, StringSplitOptions.None);
                foreach (string searchTerm in searchTermsSplit)
                    queryAudioFiles = queryAudioFiles.Where(s => s.ArtistName.ToUpper().Contains(searchTerm.ToUpper()) ||
                                                                 s.AlbumTitle.ToUpper().Contains(searchTerm.ToUpper()) ||
                                                                 s.Title.ToUpper().Contains(searchTerm.ToUpper()));
            }

            if (query.Format != AudioFileFormat.All)
                queryAudioFiles = queryAudioFiles.Where(s => s.FileType == query.Format);

            return queryAudioFiles.ToList();
        }
Exemple #3
0
        public void AddTab(MobileNavigationTabType type, string title, MobileLibraryBrowserType browserType, LibraryQuery query, IBaseView view)
        {
            Console.WriteLine("MainActivity - Adding tab {0}", title);

            //_tabHistory.Add(new Tuple<MobileNavigationTabType, List<Tuple<MobileLibraryBrowserType, LibraryQuery>>>(type, new List<Tuple<MobileLibraryBrowserType, LibraryQuery>>() {
            //   new Tuple<MobileLibraryBrowserType, LibraryQuery>(browserType, query)
            //}));

            _fragment = (Fragment)view;
            FragmentTransaction transaction = FragmentManager.BeginTransaction();
            transaction.Replace(Resource.Id.main_fragmentContainer, _fragment);
            transaction.Commit();
        }
 public LibraryBrowserAppConfig()
 {
     Query = new LibraryQuery();
 }
        public virtual void BindMobileLibraryBrowserView(IMobileLibraryBrowserView view, MobileNavigationTabType tabType, MobileLibraryBrowserType browserType, LibraryQuery query)
        {
            var key = new Tuple<MobileNavigationTabType, MobileLibraryBrowserType>(tabType, browserType);
            view.OnViewDestroy = (view2) =>
            {
                // The view list can be accessed from different threads.
                lock (_locker)
                {
                    Tracing.Log("MobileNavigationManager - CreateMobileLibraryBrowserView - Destroying view - type: {0}", tabType.ToString());
                    if (_mobileLibraryBrowserList.ContainsKey(key))
                    {
                        _mobileLibraryBrowserList[key].Item2.ViewDestroyed();
                        _mobileLibraryBrowserList.Remove(key);
                    }
                }
            };

            lock (_locker)
            {
                var presenter = Bootstrapper.GetContainer().Resolve<IMobileLibraryBrowserPresenter>(new NamedParameterOverloads() { { "tabType", tabType }, { "browserType", browserType }, { "query", query } });
                presenter.BindView(view);
                _mobileLibraryBrowserList.Add(key, new Tuple<IMobileLibraryBrowserView, IMobileLibraryBrowserPresenter>(view, presenter));
            }
        }
        public virtual IMobileLibraryBrowserView CreateMobileLibraryBrowserView(MobileNavigationTabType tabType, MobileLibraryBrowserType browserType, LibraryQuery query)
        {
            var key = new Tuple<MobileNavigationTabType, MobileLibraryBrowserType>(tabType, browserType);
            
            // Check if view already exists
            if(_mobileLibraryBrowserList.ContainsKey(key))
            {
                Tuple<IMobileLibraryBrowserView, IMobileLibraryBrowserPresenter> viewPresenter;
                if (_mobileLibraryBrowserList.TryGetValue(key, out viewPresenter))
                {
                    if (viewPresenter != null)
                    {
                        viewPresenter.Item2.ChangeQuery(browserType, query);
                        return viewPresenter.Item1;
                    }
                }
            }

            var view = Bootstrapper.GetContainer().Resolve<IMobileLibraryBrowserView>(new NamedParameterOverloads() { { "tabType", tabType }, { "browserType", browserType }, { "query", query } });
            return view;
        }
 public MobileLibraryBrowserChangeQueryMessage(object sender, MobileLibraryBrowserType browserType, LibraryQuery query) 
     : base(sender)
 {
     BrowserType = browserType;
     Query = query;
 }       
Exemple #8
0
        public void AddTab(MobileNavigationTabType type, string title, MobileLibraryBrowserType browserType, LibraryQuery query, IBaseView view)
        {
			//Tracing.Log("MainViewController - AddTab - type: {0} title: {1} browserType: {2}", type, title, browserType);
            var appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate;
            appDelegate.AddTab(type, title, (UIViewController)view);
        }
Exemple #9
0
 public IEnumerable<AudioFile> SelectAudioFiles(LibraryQuery query)
 {
     return _gateway.SelectAudioFiles(query.Format, query.ArtistName, query.AlbumTitle, query.SearchTerms);
 }
 public MobileLibraryBrowserFragment(MobileNavigationTabType tabType, MobileLibraryBrowserType browserType, LibraryQuery query) : base()
 {
     _tabType = tabType;
     _browserType = browserType;
     _query = query;
 }