Exemplo n.º 1
0
        public static List <Exhibit> GetFilteredExhibits(List <Artist> selectedArtists, List <TimePeriod> selectedTimePeriods,
                                                         List <ArtStyle> selectedArtStyles)
        {
            List <Exhibit> exhibits = ExhibitBase.GetExhibitBase().Exhibits;

            if (selectedArtists is null)
            {
                selectedArtists = GetArtists(exhibits)
                                  .ConvertAll(a => a.Artist);
            }
            if (selectedTimePeriods is null)
            {
                selectedTimePeriods = GetTimePeriods(exhibits)
                                      .ConvertAll(tp => tp.TimePeriod);
            }
            if (selectedArtStyles is null)
            {
                selectedArtStyles = GetArtStyles(exhibits)
                                    .ConvertAll(st => st.ArtStyle);
            }
            return(exhibits.FindAll((e) =>
                                    selectedArtists.Exists(a => a.Name == e.Artist.Name) &&
                                    selectedTimePeriods.Exists(tp => tp.Name == e.TimePeriod.Name) &&
                                    selectedArtStyles.Exists(st => st.Name == e.ArtStyle.Name)));
        }
Exemplo n.º 2
0
        public ExploreViewModel()
        {
            // Make a list of preselected routes
            RouteInfo filter1 = new RouteInfo {
                ImageSource = "", Name = "Classic"
            };

            filter1.ArtStyleFilter = new List <ArtStyle>
            {
                new ArtStyle("Classic")
            };

            RouteInfo filter2 = new RouteInfo {
                ImageSource = "", Name = "17th century"
            };

            filter2.TimePeriodFilter = new List <TimePeriod>
            {
                new TimePeriod("17th century")
            };

            RouteInfo filter3 = new RouteInfo {
                ImageSource = "", Name = "ALEKOS TZOMAKAS"
            };

            filter3.ArtistFilter = new List <Artist>
            {
                new Artist("ALEKOS TZOMAKAS")
            };

            PreselectedRoutes = new List <RouteInfo>
            {
                filter1,
                filter2,
                filter3
            };

            // Make a list of popular exhibits
            ExhibitBase exhibitBase = ExhibitBase.GetExhibitBase();

            PopularExhibits = new List <ExhibitInfo>();
            var FavExhibits  = exhibitBase.GetFavourites();
            int exhibitCount = Math.Min(5, exhibitBase.Exhibits.Count);

            for (int i = 0; i < exhibitCount; i++)
            {
                Exhibit exhibit = exhibitBase.Exhibits[i];
                bool    isFav   = false;
                if (FavExhibits.Contains(exhibit))
                {
                    isFav = true;
                }
                PopularExhibits.Add(new ExhibitInfo(exhibit, isFav));
            }
        }
Exemplo n.º 3
0
        public FiltersViewModel()
        {
            // Create some demo exhibits
            exhibits = ExhibitBase.GetExhibitBase().Exhibits;

            // Find out all artists and deselect all of them
            Artists = GetArtists(exhibits);

            // Find out all time periods and deselect all of them
            TimePeriods = GetTimePeriods(exhibits);

            // Find out all art styles and deselect all of them
            ArtStyles = GetArtStyles(exhibits);
        }
Exemplo n.º 4
0
        private async Task LaunchScanner()
        {
            try
            {
                var scanner = DependencyService.Get <IQrScanningService>();
                var result  = await scanner.ScanAsync();

                // TODO: Handle case when result is null
                if (result != null)
                {
                    ExhibitBase exhibitBase = ExhibitBase.GetExhibitBase();
                    Exhibit     exhibit     = exhibitBase.Exhibits.Find(e => e.Name == result);
                    await Navigation.PushAsync(new ExhibitPage(exhibit.ID));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error during qrcode scanning:" + ex.Message);
                // TODO: Return that scanning failed.
                throw;
            }
        }
Exemplo n.º 5
0
        public ExhibitPage(Guid exhibitID)
        {
            InitializeComponent();

            viewModel = new ExhibitViewModel();
            ExhibitBase exhibitBase = ExhibitBase.GetExhibitBase();
            var         FavExhibits = exhibitBase.GetFavourites();
            Exhibit     exhibit     = exhibitBase.Exhibits.Find((e) => e.ID == exhibitID);

            viewModel.ImageSource = exhibit.ImageSource;
            // TODO: Remove other attributes apart from ID from ExhibitID
            viewModel.ExhibitID          = exhibit.ID;
            viewModel.ExhibitName        = exhibit.Name;
            viewModel.ExhibitDescription = ArtistBase.GetInstance().GetArtistBio(exhibit.Artist.Name);
            viewModel.IsFavourite        = FavExhibits.Contains(exhibit);
            BindingContext = viewModel;

            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (s, e) =>
            {
                // Switch favourite state
                if (viewModel.IsFavourite)
                {
                    // Unfavourite item
                    viewModel.IsFavourite = false;
                    exhibitBase.RemoveFavourite(viewModel.ExhibitID);
                }
                else
                {
                    // Favourite item
                    viewModel.IsFavourite = true;
                    exhibitBase.AddFavourite(viewModel.ExhibitID);
                }
                // TODO: Do this using data binding
                image_favourite.Source = viewModel.FavImageSource;
            };
            image_favourite.GestureRecognizers.Add(tapGestureRecognizer);
        }
Exemplo n.º 6
0
 public FavouritesViewModel()
 {
     Favourites = ExhibitBase.GetExhibitBase().GetFavourites();
 }