/// <summary> /// Handles the DoWork event of the backGetOnlineList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param> private void backGetOnlineList_DoWork(object sender, DoWorkEventArgs e) { try { DataTable dt = OnlineManager.ListDataHubDatasetsWithSubscriptions(); foreach (DataRow dr in dt.Rows) { if (dr["IS_SUBSCRIBED"].ToString() == "Y") { if (dr["SERVICETYPE"].ToString().Equals("MAP", StringComparison.InvariantCultureIgnoreCase)) { Bitmap b = null; try { System.Net.WebRequest request = System.Net.WebRequest.Create(dr["THUMBNAIL_URL"].ToString()); System.Net.WebResponse response = request.GetResponse(); System.IO.Stream responseStream = response.GetResponseStream(); b = new Bitmap(responseStream); int w = 165; int h = 130; int borderx = 10; int bordery = 10; Bitmap newImage = new Bitmap(w, h); using (Graphics graphics = Graphics.FromImage(newImage)) { graphics.Clear(Color.White); int x = (newImage.Width - b.Width) / 2; int y = (newImage.Height - b.Height) / 2; graphics.DrawImage(b, new Rectangle(borderx, bordery, newImage.Width - 2 * borderx, newImage.Height - 2 * bordery), 0, 0, b.Width, b.Height, GraphicsUnit.Pixel); } b = newImage; } catch (Exception) { } string id = dr["ID"].ToString(); string name = dr["NAME"].ToString(); string mapurl = dr["URL"].ToString(); lock (mylock) { DataRow dn = _BaseData.NewRow(); dn["ID"] = id; dn["NAME"] = name; dn["THUMBNAIL"] = b; dn["MAP_URL"] = mapurl; _BaseData.Rows.Add(dn); } backGetOnlineList.ReportProgress(1); } } } } catch (Exception) { } }