예제 #1
0
        /// <summary>
        /// 删除图片
        /// </summary>
        private void btnRemovePic_Click(object sender, EventArgs e)
        {
            //if (lbPicList.Items.Count > 1)
            //{
            //if (btnCamera.Text == "拍摄")
            //{
            //    txtLog.Text += "请先拍摄当前图片!\r\n";
            //    //MessageBox.Show("请先拍摄当前图片!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
            //    return;
            //}
            PicNameAndPath pic = lbPicList.SelectedItem as PicNameAndPath;

            if (pic != null)
            {
                lbPicList.Items.Remove(pic);
            }
            if (lbPicList.Items.Count == 0)
            {
                picCaptrue.Image     = null;
                btnRemovePic.Enabled = false;
            }
            else
            {
                lbPicList.SelectedIndex = lbPicList.Items.Count - 1;
            }
            //}
        }
예제 #2
0
        /// <summary>
        /// 添加图片
        /// </summary>
        private void btnAddPic_Click(object sender, EventArgs e)
        {
            //if (btnCamera.Text == "拍摄")
            //{
            //    txtLog.Text += "请先拍摄当前图片!\r\n";
            //    //MessageBox.Show("请先拍摄当前图片!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
            //    return;
            //}
            //_PicCount++;
            //PicNameAndPath pic = new PicNameAndPath { PicName = "P" + _PicCount, PicPath = string.Empty };
            //lbPicList.Items.Add(pic);
            //lbPicList.SelectedItem = pic;

            try
            {
                btnAddPic.Enabled = false;
                //清空/创建缓存图片目录
                if (Directory.Exists(jpgFilePath))
                {
                    Directory.Delete(jpgFilePath, true);
                }
                Directory.CreateDirectory(jpgFilePath);
                if (!Directory.Exists(tempPicPath))
                {
                    Directory.CreateDirectory(tempPicPath);
                }
                System.Diagnostics.Process.Start(filePathExe, null).WaitForExit();
                if (File.Exists(jpgFilePath + jpgFileName))
                {
                    //已在拍照界面拍照
                    foreach (string fileName in Directory.GetFiles(jpgFilePath))
                    {
                        if (!fileName.Contains(jpgFileName))
                        {
                            _PicCount++;
                            string newTempPath = tempPicPath + Path.GetFileName(fileName);
                            File.Move(fileName, newTempPath);
                            PicNameAndPath pic = new PicNameAndPath {
                                PicName = "P" + _PicCount, PicPath = newTempPath
                            };
                            lbPicList.Items.Add(pic);
                        }
                        lbPicList.SelectedIndex = 0;
                        btnRemovePic.Enabled    = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("调用相机模块失败:" + ex.Message);
            }
            finally {
                btnAddPic.Enabled = true;
            }
        }
예제 #3
0
 /// <summary>
 /// 拍摄/重拍
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnCamera_Click(object sender, EventArgs e)
 {
     FrmParent.ParentForm.ResetReturnDelay();
     btnCamera.Enabled = false;
     if (btnCamera.Text == "重拍")
     {
         btnCamera.Text = "拍摄";
         //UnitechDSDll.PreviewStart();
         CAMView(true);
     }
     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);
         }
         if (!Directory.Exists(parentPath.Replace("tempPic", "TEMP")))
         {
             Directory.CreateDirectory(parentPath.Replace("tempPic", "TEMP"));
         }
         string filePath = parentPath + DateTime.Now.ToString("yyyyMMddHHmmss");// +".jpg";
         if (System.IO.File.Exists(filePath))
         {
             System.IO.File.Delete(filePath);
         }
         if (System.IO.File.Exists(filePath))
         {
             System.IO.File.Delete(filePath.Replace("tempPic", "TEMP"));
         }
         FrmParent.ParentForm.CamSdk.CamCapture(filePath);
         pic.PicPath = filePath;
         FrmParent.ParentForm.CamSdk.CamMakeThumbnailImage(filePath.Replace("tempPic", "TEMP"));
         Thread.Sleep(666);
         lbPicList_SelectedIndexChanged(sender, e);
         //FrmParent.ParentForm.CamSdk.CamPreview(false);
         //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;
 }
예제 #4
0
        /// <summary>
        /// 初始化签收照片列表
        /// </summary>
        private void InitPhoto()
        {
            _PicCount       = 1;
            pbPreview.Image = null;
            lbPicList.Items.Clear();
            lbPicList.DisplayMember = "PicName";
            lbPicList.ValueMember   = "PicPath";
            PicNameAndPath pic = new PicNameAndPath {
                PicName = "P" + _PicCount, PicPath = string.Empty
            };

            lbPicList.Items.Add(pic);
            lbPicList.SelectedItem = pic;
        }
예제 #5
0
        /// <summary>
        /// 添加图片
        /// </summary>
        private void btnAddPic_Click(object sender, EventArgs e)
        {
            if (btnCamera.Text == "拍摄")
            {
                txtLog.Text += "请先拍摄当前图片!\r\n";
                //MessageBox.Show("请先拍摄当前图片!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                return;
            }
            _PicCount++;
            PicNameAndPath pic = new PicNameAndPath {
                PicName = "P" + _PicCount, PicPath = string.Empty
            };

            lbPicList.Items.Add(pic);
            lbPicList.SelectedItem = pic;
        }
예제 #6
0
 /// <summary>
 /// 删除图片
 /// </summary>
 private void btnRemovePic_Click(object sender, EventArgs e)
 {
     if (lbPicList.Items.Count > 1)
     {
         if (btnCamera.Text == "拍摄")
         {
             txtLog.Text += "请先拍摄当前图片!\r\n";
             //MessageBox.Show("请先拍摄当前图片!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
             return;
         }
         PicNameAndPath pic = lbPicList.SelectedItem as PicNameAndPath;
         if (pic != null)
         {
             lbPicList.Items.Remove(pic);
         }
         lbPicList.SelectedIndex = lbPicList.Items.Count - 1;
     }
 }
예제 #7
0
        /// <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))
            {
                CAMView(false);
                //bool flag = UnitechDSDll.PreviewStop();
                try
                {
                    pbPreview.Image = new Bitmap(pic.PicPath.Replace("tempPic", "TEMP"));
                }
                catch
                {
                }
                //try
                //{
                //    pbPreview.Image = new Bitmap(pic.PicPath);
                //}
                //catch
                //{
                //    pbPreview.Image = new Bitmap(pic.PicPath.Replace("tempPic", "TEMP"));
                //}
                pbPreview.Update();
                lbPicList.Enabled = true;
                btnCamera.Text    = "重拍";
            }
            else
            {
                if (tcScan.SelectedIndex == 1)
                {
                    Cursor.Current = Cursors.WaitCursor;
                    CAMView(true);
                    Cursor.Current = Cursors.Default;
                }
                btnCamera.Text = "拍摄";
                //bool flag = UnitechDSDll.PreviewStart();
                lbPicList.Enabled = false;
            }
        }
예제 #8
0
        /// <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;
            }
        }
예제 #9
0
 /// <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;
 }