void UpdatePhotos(List <FlickrPhoto> photos, TileCollection tiles, bool keepExistent) { flickrTiles.BeginUpdate(); if (!keepExistent) { tiles.Clear(true); } foreach (FlickrPhoto photo in photos) { var tile = new Tile(); tile.HorizontalSize = 4; tile.VerticalSize = 3; tile.Template = tempFlickr; tile.Text = photo.Title; tile.Text1 = photo.AuthorName; tile.Tag = photo; tile.Click += Tile_Click; if (!string.IsNullOrEmpty(photo.ThumbnailUri)) { _downloadQueue.Enqueue(new DownloadItem(photo.ThumbnailUri, tile, false)); } if (!string.IsNullOrEmpty(photo.AuthorBuddyIconUri)) { _downloadQueue.Enqueue(new DownloadItem(photo.AuthorBuddyIconUri, tile, true)); } tiles.Add(tile); } flickrTiles.EndUpdate(); }
private void CreateWindow(TileCollection tiles) { Width = tiles.Width; Height = tiles.Height; for (var i = 0; i < tiles.Columns; i++) { MainGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); } for (var i = 0; i < tiles.Rows; i++) { MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); } for (var row = 0; row < tiles.Rows; row++) { for (var col = 0; col < tiles.Columns; col++) { var tile = tiles.FirstOrDefault(t => t.Column == col && t.Row == row); if (tile == null) { var id = tiles.Count > 0 ? tiles.Max(t => t.Id) + 1 : 0; tile = new AppTile(id, col, row); tiles.Add(tile); } var button = new TileButton(tile, this); MainGrid.Children.Add(button); } } }
void ShowErrorTile() { _downloadQueue.Clear(); try { TileCollection tiles = flickrTiles.Groups[0].Tiles; flickrTiles.BeginUpdate(); tiles.Clear(true); var tile = new Tile(); tile.HorizontalSize = 4; tile.VerticalSize = 2; tile.Template = tempError; tile.Click += ErrorTile_Click; tiles.Add(tile); } catch (Exception ex) { Console.WriteLine(ex.Message); } flickrTiles.EndUpdate(); }
private void LoadFoods(bool keepExistent) { TileCollection tiles1 = TileRec.Groups[0].Tiles; tiles1.Clear(true); lfooR = mposC.mposDB.fooDB.getlFoodsRecommend(); foreach (Foods foo1 in lfooR) { var tile = new Tile(); tile.HorizontalSize = mposC.takeouttilhorizontalsize; tile.VerticalSize = mposC.takeouttilverticalsize; tile.Template = tempFlickr; tile.Text = foo1.foods_name; tile.Text1 = "ราคา " + foo1.foods_price; tile.Tag = foo1; tile.Name = foo1.foods_id; tile.Click += Tile_Click; tile.Image = null; try { tile.Image = null; tiles1.Add(tile); MemoryStream stream = new MemoryStream(); Image loadedImage = null, resizedImage; if (foo1.filename.Equals("")) { continue; } //stream = mposC.ftpC.download(mposC.iniC.ShareFile + "/foods/" + foo1.filename); string ext = Path.GetExtension(foo1.filename); String file = ""; file = foo1.filename.Replace(ext, ""); file = file + "_210" + ext; stream = mposC.ftpC.download(mposC.iniC.ShareFile + "/foods/" + file); //loadedImage = new Bitmap(stream); //if (loadedImage != null) //{ // //SizeF size = tile.Width; // int originalWidth = loadedImage.Width; // int newWidth = 180; // resizedImage = loadedImage.GetThumbnailImage(newWidth, (newWidth * loadedImage.Height) / originalWidth, null, IntPtr.Zero); // tile.Image = resizedImage; //} tile.Image = new Bitmap(stream); } catch (Exception ex) { //MessageBox.Show("" + ex.Message, "showImg"); } //if (!string.IsNullOrEmpty(photo.ThumbnailUri)) // _downloadQueue.Enqueue(new DownloadItem(photo.ThumbnailUri, tile, false)); //if (!string.IsNullOrEmpty(photo.AuthorBuddyIconUri)) // _downloadQueue.Enqueue(new DownloadItem(photo.AuthorBuddyIconUri, tile, true)); } for (int i = 0; i < dtCat.Rows.Count; i++) { LoadFoods(false, i, dtCat.Rows[i]["foods_cat_id"].ToString()); } }
private void LoadFoods(bool keepExistent, int index, String catid) { //Control.FromHandle(intptr); Control ctl = new Control(); ctl = tabPage[1]; //if (index == 0) return; if (TileFoods[index + 1] == null) { return; } TileCollection tiles = TileFoods[index + 1].Groups[0].Tiles; tiles.Clear(true); lfooT = mposC.mposDB.fooDB.getlFoodsByCat(catid); foreach (Foods foo1 in lfooT) { var tile = new Tile(); tile.HorizontalSize = mposC.takeouttilhorizontalsize; tile.VerticalSize = mposC.takeouttilverticalsize; tile.Template = tempFlickr; tile.Text = foo1.foods_name; tile.Text1 = "ราคา " + foo1.foods_price; tile.Tag = foo1; tile.Name = foo1.foods_id; tile.Click += Tile_Click; tile.Image = null; try { tile.Image = null; tiles.Add(tile); MemoryStream stream = new MemoryStream(); Image loadedImage = null, resizedImage; if (foo1.filename.Equals("")) { continue; } stream = mposC.ftpC.download(mposC.iniC.ShareFile + "/foods/" + foo1.filename); loadedImage = new Bitmap(stream); if (loadedImage != null) { //SizeF size = tile.Width; int originalWidth = loadedImage.Width; int newWidth = 180; resizedImage = loadedImage.GetThumbnailImage(newWidth, (newWidth * loadedImage.Height) / originalWidth, null, IntPtr.Zero); tile.Image = resizedImage; } } catch (Exception ex) { //MessageBox.Show("" + ex.Message, "showImg"); } //if (!string.IsNullOrEmpty(photo.ThumbnailUri)) // _downloadQueue.Enqueue(new DownloadItem(photo.ThumbnailUri, tile, false)); //if (!string.IsNullOrEmpty(photo.AuthorBuddyIconUri)) // _downloadQueue.Enqueue(new DownloadItem(photo.AuthorBuddyIconUri, tile, true)); } }
private void setTileCategory() { int index = 0; String pathScan = ""; pathScan = bc.iniC.pathImageScan; TileCollection tiles = TileCat.Groups[0].Tiles; foreach (String filename in Directory.GetFiles(pathScan)) { var tile = new Tile(); Patient fooc = new Patient(); tile.HorizontalSize = 1; tile.VerticalSize = 2; //tile.VerticalSize = 1; //tile.HorizontalSize = 2; tile.Template = tempRec; tile.Text = index.ToString(); //tile.HorizontalSize = 2; //tile.VerticalSize = 1; //tile.Template = tempFlickr; //tile.Text1 = "ราคา " + foo1.foods_price; //tile.Tag = foo1; fooc.filename = filename; tile.Tag = fooc; tile.Name = index.ToString(); tile.Index = index; tile.Click += Tile_Click; tile.Image = null; try { tile.Image = null; tiles.Add(tile); Image loadedImage = null; if (fooc.filename.Equals("")) { continue; } loadedImage = Image.FromFile(filename); if (loadedImage != null) { int originalWidth = loadedImage.Width; int newWidth = 180; tile.Image = loadedImage; } } catch (Exception ex) { //MessageBox.Show("" + ex.Message, "showImg"); } index++; } }
void ShowErrorTile() { _downloadQueue.Clear(); TileCollection tiles = flickrTiles.Groups[0].Tiles; flickrTiles.BeginUpdate(); tiles.Clear(true); var tile = new Tile(); tile.HorizontalSize = 4; tile.VerticalSize = 2; tile.Template = tempError; tile.Click += ErrorTile_Click; tiles.Add(tile); flickrTiles.EndUpdate(); }