/// <summary> /// 图片填充PictureBox /// </summary> /// <param name="exinfo"></param> public override void GeneratePictureBoxFillImage(ExportInfo exinfo = null) { if (String.IsNullOrEmpty(PanelForm.GetShowStringValue())) { MessageBox.Show(this, "条码内容不能为空!"); return; } PicImage = GetBarCodeByZXingNet(PanelForm.GetShowStringValue(), PanelForm.GetWidthValue(), PanelForm.GetHeightValue()); AddPictureBox(PicImage, new TagInfo("barcode", PanelForm.GetShowStringValue())); }
/// <summary> /// 填充控件信息 /// </summary> /// <param name="img"></param> /// <param name="tag"></param> private void PicBoxFillImage(Image img, TagInfo tag) { if (tag.Type == "background") { SendToBack(); } else { SizeMode = PictureBoxSizeMode.StretchImage; Image = img; BringToFront(); } Size = new Size(PanelForm.GetWidthValue(), PanelForm.GetHeightValue()); Tag = tag; }
/// <summary> /// 图片填充PictureBox /// </summary> /// <param name="exinfo"></param> public override void GeneratePictureBoxFillImage(ExportInfo exinfo = null) { OpenFileDialog openFileDialog = null; if (exinfo != null) { PicImage = Image.FromFile(exinfo.taginfo.Info); PicImage = ZoomPicture(PicImage, PanelForm.GetWidthValue(), PanelForm.GetHeightValue()); } else { openFileDialog = OpenFileDialogSelectImage(); } AddPictureBox(PicImage, new TagInfo("image", openFileDialog.FileName)); }
/// <summary> /// 选择要添加的图片 /// </summary> /// <returns></returns> private OpenFileDialog OpenFileDialogSelectImage() { OpenFileDialog openFileDialog = new OpenFileDialog(); try { openFileDialog.InitialDirectory = System.Environment.CurrentDirectory; openFileDialog.Title = "选择要使用的图片"; openFileDialog.Filter = "图片文件|*.jpg;*.bmp;*.png;*.jpeg;*.gif"; if (DialogResult.OK == openFileDialog.ShowDialog()) { PicImage = Image.FromStream(openFileDialog.OpenFile()); PicImage = ZoomPicture(PicImage, PanelForm.GetWidthValue(), PanelForm.GetHeightValue()); } return(openFileDialog); } catch (Exception) { openFileDialog.Dispose(); return(null); } }