private void timer_Tick(object sender, EventArgs e) { NodeTag[] listTreeNodes = _currentNodeTag.Chidrens; if (i == listTreeNodes.GetLength(0)) { timer.Stop(); return; } Image image; SizeF sizef; try { image = Image.FromFile(FileTransferUtility.DownloadFile(listTreeNodes[i].Thumbnail.Guid, listTreeNodes[i].Thumbnail.Extension)); sizef = new SizeF(image.Width / image.HorizontalResolution, image.Height / image.VerticalResolution); float fScale = Math.Min(cxButton / sizef.Width, cyButton / sizef.Height); sizef.Width *= fScale; sizef.Height *= fScale; } catch (FileTransferException ex) { _log.Error(ex.Message); ++i; return; } catch (Exception ex) { _log.Error(ex.ToString()); ++i; return; } // convert image to small size for button Bitmap bitmap = new Bitmap(image, Size.Ceiling(sizef)); image.Dispose(); // create button and add to panel Button btn = new Button(); btn.Image = bitmap; btn.Location = new Point(x, y) + (Size)AutoScrollPosition; btn.Size = new Size(cxButton, cyButton); btn.Tag = listTreeNodes[i]; btn.Click += new EventHandler(btn_Click); Controls.Add(btn); // give button a tooltip tooltip.SetToolTip(btn, String.Format("{0}\n{1}", listTreeNodes[i].Name, listTreeNodes[i].Description)); // adjust i, x and y for next image AdjustXY(ref x, ref y); ++i; }
public string GetFilePathFromGuid(Guid guid) { DCComponent comp = GetComponent(guid); return(FileTransferUtility.DownloadFile(comp.File.Guid, comp.File.Extension)); }