private void dataGridView1_SelectionChanged(object sender, EventArgs e) { if (dataGridView1.CurrentRow != null) { try { if (GlobalUtil.EngineUnconnectioned(this)) { return; } Costume item = (Costume)dataGridView1.CurrentRow.DataBoundItem; if (curCostume != item && skinCheckBoxShowImage.Checked) { if (imageCtrl != null) { imageCtrl?.Close(); imageCtrl = null; } imageCtrl = new SingleImageForm(); skinCheckBoxShowImage.CheckedChanged -= skinCheckBoxShowImage_CheckedChanged; skinCheckBoxShowImage.Checked = true; skinCheckBoxShowImage.CheckedChanged += skinCheckBoxShowImage_CheckedChanged; imageCtrl.FormClosing += ImageCtrl_FormClosing; imageCtrl.Text = "款号:" + item.ID; imageCtrl.OnLoadingState(); Image img = null; //InteractResult<string> result = GlobalCache.ServerProxy.GetMainCostumePhotoAddress(item.ID); // if (result.ExeResult == ExeResult.Success) // { // String savePath = GlobalUtil.EmallDir + Path.GetFileName(result.Data); try { /* if (!File.Exists(savePath)) * { * CosCloud.DownloadFile(CosLoginInfo.BucketName, result.Data, savePath); * } * img = JGNet.Core.ImageHelper.FromFileStream(savePath);*/ if (item.EmThumbnail != null) { String url = item.EmThumbnail; System.Net.WebRequest webreq = System.Net.WebRequest.Create(url); System.Net.WebResponse webres = webreq.GetResponse(); using (System.IO.Stream stream = webres.GetResponseStream()) { img = Image.FromStream(stream); } } } catch (Exception ex) { //下载失败,可能文件被占用,直接使用该文件即可。 //文件找不到使用默认图片,找不到 } //} if (img != null) { imageCtrl.Image = img; } else { imageCtrl.Image = null; } imageCtrl?.BringToFront(); imageCtrl?.Show(); curCostume = item; } } catch (Exception ex) { // GlobalUtil.ShowError(ex); } finally { GlobalUtil.UnLockPage(this); } } }
private void dataGridView1_SelectionChanged(object sender, EventArgs e) { if (dataGridView1.CurrentRow != null) { try { if (GlobalUtil.EngineUnconnectioned(this)) { return; } EmCostume item = (EmCostume)dataGridView1.CurrentRow.DataBoundItem; // item.EmThumbnailData if (curCostume != item && skinCheckBoxShowImage.Checked) { if (imageCtrl != null) { imageCtrl?.Close(); imageCtrl = null; } imageCtrl = new SingleImageForm(); imageCtrl.FormClosing += ImageCtrl_FormClosing; imageCtrl.Text = "款号:" + item.ID; imageCtrl.OnLoadingState(); skinCheckBoxShowImage.CheckedChanged -= skinCheckBoxShowImage_CheckedChanged; skinCheckBoxShowImage.Checked = true; skinCheckBoxShowImage.CheckedChanged += skinCheckBoxShowImage_CheckedChanged; Costume CurItem = CommonGlobalCache.GetCostume(item.ID); // byte[] bytes = GlobalCache.ServerProxy.GetCostumePhoto(item.ID); if (item.EmShowOnline) { if (!String.IsNullOrEmpty(item.EmThumbnail)) { String url = item.EmThumbnail; System.Net.WebRequest webreq = System.Net.WebRequest.Create(url); System.Net.WebResponse webres = webreq.GetResponse(); using (System.IO.Stream stream = webres.GetResponseStream()) { imageCtrl.Image = Image.FromStream(stream); } } else { imageCtrl.Image = null; } } else { if (!String.IsNullOrEmpty(CurItem.EmThumbnail)) { String url = CurItem.EmThumbnail; System.Net.WebRequest webreq = System.Net.WebRequest.Create(url); System.Net.WebResponse webres = webreq.GetResponse(); using (System.IO.Stream stream = webres.GetResponseStream()) { imageCtrl.Image = Image.FromStream(stream); } } else { imageCtrl.Image = null; } } imageCtrl?.BringToFront(); imageCtrl?.Show(); curCostume = item; } } catch (Exception ex) { // GlobalUtil.ShowError(ex); } finally { GlobalUtil.UnLockPage(this); } } }