public void setSamune(string url) { //if (string.IsNullOrEmpty(url)) return; if (isTest) { thumbnailPictureBox.Image = new Bitmap(Image.FromFile(ri.thumbnailUrl), thumbnailPictureBox.Size); return; } var img = ThumbnailManager.getImageId(ri.comId); var isSaveCache = bool.Parse(config.get("alartCacheIcon")); if (img != null && isSaveCache) { ThumbnailManager.saveImage(img, ri.comId); } if (img == null && !string.IsNullOrEmpty(url)) { img = ThumbnailManager.getThumbnailRssUrl(url, isSaveCache, true); } thumbnailPictureBox.Image = img; /* * if (!util.isShowWindow) return; * if (IsDisposed) return; * WebClient cl = new WebClient(); * cl.Proxy = null; * * System.Drawing.Icon icon = null; * try { * byte[] pic = cl.DownloadData(url); * * * var st = new System.IO.MemoryStream(pic); * icon = Icon.FromHandle(new System.Drawing.Bitmap(st).GetHicon()); * st.Close(); * * * } catch (Exception e) { * util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); * util.debugWriteLine("set samune url error " + url); * return; * } * * try { * Invoke((MethodInvoker)delegate() { * try { * thumbnailPictureBox.Image = icon.ToBitmap(); * * } catch (Exception e) { * util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); * } * }); * } catch (Exception e) { * util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); * } * * * // Icon = new System.Drawing.Icon(url); */ }
private void setThunb(string num, bool isOkBtn) { var isUser = !num.StartsWith("c"); Image img; if (ThumbnailManager.isExist(num, out img)) { var type = isUser ? "ユーザー" : "コミュニティ"; if (isUser) { userThumbBox.Image = new Bitmap(img, userThumbBox.Size); } else { comThumbBox.Image = new Bitmap(img, comThumbBox.Size); } var res = DialogResult.No; if (!isOkBtn && num != "co00") { res = MessageBox.Show(type + "画像を取得し直しますか?", type + "画像が既に存在します", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); } if (res == DialogResult.No) { if (isUser) { userThumbBox.Image = new Bitmap(img, userThumbBox.Size); } else { comThumbBox.Image = new Bitmap(img, comThumbBox.Size); } return; } } var newImg = ThumbnailManager.getImageId(num); if (newImg == null) { return; } if (bool.Parse(form.config.get("alartCacheIcon"))) { ThumbnailManager.saveImage(newImg, num); } if (isUser) { userThumbBox.Image = new Bitmap(newImg, userThumbBox.Size); } else { comThumbBox.Image = new Bitmap(newImg, comThumbBox.Size); } newImg.Dispose(); }
public void getThumbBulkCore(ToolMenuLock _lock, MainForm form, bool isUser) { var getAiList = new List <AlartInfo>(); while (true) { try { foreach (var ai in form.alartListDataSource) { Image img = null; if (isUser && !string.IsNullOrEmpty(ai.hostId) && !ThumbnailManager.isExist(ai.hostId, out img) && getAiList.IndexOf(ai) == -1) { getAiList.Add(ai); } if (!isUser && !string.IsNullOrEmpty(ai.communityId) && !ThumbnailManager.isExist(ai.communityId, out img) && getAiList.IndexOf(ai) == -1) { getAiList.Add(ai); } } foreach (var ai in form.userAlartListDataSource) { Image img = null; if (isUser && !string.IsNullOrEmpty(ai.hostId) && !ThumbnailManager.isExist(ai.hostId, out img) && getAiList.IndexOf(ai) == -1) { getAiList.Add(ai); } if (!isUser && !string.IsNullOrEmpty(ai.communityId) && !ThumbnailManager.isExist(ai.communityId, out img) && getAiList.IndexOf(ai) == -1) { getAiList.Add(ai); } } break; } catch (Exception e) { util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite); } } _lock.all = getAiList.Count; setToolMenuStatusBar(); int got = 0, error = 0, no = 0; for (var i = 0; i < getAiList.Count; i++) { var ai = getAiList[i]; if ((isUser && userThumbLock != _lock) || (!isUser && comThumbLock != _lock)) { util.showModelessMessageBox("未取得" + (isUser ? "ユーザ" : "コミュ") + "画取得が中断されました", "", form); setToolMenuStatusBar(); return; } var id = isUser ? ai.hostId : ai.communityId; var img = ThumbnailManager.getImageId(id, form); if (img == null) { error++; form.alartListExistColorChange(id, isUser, 2); } else { ThumbnailManager.saveImage(img, id); got++; form.alartListExistColorChange(id, isUser, 0); } _lock.end = i; setToolMenuStatusBar(); Thread.Sleep(3000); } util.showModelessMessageBox("取得:" + got + " 画像無し:" + no + " エラー:" + error, "未取得" + (isUser ? "ユーザ" : "コミュ") + "画取得終了", form); if (isUser) { userThumbLock = null; } else { comThumbLock = null; } setToolMenuStatusBar(); }
public void setSamune(string url) { //if (string.IsNullOrEmpty(url)) return; if (isTest) { thumbnailPictureBox.Image = new Bitmap(Image.FromFile(ri.thumbnailUrl), thumbnailPictureBox.Size); return; } Image img; var dt0 = DateTime.Now; if (!ThumbnailManager.isExist(ri.comId, out img)) { util.debugWriteLine("is not exist thumbnail time " + (DateTime.Now - dt0) + " " + ri.comName); img = ThumbnailManager.getImageId(ri.comId); if (img != null) { ThumbnailManager.saveImage(img, ri.comId); } if (img == null && !string.IsNullOrEmpty(url)) { img = ThumbnailManager.getThumbnailRssUrl(url, true); } } else { util.debugWriteLine("is exist thumbnail time " + (DateTime.Now - dt0) + " " + ri.comName); } thumbnailPictureBox.Image = img; util.debugWriteLine("is set thumbnail time " + (DateTime.Now - dt0) + " " + ri.comName); /* * if (!util.isShowWindow) return; * if (IsDisposed) return; * WebClient cl = new WebClient(); * cl.Proxy = null; * * System.Drawing.Icon icon = null; * try { * byte[] pic = cl.DownloadData(url); * * * var st = new System.IO.MemoryStream(pic); * icon = Icon.FromHandle(new System.Drawing.Bitmap(st).GetHicon()); * st.Close(); * * * } catch (Exception e) { * util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); * util.debugWriteLine("set samune error " + url); * return; * } * * try { * Invoke((MethodInvoker)delegate() { * try { * thumbnailPictureBox.Image = icon.ToBitmap(); * * } catch (Exception e) { * util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); * } * }); * } catch (Exception e) { * util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); * } * * * // Icon = new System.Drawing.Icon(url); */ }