/// <summary> /// 切换 节点/图片 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tcScan_SelectedIndexChanged(object sender, EventArgs e) { if (tcScan.SelectedIndex == 0) { lblResult.Text = "扫描/录入单号"; btnConfirm.Enabled = true; } else { lblResult.Text = "拍摄/保存图片"; btnConfirm.Enabled = false; Cursor.Current = Cursors.WaitCursor; UnitechDSDll.PreviewStop(); UnitechDSDll.PreviewStart(); Cursor.Current = Cursors.Default; } }
/// <summary> /// 显示图片/拍摄预览 /// </summary> private void lbPicList_SelectedIndexChanged(object sender, EventArgs e) { PicNameAndPath pic = lbPicList.SelectedItem as PicNameAndPath; if (pic == null) { return; } if (!string.IsNullOrEmpty(pic.PicPath)) { bool flag = UnitechDSDll.PreviewStop(); FrmParent.ParentForm.pbPreview.Image = new Bitmap(pic.PicPath); lbPicList.Enabled = true; btnCamera.Text = "重拍"; } else { btnCamera.Text = "拍摄"; bool flag = UnitechDSDll.PreviewStart(); lbPicList.Enabled = false; } }
/// <summary> /// 拍摄/重拍 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCamera_Click(object sender, EventArgs e) { btnCamera.Enabled = false; if (btnCamera.Text == "重拍") { btnCamera.Text = "拍摄"; UnitechDSDll.PreviewStart(); } else { Cursor.Current = Cursors.WaitCursor; PicNameAndPath pic = lbPicList.SelectedItem as PicNameAndPath; string parentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase.ToString()) + "\\tempPic\\"; if (!Directory.Exists(parentPath)) { Directory.CreateDirectory(parentPath); } string filePath = parentPath + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg"; if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } if (UnitechDSDll.SnapPicture(filePath)) { pic.PicPath = filePath; while (!File.Exists(pic.PicPath)) { Thread.Sleep(300); } UnitechDSDll.PreviewStart(); UnitechDSDll.PreviewStop(); lbPicList_SelectedIndexChanged(sender, e); } Cursor.Current = Cursors.Default; } btnCamera.Enabled = true; }