private Image GetFullImage(imageCell cell) { Image img = null; if (cell.FullSize != null) { img = cell.FullSize; } else { var provider = GetCurrentContext().Provider; string url = string.Empty; if (!string.IsNullOrEmpty(cell.FullSizeUrl)) { url = cell.FullSizeUrl; } else if (provider.GetFullsizeUrlViaCallback) { var tgeturl = new Thread(() => url = provider.GetFullsizeUrlCallback(cell.AdditionalInfo)); tgeturl.Start(); while (tgeturl.IsAlive) { Application.DoEvents(); } } var tget = new Thread(() => img = Http.getPicture(url)); tget.Start(); while (tget.IsAlive) { Application.DoEvents(); } cell.FullSize = img; } return img; }
private void ShowResults(List<UnifiedResponse> Responses) { for (int c = 0; c < Responses.Count(); c++) { var Response = Responses[c]; var tab = Sources.TabPages[c]; var context = GetContextByTab(tab); int count = Math.Min(20, Response.Results.Count); tab.Text = string.Format("{0} ({1})", context.DisplayedName, count); if (count == 0) { continue; } int cursor = 0; int i = 0; while (cursor < Response.Results.Count && i < count) { var r = Response.Results[cursor]; if (string.IsNullOrEmpty(r.Url) && string.IsNullOrEmpty(r.Thumb)) { cursor++; continue; } var cell = new imageCell(120, 150, 120 * (i % 5), 150 * (i / 5)); cell.Caption = string.Format( "{0}; {1}", r.Album, r.Width > 0 && r.Height > 0 ? string.Format("{0}x{1}px", r.Width, r.Height) : "size\u00A0n/a" ); Label l = null; cell.MouseEnter += (sender, args) => l = ShowInfoTooltip(cell.Caption, cell.Location + new Size(16, cell.Height)); cell.MouseLeave += (sender, args) => { this.Controls.Remove(l); l.Dispose(); }; cell.Click += CellClick; cell.FullSizeUrl = r.Url; if (context.Provider.GetFullsizeUrlViaCallback) { cell.AdditionalInfo = r.AdditionalInfo; } tab.Controls.Add(cell); (new Thread(() => cell.Thumbnail = Http.getPicture(r.Thumb))).Start(); cursor++; i++; } } }
private void formDoWork_Shown(object sender, EventArgs e) { this.Controls.Add(generalmsg); generalmsg.MouseClick += HideEventHandler; cellEmbeded = new imageCell(120, 150, 840, 280); cellEmbeded.Caption = Verbal.Embedded; cellEmbeded.IsEmbeded = true; cellEmbeded.Click += CellClick; this.Controls.Add(cellEmbeded); currentJob = jCon.Jobs.Tables[Fields.Tracks].Rows[0]; bindGrid(); if (WinRegistry.GetValue<bool>(WinRegistry.Keys.ShowJobs)) { btnJobs.Checked = true; } else { btnJobs_CheckedChanged(null, null); } chkCrop.Checked = WinRegistry.GetValue<bool>(WinRegistry.Keys.Crop); chkResize.Checked = WinRegistry.GetValue<bool>(WinRegistry.Keys.Resize); int size = WinRegistry.GetValue<int>(WinRegistry.Keys.ResizeTo); numSize.Value = size > 0 ? size : 500; showTrackInfo(); DoSearch(); }