public bool SaveMark(Image image, ref string name) { try { string oldName = name; if (!Directory.Exists(GetConfig.Dynamic)) { Directory.CreateDirectory(GetConfig.Dynamic); } if (!name.Contains("Mark")) { name = "Mark" + name; } else { oldName = name.Replace("Mark", ""); } string newPath = GetConfig.Dynamic + "\\" + name; FileOperator.SaveAsJPEG(image, newPath, GetConfig.IMS_Quality); userCtrPictureEx u = (userCtrPictureEx)this.p_BackImags.Controls[oldName]; u.Picture.LoadFile(newPath); u.Picture.IsMark = true; u.l_Buttom.Text = name; this.CurrentCtlName = u.Picture.FileName; this.dbClick(u.Picture); return(true); } catch { return(false); } }
public List <ImgObj> SaveImgs(ref string ImgToPaxPaths) { ImgToPaxPaths = ""; List <ImgObj> arraySaveImg = new List <ImgObj>(); //string ImgToPaxPaths = ""; arraySaveImg = arrayImgDel; for (int i = 0; i < p_RptImages.Controls.Count; i++) { userCtrPictureEx ctr = ((userCtrPictureEx)(p_RptImages.Controls[i])); ImgObj obj = (ImgObj)ctr.Picture.ImgObj; obj.IsCheck = ctr.Picture.GetCheck(); arraySaveImg.Add(obj); if (GetConfig.SendCheckImage) { if (obj.IsCheck) { ImgToPaxPaths += obj.ImagePath + ";"; } } else { ImgToPaxPaths += obj.ImagePath + ";"; } // ctr.Picture.Image.Save(@"D:\121.jpg"); Image img = ctr.Picture.Image; } return(arraySaveImg); }
private Control AddImageCtl(ImgObj obj, int i) { userCtrPictureEx ctl = new userCtrPictureEx(); ctl.LabelBorderStyle = userCtrPictureEx.LBorderStyle.All; ctl.Picture.ImgObj = obj; ctl.Picture.SetCheckBoxReadOnly(this.ReadOnly); ctl.Picture.SetDoubleClick(true); ctl.Picture.SetCheck(obj.IsCheck); ctl.Picture.CheckChanged += new EventHandler(Picture_CheckChanged); ctl.Picture.MouseDoubleClick += new MouseEventHandler(Picture_MouseDoubleClick); ctl.Picture.MouseUp += new MouseEventHandler(Picture_MouseUp); ctl.Picture.MouseDown += new MouseEventHandler(Picture_MouseDown); if (obj.MarkImgPath == "") { ctl.Picture.LoadFile(obj.ImagePath); } else { ctl.Picture.LoadFile(obj.MarkImgPath); ctl.Picture.IsMark = true; } ctl.Picture.Inf = obj.Inf; ctl.Picture.LocMapPath = obj.LocMapPath; int height = this.p_RptImages.Height; int width = this.p_RptImages.Width; if (this.isDockTop) { if (ctl.Picture.ImageRatio != 0) { height = Convert.ToInt32(width / ctl.Picture.ImageRatio); } ctl.Dock = DockStyle.Top; } else { if (ctl.Picture.ImageRatio != 0) { width = Convert.ToInt32(height * ctl.Picture.ImageRatio); } ctl.Dock = DockStyle.Left; } if (GetConfig.IsAddLocMap) { string name = obj.ImagePath.Substring(obj.ImagePath.LastIndexOf("\\") + 1); if (ExitesMap(name)) { ctl.Picture.LocMapPath = Dir + "Map" + name; } } ctl.Size = new Size(width, height); ctl.l_Top.TextAlign = ContentAlignment.MiddleLeft; ctl.l_Top.BackColor = Color.LightGray; ctl.l_Top.ForeColor = Color.Blue; ctl.l_Top.Text = i.ToString(); ctl.l_Buttom.Text = ctl.Picture.FileName; return(ctl); }
public void ReSetCheck() { for (int i = 0; i < this.p_RptImages.Controls.Count; i++) { userCtrPictureEx u = (userCtrPictureEx)this.p_RptImages.Controls[i]; u.Picture.SetCheck(false); } }
public void DeleteImage() { for (int i = 0; i < this.p_Show.Controls.Count; i++) { userCtrPictureEx ptb = (userCtrPictureEx)this.p_Show.Controls[i]; if (ptb.Picture.IsSelecting) { this.p_Show.Controls.RemoveAt(i); } } }
/// <summary> /// 导出所有图像到指定文件夹 /// </summary> public void ExportAll() { FolderBrowserDialog fd = new FolderBrowserDialog(); if (fd.ShowDialog() == DialogResult.OK) { for (int i = 0; i < this.p_RptImages.Controls.Count; i++) { userCtrPictureEx axf = (userCtrPictureEx)this.p_RptImages.Controls[i]; System.IO.File.Copy(axf.Picture.FilePath, fd.SelectedPath + "\\" + axf.Picture.FileName, true); } } }
/// <summary> /// 导出所有图像到指定文件夹 /// </summary> private void tsmi_ExportAll_Click(object sender, EventArgs e) { FolderBrowserDialog fd = new FolderBrowserDialog(); if (fd.ShowDialog() == DialogResult.OK) { for (int i = 0; i < this.p_BackImags.Controls.Count; i++) { userCtrPictureEx axf = (userCtrPictureEx)this.p_BackImags.Controls[i]; System.IO.File.Copy(axf.Picture.FilePath, fd.SelectedPath + "\\" + axf.Picture.FileName, true); } } }
/// <summary> /// 切换打印模板时取得图片信息 /// </summary> /// <returns></returns> public List <ImgObj> SaveImgs() { List <ImgObj> arraySaveImg = new List <ImgObj>(); for (int i = 0; i < p_RptImages.Controls.Count; i++) { userCtrPictureEx ctr = ((userCtrPictureEx)(p_RptImages.Controls[i])); ImgObj obj = (ImgObj)ctr.Picture.ImgObj; obj.IsCheck = ctr.Picture.GetCheck(); arraySaveImg.Add(obj); } return(arraySaveImg); }
/// <summary> /// 删除选择图像 /// </summary> private void tsmi_Delete_Click(object sender, EventArgs e) { if (this.p_BackImags.Controls.Count > 0) { // List<string> arrayDelete = new List<string>(); //List<int> arrayDeleteCtl = new List<int>(); ArrayList arraydel = new ArrayList(); for (int i = 0; i < this.p_BackImags.Controls.Count; i++) { userCtrPictureEx axf = (userCtrPictureEx)this.p_BackImags.Controls[i]; if (axf.Picture.IsSelecting) { arraydel.Add(axf); //arrayDelete.Add(axf.Picture.FilePath); //arrayDeleteCtl.Add(i); } } if (arraydel.Count > 0) { if (DialogResult.OK == MessageBoxEx.Show("是否删除所选择图像?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)) { xmlDoc.Load(XmlPath); XmlNode root = xmlDoc.DocumentElement; for (int i = 0; i < arraydel.Count; i++) { userCtrPictureEx axf = (userCtrPictureEx)arraydel[i]; System.IO.File.Delete(axf.Picture.FilePath); this.p_BackImags.Controls.Remove(axf); //System.IO.File.Delete(arrayDelete[i]); //this.p_BackImags.Controls.RemoveAt(arrayDeleteCtl[i]); XmlNode node = xmlDoc.SelectSingleNode("PatientBackImage/Image[@Name='" + axf.Picture.FilePath + "'] "); if (node != null) { root.RemoveChild(node); } if (axf.Picture.FilePath == this.CurrentCtlName) { this.dbClick(null); } } xmlDoc.Save(XmlPath); } } } this.l_Count.Text = "共 " + this.p_BackImags.Controls.Count.ToString() + " 张"; }
private void AddImage(string image) { userCtrPictureEx uptb = new userCtrPictureEx(); uptb.Picture.SetCheckBoxVisible(false); uptb.LabelBorderStyle = userCtrPictureEx.LBorderStyle.All; uptb.LabelBorder = 3; uptb.Name = count.ToString(); uptb.Size = new System.Drawing.Size(150, 150); uptb.Picture.LoadFile(image); if (uptb.Picture.Image != null) { this.p_Show.Controls.Add(uptb); uptb.Dock = DockStyle.Top; count++; this.isUplond = false; } }
private void SetImages() { bool isSetDock = false; try { if (isDockTop) { int width = this.p_BackImags.Width; for (int i = 0; i < this.p_BackImags.Controls.Count; i++) { userCtrPictureEx ctl = (userCtrPictureEx)this.p_BackImags.Controls[i]; int height = Convert.ToInt32(width / ctl.Picture.ImageRatio); ctl.Size = new Size(width, height); if (isDockStateChanged) { ctl.Dock = DockStyle.Top; isSetDock = true; } } } else { int height = this.p_BackImags.Height; for (int i = 0; i < this.p_BackImags.Controls.Count; i++) { userCtrPictureEx ctl = (userCtrPictureEx)this.p_BackImags.Controls[i]; int width = Convert.ToInt32(height * ctl.Picture.ImageRatio); ctl.Size = new Size(width, height); if (isDockStateChanged) { ctl.Dock = DockStyle.Left; isSetDock = true; } } } } catch { } if (isSetDock) { this.isDockStateChanged = false; } //this.p_BackImags.Refresh(); }
private void Picture_MouseDoubleClick(object sender, MouseEventArgs e) { userCtrPicture s = (userCtrPicture)sender; for (int i = 0; i < this.p_RptImages.Controls.Count; i++) { userCtrPictureEx u = (userCtrPictureEx)this.p_RptImages.Controls[i]; if (u.Picture.FileName != s.FileName && u.Picture.IsSelected) { u.Picture.IsSelected = false; u.Picture.IsSelecting = true; u.Picture.Refresh(); } } string[] ss = new string[1]; ss[0] = s.FilePath; if (GetConfig.IsAddLocMap) { // if (this.frmLocMap == null || this.frmLocMap.IsDisposed) this.frmLocMap = new frmLocMap(s, word); //this.frmLocMap.init(); this.frmLocMap.ShowDialog(); for (int j = 0; j < this.p_RptImages.Controls.Count; j++) { userCtrPictureEx u = (userCtrPictureEx)this.p_RptImages.Controls[j]; if (s.Equals(u.Picture)) { u.l_Buttom.Text = ""; } } } else { Explorer(); iViewer.SelectImg(ss[0]); // if (iViewer == null || iViewer.IsDisposed) // iViewer = new ImageViewer(); // iViewer.init(ss); // iViewer.Show(); // iViewer.Activate(); } }
//定位图时刷新图片名 public void ReflashName(string name) { if (GetConfig.IsAddLocMap) { try { string CName = name; if (name.Contains("Mark")) { CName = name.Replace("Mark", ""); } userCtrPictureEx u = (userCtrPictureEx)this.p_PreferImages.Controls[CName]; u.l_Buttom.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private Control AddImageCtl(string Path, bool isMark, int i) { userCtrPictureEx ctl = new userCtrPictureEx(); ctl.Picture.SetCheckBoxVisible(false); ctl.LabelBorderStyle = userCtrPictureEx.LBorderStyle.All; ctl.Picture.MouseDoubleClick += new MouseEventHandler(Picture_MouseDoubleClick); ctl.Picture.LoadFile(Path); ctl.Picture.IsMark = isMark; int height = this.p_BackImags.Height; int width = this.p_BackImags.Width; if (this.isDockTop) { if (ctl.Picture.ImageRatio != 0) { height = Convert.ToInt32(width / ctl.Picture.ImageRatio); } ctl.Dock = DockStyle.Top; } else { if (ctl.Picture.ImageRatio != 0) { width = Convert.ToInt32(height * ctl.Picture.ImageRatio); } ctl.Dock = DockStyle.Left; } ctl.Name = ctl.Picture.FileName.Replace("Mark", ""); ctl.Size = new Size(width, height); ctl.l_Top.TextAlign = ContentAlignment.MiddleLeft; ctl.l_Top.BackColor = Color.LightGray; ctl.l_Top.ForeColor = Color.Blue; ctl.l_Top.Text = i.ToString(); ctl.l_Buttom.Text = ctl.Picture.FileName; return(ctl); }
/// <summary> /// 保存图像处理后的效果 /// </summary> /// <param name="image">新图像</param> /// <param name="Obj">图像数据库对象</param> /// <param name="xml">处理信息</param> /// <param name="name">旧图像名</param> /// <returns>是否保存成功</returns> public bool SaveMark(Image image, ImgObj Obj, string xml, ref string name) { if (!Directory.Exists(Dir)) { Directory.CreateDirectory(Dir); } MImage img = (MImage)Obj.MImage; if (xml == "" && name.Contains("Mark")) { img.MARK_IMAGE_PATH = ""; img.MARK_INF = ""; SIS_BLL.BImage bi = new SIS_BLL.BImage(); if (bi.Update(img, " where IMAGE_ID = " + img.IMAGE_ID) < 0) { return(false); } else { Obj.MarkImgPath = ""; Obj.MarkInf = ""; name = name.Replace("Mark", ""); string newpath = Dir + "\\" + name; userCtrPictureEx u = (userCtrPictureEx)this.p_PreferImages.Controls[name]; u.Picture.LoadFile(newpath); u.Picture.IsMark = false; u.l_Buttom.Text = name; this.CurrentCtlName = u.Picture.FileName; this.dbClick(u.Picture); return(true); } } else { string newPath = ""; string oldName = name; if (xml != "" && !name.Contains("Mark")) { name = "Mark" + name; newPath = Dir + "\\" + name; img.MARK_IMAGE_PATH = GetConfig.ServerImgDir + "/" + frmMainForm.examInf.ReqDateTime + "/" + frmMainForm.examInf.ExamAccessionNum + "/" + name; } else { newPath = Obj.MarkImgPath; oldName = name.Replace("Mark", ""); } image.Save(newPath); img.MARK_INF = xml; ImageCopy imgCopy = new ImageCopy(); if (imgCopy.FileUpLoad(img, newPath, true) != 1) { return(false); } else { Obj.MarkImgPath = newPath; Obj.MarkInf = xml; userCtrPictureEx u = (userCtrPictureEx)this.p_PreferImages.Controls[oldName]; u.Picture.LoadFile(newPath); u.Picture.IsMark = true; u.l_Buttom.Text = name; this.CurrentCtlName = u.Picture.FileName; this.dbClick(u.Picture); return(true); } } }
/// <summary> /// 删除图像 /// </summary> /// <param name="DelAll">是否删除全部</param> public void DeleteImage(bool DelAll) { List <Control> delControl = new List <Control>(); List <Control> printControl = new List <Control>(); bool HadCheck = false; if (this.p_RptImages.Controls.Count > 0) { //提示 int delImgCount = 0; for (int i = 0; i < this.p_RptImages.Controls.Count; i++) { userCtrPictureEx axf = (userCtrPictureEx)this.p_RptImages.Controls[i]; ImgObj imgobj = (ImgObj)axf.Picture.ImgObj; if (axf.Picture.IsSelecting || axf.Picture.IsSelected || DelAll == true) { delImgCount++; } } if (delImgCount > 1) { if (DialogResult.No == MessageBoxEx.Show("已选择" + delImgCount.ToString() + "幅图片,确定删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { return; } } //提示 for (int i = 0; i < this.p_RptImages.Controls.Count; i++) { try { userCtrPictureEx axf = (userCtrPictureEx)this.p_RptImages.Controls[i]; ImgObj imgobj = (ImgObj)axf.Picture.ImgObj; if (axf.Picture.IsSelecting || axf.Picture.IsSelected || DelAll == true) { if (!axf.Picture.GetCheck()) { imgobj.IsDeleted = true; delControl.Add(axf); if (!this.arrayImgDel.Contains(imgobj)) { this.arrayImgDel.Add(imgobj); } this.arrayImg.RemoveAt(i); } else { printControl.Add(axf); HadCheck = true; } } } catch { } } } for (int i = 0; i < delControl.Count; i++) { this.p_RptImages.Controls.Remove(delControl[i]); } if (HadCheck) { if (DialogResult.Yes == MessageBoxEx.Show("选择图像包含打印图像,是否删除?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { for (int i = 0; i < printControl.Count; i++) { userCtrPicture ctr = ((userCtrPictureEx)printControl[i]).Picture; ImgObj imgobj = (ImgObj)ctr.ImgObj; imgobj.IsDeleted = true; if (!this.arrayImgDel.Contains(imgobj)) { this.arrayImgDel.Add(imgobj); } this.arrayImg.Remove(imgobj); if (ctr.LocMapPath == "") { word.DelImg(ctr.FilePath); } else { word.DelImgWithLocMap(ctr.FilePath, ctr.LocMapPath); } this.p_RptImages.Controls.Remove(printControl[i]); } } } this.l_Count.Text = "共 " + this.p_RptImages.Controls.Count.ToString() + " 张"; }
private void DeleteImg(bool isAll) { if (this.p_PreferImages.Controls.Count > 0) { List <userCtrPictureEx> arrayDelCheckCtl = new List <userCtrPictureEx>(); List <userCtrPictureEx> arrayDelCtl = new List <userCtrPictureEx>(); for (int i = 0; i < this.p_PreferImages.Controls.Count; i++) { userCtrPictureEx axf = (userCtrPictureEx)this.p_PreferImages.Controls[i]; if (isAll) { arrayDelCtl.Add(axf); continue; } if (axf.Picture.IsSelecting) { if (axf.Picture.GetCheck()) { arrayDelCheckCtl.Add(axf); } else { arrayDelCtl.Add(axf); } } } if (!isAll && arrayDelCtl.Count == 0 && arrayDelCheckCtl.Count == 0) { return; } DialogResult dr; if (arrayDelCheckCtl.Count > 0) { if (!isAll) { dr = MessageBoxEx.Show("选择图像包含打印图像,打印图像不能删除,是否删除其它所选择图像?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } else { dr = MessageBoxEx.Show("该检查包含打印图像,打印图像不能删除,是否删除所有没打印图像?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } } else { if (!isAll) { dr = MessageBoxEx.Show("是否删除所选择图像?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } else { dr = MessageBoxEx.Show("是否删除该检查所有图像?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } } if (dr == DialogResult.OK) { ImageCopy imgCopy = new ImageCopy(); if (isAll) { for (int i = 0; i < arrayDelCtl.Count; i++) { System.IO.File.Delete(arrayDelCtl[i].Picture.FilePath); ImgObj obj = (ImgObj)arrayDelCtl[i].Picture.ImgObj; imgCopy.DeleteImg((SIS_Model.MImage)obj.MImage); } this.p_PreferImages.Controls.Clear(); this.dbClick(null); frmMainForm.examInf.ArrayImages.Clear(); } else { for (int i = 0; i < arrayDelCtl.Count; i++) { System.IO.File.Delete(arrayDelCtl[i].Picture.FilePath); this.p_PreferImages.Controls.Remove(arrayDelCtl[i]); ImgObj obj = (ImgObj)arrayDelCtl[i].Picture.ImgObj; imgCopy.DeleteImg((SIS_Model.MImage)obj.MImage); frmMainForm.examInf.ArrayImages.Remove(obj); if (obj.ImagePath.Substring(obj.ImagePath.LastIndexOf("\\") + 1) == this.CurrentCtlName) { this.dbClick(null); } } } } } this.l_Count.Text = "共 " + this.p_PreferImages.Controls.Count.ToString() + " 张"; }