//打印无图 private void PrintDelImg() { string str = ""; List <ImgObj> arraySaveImg = this.frmRptImg.SaveImgs(); for (int i = 0; i < arraySaveImg.Count; i++) { ImgObj obj = (ImgObj)arraySaveImg[i]; if (obj.IsCheck) { string FilePath = obj.MarkImgPath != "" ? obj.MarkImgPath : obj.ImagePath; if (!GetConfig.IsAddLocMap) { // word.InsertImg(FilePath); word.DelImg(FilePath); } else { // word.InsertImgWithLocMap(FilePath, obj.LocMapPath); word.DelImgWithLocMap(FilePath, obj.LocMapPath); } } } //this.Print(); word.PrintDocument(); initAddImg(); }
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); }
private void PreferAddImage(string newFileName, string newPath) { ImgObj obj = this.AddImgObj(newFileName, newPath); if (obj != null) { this.p_PreferImages.Controls.Add(this.AddImageCtl(obj, this.p_PreferImages.Controls.Count + 1)); } this.l_Count.Text = "共 " + this.p_PreferImages.Controls.Count.ToString() + " 张"; }
private void ClearPtbImage() { this.CurrentObj = null; this.drawArea.Image = null; this.lb_ImageName.Text = ""; this.drawArea.GraphicsList.Clear(); this.drawArea.Controls.Clear(); this.drawArea.Initialize(); this.sourceImage = null; this.filteredImage = null; this.xml = ""; }
public List <ImgObj> ArrReportImg(List <ImgObj> array, string oldstr, string newstr) { List <ImgObj> arr = new List <ImgObj>(); for (int i = 0; i < array.Count; i++) { ImgObj obj = ((ImgObj)array[i]).Copy(); obj.ImagePath = obj.ImagePath.Replace(oldstr, newstr); arr.Add(obj); } return(arr); }
/// <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); }
private ImgObj AddImgObj(string newFileName, string path) { SIS_Model.MImage Mimage = new SIS_Model.MImage(); Mimage.EXAM_ACCESSION_NUM = frmMainForm.examInf.ExamAccessionNum; Mimage.IMAGE_PATH = GetConfig.ServerImgDir + "/" + frmMainForm.examInf.ReqDateTime + "/" + frmMainForm.examInf.ExamAccessionNum + "/" + newFileName;//linux上文件保存路径 ImageCopy imgCopy = new ImageCopy(); if (imgCopy.FileUpLoad(Mimage, path, false) != 1) { return(null); } ImgObj imgObj = new ImgObj(path, false, Mimage); frmMainForm.examInf.ArrayImages.Add(imgObj); this.arrayImg.Add(imgObj); return(imgObj); }
public ImgObj Copy() { ImgObj ob = new ImgObj(); ob.ImagePath = this.imagePath; ob.inf = this.inf; ob.isCheck = this.isCheck; ob.isDel = this.isDel; ob.isReport = this.isReport; ob.isSaved = this.isSaved; ob.locMapObj = this.locMapObj; ob.locMapPath = this.locMapPath; ob.model = this.model; ob.serverpath = this.serverpath; ob.changeImagePath = this.changeImagePath; ob.markImgPath = this.markImgPath; ob.markInf = this.markInf; return(ob); }
public void LoadImages() { this.p_PreferImages.Controls.Clear(); if (frmMainForm.examInf.ExamAccessionNum != "" && frmMainForm.examInf.ArrayImages.Count > 0) { int width = this.p_PreferImages.Width; Control[] ctls = new Control[frmMainForm.examInf.ArrayImages.Count]; for (int i = 0; i < frmMainForm.examInf.ArrayImages.Count; i++) { ImgObj obj = (ImgObj)frmMainForm.examInf.ArrayImages[i]; ctls[i] = this.AddImageCtl(obj, i); } for (int i = ctls.Length - 1; i >= 0; i--) { this.p_PreferImages.Controls.Add(ctls[i]); } } this.l_Count.Text = "共 " + this.p_PreferImages.Controls.Count.ToString() + " 张"; }
/// <summary> /// 保存图片并记录入图片表(注意是否打勾) /// </summary> /// <param name="arrayImg"></param> public bool SaveImage(List <ImgObj> arrayImg, SIS_Model.MWorkList worklist) { bool isSuccess = true; int j = 0; for (int i = 0; i < arrayImg.Count; i++) { ImgObj obj = (ImgObj)arrayImg[i]; MImage model = (MImage)obj.MImage; if (model == null) { model = new MImage(); model.IMAGE_PATH = CreateServerPath(obj.ImagePath); model.EXAM_ACCESSION_NUM = worklist.EXAM_ACCESSION_NUM; } else { model.IMAGE_PATH = CreateServerPath(obj.ImagePath); } model.IS_PRINT = (obj.IsCheck == true ? 1 : 0); model.IMAGE_DATE = System.DateTime.Now; if (obj.IsDeleted) { imgCopy.DeleteImg(model); } else { if (imgCopy.FileUpLoad(model, obj.ImagePath, false) != 1) { // MessageBox.Show("图片" + obj.ImagePath + "保存失败,请检查网络连接情况", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); isSuccess = false; } else { j++; } } } worklist.IMAGE_COUNTS = j; return(isSuccess); }
public void AddPreferImage(Image image) { if (frmMainForm.examInf.ExamAccessionNum != "" && frmMainForm.examInf.ReqDateTime != "") { if (!Directory.Exists(Dir)) { Directory.CreateDirectory(Dir); } FileOperator ope = new FileOperator(); string newFileName = ope.GetNewFileName(Dir, frmMainForm.examInf.ExamAccessionNum, ".jpg"); string path = Dir + newFileName; FileOperator.SaveAsJPEG(image, path, GetConfig.IMS_Quality); ImgObj obj = this.AddImgObj(newFileName, path); if (obj != null) { AddNewImage ani = new AddNewImage(RptAddImage); this.p_RptImages.BeginInvoke(ani, new object[] { obj }); } } this.l_Count.Text = "共 " + this.p_RptImages.Controls.Count.ToString() + " 张"; }
/*private void Picture_MouseDoubleClick(object sender, MouseEventArgs e) * { * * userCtrPicture s = (userCtrPicture)sender; * userCtrPictureEx u = null; * for (int i = 0; i < this.p_RptImages.Controls.Count; i++) * { * 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(); * break; * } * } * 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); * DialogResult dr = this.frmLocMap.ShowDialog(); * // if (dr == DialogResult.OK) * u.l_Buttom.Text= ""; * * * } * else * { * Explorer(); * iViewer.SelectImg(s.FileName); * //if (iViewer == null || iViewer.IsDisposed) * // iViewer = new ImageViewer(); * //iViewer.init(ss); * iViewer.Show(); * iViewer.Activate(); * } * }*/ public void Explorer() { List <string> filePaths = new List <string>(); for (int i = 0; i < arrayImg.Count; i++) { ImgObj obj = (ImgObj)arrayImg[i]; if (!obj.IsDeleted) { string ImagePath = obj.MarkImgPath != "" ? obj.MarkImgPath : obj.ImagePath; filePaths.Add(ImagePath); } } if (iViewer == null || iViewer.IsDisposed) { iViewer = new ImageViewer(); } iViewer.init(filePaths.ToArray()); iViewer.Show(); iViewer.Activate(); }
/// <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); } } }
private void RptAddImage(ImgObj obj) { this.p_RptImages.Controls.Add(this.AddImageCtl(obj, this.p_RptImages.Controls.Count + 1)); this.l_Count.Text = "共 " + this.p_RptImages.Controls.Count.ToString() + " 张"; }
/// <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() + " 张"; }
/// <summary> /// 加载本地图片 /// </summary> /// <param name="saveDir"></param> //private void LoadLocalImage(string saveDir) //{ // string path = GetConfig.TempPath + "\\" + Convert.ToDateTime(mWorklist.REQ_DATE_TIME).ToString("yyyyMMdd") + "\\" + mWorklist.EXAM_ACCESSION_NUM; // if (!Directory.Exists(path)) // Directory.CreateDirectory(path); // string[] files = Directory.GetFiles(path, "*.jpg"); // for (int i = 0; i < files.Length; i++) // { // string temppath = saveDir + "\\" + files[i].Substring(files[i].LastIndexOf("\\") + 1); // File.Copy(files[i].ToString(), temppath, true); // ImgObj imgObj = new ImgObj(temppath, false, null); // arrayImg.Add(imgObj); // } //} /// <summary> /// 加载本次检查的图片 /// </summary> /// <returns>返回值0:下载成功;-1下载失败</returns> private int DownLoadPicture(string saveDir) { try { string Message = "", Message2 = "", Serverpath = "", temppath = "", MarkPath = ""; DataTable dt = Bimage.GetList("1=1 and EXAM_ACCESSION_NUM='" + mWorklist.EXAM_ACCESSION_NUM + "'order by IS_PRINT DESC"); for (int i = 0; i < dt.Rows.Count; i++) { fileTranfer.ConnServer();//2010-03-17修改 Serverpath = dt.Rows[i]["IMAGE_PATH"].ToString(); temppath = saveDir.TrimEnd('\\') + "\\" + Serverpath.Substring(Serverpath.LastIndexOf("\\") + 1); switch (fileTranfer.FileDown(Serverpath, temppath)) { case 1: MImage Mimg = (MImage)Bimage.GetModel(dt.Rows[i]); ImgObj imgObj = new ImgObj(temppath, Convert.ToBoolean(Mimg.IS_PRINT), Mimg); arrayImg.Add(imgObj); break; case -1: Message2 += Serverpath + ","; break; case -2: Message += Serverpath + ","; break; default: break; } if (dt.Rows[i]["MARK_IMAGE_PATH"].ToString() != "") { MarkPath = dt.Rows[i]["MARK_IMAGE_PATH"].ToString(); temppath = saveDir + "\\" + MarkPath.Substring(MarkPath.LastIndexOf("/") + 1); switch (fileTranfer.FileDown(MarkPath, temppath))//下载处理后的图像 { case 1: arrayImg[arrayImg.Count - 1].MarkImgPath = temppath; arrayImg[arrayImg.Count - 1].MarkInf = dt.Rows[i]["MARK_INF"].ToString();//记录图像处理信息 break; case -1: Message2 += MarkPath + ","; break; case -2: Message += MarkPath + ","; break; default: break; } } if (GetConfig.IsAddLocMap) { this.DownLoadLocMap(saveDir, dt.Rows[i]["IMAGE_ID"].ToString(), arrayImg.Count - 1);//下载定位图 } } if (Message != "") { Message = "下载" + Message + "文件失败!"; } if (Message2 != "") { Message += "服务器图片:" + Message2 + "不存在!"; } if (Message != "") { MessageBox.Show(Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(0); } catch { //MessageBox.Show("下载图像失败"); return(-1); } }