Пример #1
0
        public void AddSection(string header, BaseAdapter adapter, int headcolor)
        {
            var  listSection = new ListSection(header, adapter, headcolor);
            bool issection = false, isoriginal = false;

            foreach (var section in Sections)
            {
                if (section.Header.Equals(listSection.Header))
                {
                    issection = true;
                }
            }

            foreach (var original in Original)
            {
                if (original.Header.Equals(listSection.Header))
                {
                    isoriginal = true;
                }
            }


            if (!isoriginal)
            {
                Original.Add(listSection);
            }

            if (!issection)
            {
                Sections.Add(listSection);
            }
        }
Пример #2
0
        public static ObservableCollection <ImageModel> SplitImage(string img, int length)
        {
            Original.Clear();
            GameList.Clear();
            Bitmap original = new Bitmap(img);
            int    position = 0;
            int    index    = 0;


            int widthOrg = original.Width / length, heighOrg = original.Height / length;

            for (int i = 0; i < length; i++)
            {
                for (int j = 0; j < length; j++)
                {
                    Rectangle srcRect = new Rectangle(j * widthOrg, i * heighOrg, widthOrg, heighOrg);
                    Bitmap    objImg  = original.Clone(srcRect, original.PixelFormat);
                    using (var memory = new MemoryStream())
                    {
                        objImg.Save(memory, ImageFormat.Png);
                        memory.Position = position;

                        BitmapImage bitmapImage = new BitmapImage();
                        bitmapImage.BeginInit();
                        bitmapImage.StreamSource = memory;
                        bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                        bitmapImage.EndInit();
                        bitmapImage.Freeze();
                        Original.Add(new ImageModel {
                            Image = bitmapImage, Row = i, Col = j, Text = index.ToString()
                        });
                    }
                    index++;
                }
            }
            Original.Last().Image = null;

            do
            {
                Randomize(length);
            } while (CheckIt(length) == false);

            return(GameList);
        }
        public async Task GetConfigurationMovieDb()
        {
            var configurationService = RestService.For <IConfigurationService>(EndPoints.BaseUrl);
            var topRatedService      = RestService.For <ITopRatedService>(EndPoints.BaseUrl);
            var result = await configurationService.GetConfiguration(EndPoints.ApiKey);

            if (result != null)
            {
                var movies = await topRatedService.GetMoviesTopRated(EndPoints.ApiKey, "pt-BR", 1);

                if (movies != null)
                {
                    foreach (var item in movies.results)
                    {
                        item.url_image = $"{result.images.base_url}{result.images.poster_sizes[2]}{item.poster_path}";
                        Kaina.Add(item);
                    }
                }

                var recente = await topRatedService.GetMoviesTopRated(EndPoints.ApiKey, "pt-BR", 2);

                if (recente != null)
                {
                    foreach (var item in recente.results)
                    {
                        item.url_image = $"{result.images.base_url}{result.images.poster_sizes[2]}{item.poster_path}";
                        Recentes.Add(item);
                    }
                }

                var emAlta = await topRatedService.GetMoviesTopRated(EndPoints.ApiKey, "pt-BR", 3);

                if (emAlta != null)
                {
                    foreach (var item in emAlta.results)
                    {
                        item.url_image = $"{result.images.base_url}{result.images.poster_sizes[2]}{item.poster_path}";
                        EmAlta.Add(item);
                    }
                }

                var original = await topRatedService.GetMoviesTopRated(EndPoints.ApiKey, "pt-BR", 4);

                if (original != null)
                {
                    foreach (var item in original.results)
                    {
                        item.url_image = $"{result.images.base_url}{result.images.poster_sizes[2]}{item.poster_path}";
                        Original.Add(item);
                    }
                }

                var disponivel = await topRatedService.GetMoviesTopRated(EndPoints.ApiKey, "pt-BR", 5);

                if (disponivel != null)
                {
                    foreach (var item in disponivel.results)
                    {
                        item.url_image = $"{result.images.base_url}{result.images.backdrop_sizes[1]}{item.backdrop_path}";
                        Disponivel.Add(item);
                    }
                    Movies = Disponivel[2];
                }
            }
        }