Exemple #1
0
        void OnRowClicked(object sender, EventArgs e)
        {
            GalleryRow row = (GalleryRow)sender;

            var intent = new Intent(this, row.Activity);

            intent.PutExtra(BaseActivity.MapTitle, row.Sample.Title);
            intent.PutExtra(BaseActivity.MapDescription, row.Sample.Description);
            StartActivity(intent);
        }
Exemple #2
0
        private void UpdateRows()
        {
            if (ItemsSource == null || PerRow == 0)
            {
                return;
            }

            var perRow = PerRow;
            var rows   = new List <GalleryRow>();
            var row    = new GalleryRow {
                Items = new object[perRow]
            };
            var columnIndex = 0;

            foreach (var item in ItemsSource)
            {
                row.Items[columnIndex++] = item;
                if (columnIndex == perRow)
                {
                    rows.Add(row);
                    row = new GalleryRow {
                        Items = new object[perRow]
                    };
                    columnIndex = 0;
                }
            }

            if (columnIndex > 0)
            {
                var newItems = new object[columnIndex];
                Array.Copy(row.Items, newItems, columnIndex);
                row.Items = newItems;
                rows.Add(row);
            }

            _listBox.ItemsSource = rows;
        }
        /// <summary>
        /// Gets the thumbnail images for the picture gallery page
        /// </summary>
        /// <returns>A List of GalleryRow containing thumbnail images</returns>
        public static List<GalleryRow> GetGalleryThumbnails()
        {
            List<GalleryRow> images = new List<GalleryRow>();

            DirectoryInfo dir = new DirectoryInfo(HttpContext.Current.Server.MapPath("images/Gallery"));

            if (!dir.Exists) return null;

            List<FileInfo> directoryImages = new List<FileInfo>(dir.GetFiles("*.jpg"));
            var imagesWithThumbNails = from img in directoryImages
                                       where img.Name.Contains("_100")
                                       select img;

            var imagesWithOutThumbNails = from img in directoryImages
                                          where !img.Name.Contains("_100")
                                          join thumbNails in imagesWithThumbNails on img.Name equals thumbNails.Name.Replace("_100", "") into thmbs
                                          from i in thmbs.DefaultIfEmpty()
                                          where i == null
                                          select img;

            directoryImages = new List<FileInfo>();
            directoryImages.AddRange(imagesWithThumbNails);
            directoryImages.AddRange(imagesWithOutThumbNails);

            GalleryRow row = new GalleryRow();

            for (int i = 0; i < directoryImages.Count; i++)
            {
                if (i != 0 && i % 4 == 0)
                {
                    images.Add(row);
                    row = new GalleryRow();
                }

                row.Columns.Add(new GalleryColumn(directoryImages[i]));
            }

            images.Add(row);

            return images;
        }
        /// <summary>
        /// Gets the images for the picture gallery page
        /// </summary>
        /// <returns>A list of fileinfo containing images</returns>
        public static List<GalleryRow> GetGalleryImages()
        {
            List<GalleryRow> rows = new List<GalleryRow>();

            DirectoryInfo dir = new DirectoryInfo(HttpContext.Current.Server.MapPath("images/Gallery"));

            if (!dir.Exists) return null;

            List<FileInfo> images = dir.GetFiles("*.jpg").Where(fi => !fi.Name.Contains("_")).ToList();

            GalleryRow row = new GalleryRow();

            for (int i = 0; i < images.Count; i++)
            {
                if (i != 0 && i % 4 == 0)
                {
                    rows.Add(row);
                    row = new GalleryRow();
                }

                row.Columns.Add(new GalleryColumn(images[i]));
            }

            rows.Add(row);

            return rows;
        }
Exemple #5
0
        void OnRowClicked(object sender, EventArgs e)
        {
            GalleryRow row = (GalleryRow)sender;

            StartActivity(new Intent(this, row.Activity));
        }