/// <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="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { UnitechDSDll.PreviewStop(); //移除当前的扫描响应事件处理方法 Scanner.GetScanner().OnGetBarcodeEvent -= Scanner_OnGetBarcodeEvent; //使扫描不可用,即不可发红外光 Scanner.GetScanner().Close(); try { FrmParent.ParentForm.pbPreview.Visible = false; FrmParent.ParentForm.pbPreview.Parent = FrmParent.ParentForm.pnlAbout; } catch { } if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }
/// <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; }