public void InitData(PrintSettingParam setting) { this.SettingParam = setting; var imageList = setting.Images; if (imageList != null) { this.Images = imageList.Select(x => new ImageParamEdit { YuanImg = x.YuanImg, DetailImg = x.YuanImg, SuoImg = ImageUtil.CreateThumbnailImage(x.YuanImg, 154, 134), ImagePath = x.ImagePath, ImageType = x.ImageType }).ToList(); //写死赋值保存的图片 this.SaveImg = this.Images.FirstOrDefault(); } else { this.Images = new List <ImageParamEdit>(); } }
/// <summary> /// 加入到图片队列 /// </summary> public void PushImages(Image img, string imgPath, string imgType, ResoponseResult resoponse = null) { if (resoponse != null) { resoponse.Count++; resoponse.Code = "ok"; resoponse.Message = $"上传{resoponse.Count}张图片成功!"; } var detailW = this.detailPic.Size.Width; var detailH = this.detailPic.Size.Height; var width = 150; var height = 150; //构建Pic容器 var x = 20; var y = 0; var tag = 0; //获取最后一个Pic var lastPic = this.PicList.LastOrDefault(); if (lastPic != null) { x = lastPic.Location.X + 170; y = lastPic.Location.Y; tag = Convert.ToInt16(lastPic.Tag) + 1; } PictureBox pic = new PictureBox(); pic.Location = new System.Drawing.Point(x, y); pic.Name = "pic" + tag; pic.Tag = tag; pic.Size = new System.Drawing.Size(width, height); pic.TabIndex = 0; pic.TabStop = false; pic.Cursor = Cursors.Hand; pic.Click += picPicBox_Click; pic.Paint += picPicBox_Paint; var imgParam = new ImageParamEdit { YuanImg = img, SuoImg = ImageUtil.CreateThumbnailImage(img, width, height), DetailImg = ImageUtil.CreateThumbnailImage(img, detailW, detailH), IsUpImg = true, ImagePath = imgPath, ImageType = imgType }; pic.Image = imgParam.SuoImg; this.PicList.Add(pic); this.Images.Add(imgParam); //添加缩略图 if (this.picPanel.InvokeRequired) { ThreadMethood t = () => { this.picPanel.Controls.Add(pic); this.SetDetailImg(); }; this.picPanel.Invoke(t); } else { this.picPanel.Controls.Add(pic); this.SetDetailImg(); } }