Ejemplo n.º 1
0
 private void btnScan_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         VsTwain.StartDevice();
         if (this.SelectScannerBeforScan && this.ScanSource == null)
         {
             if (!VsTwain.SelectSource())
             {
                 PersianMessageBox.Show(this, "هیچ اسکنری انتخاب نشده است");
                 return;
             }
             else
             {
                 this.ScanSource = VsTwain.GetSourceProductName(VsTwain.SourceIndex);
             }
         }
         VsTwain.Acquire();
         lblStatus.Text = "درحال اسکن تصویر...";
     }
     catch (Exception ex)
     {
         PersianMessageBox.Show("خطا" + "\r\n\r\n" + ex.Message);
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Ejemplo n.º 2
0
        private void VsTwain_ImageAcquired(object sender, EventArgs e)
        {
            lblStatus.Text = "درحال ذخیره تصویر...";
            string fileName     = Njit.Common.PersianCalendar.GetDate(DateTime.Now, "-") + " " + Njit.Common.PersianCalendar.GetTime(DateTime.Now, "-", true, true);
            string documentPath = Path.Combine(tempDirectory, fileName + ".tiff").ToString();
            int    i            = 0;

            while (System.IO.File.Exists(documentPath))
            {
                documentPath = Path.Combine(tempDirectory, fileName + "(" + (++i).ToString() + ")" + ".tiff").ToString();
            }
            try
            {
                VsTwain.FileFormat = Vintasoft.Twain.FileFormat.TiffMulti;
                VsTwain.SaveImage(0, documentPath);
                VsTwain.DeleteImage(0);
            }
            catch (Exception ex)
            {
                PersianMessageBox.Show(this, "خطا در ذخیره فایل اسکن شده" + "\r\n\r\n" + ex.Message);
                return;
            }
            if (checkBoxInsertFilesIntoCurrentPosition.Checked)
            {
                imageViewer.InsertFile(documentPath);
            }
            else
            {
                imageViewer.AddFile(documentPath);
            }
            lblStatus.Text = "در حال اعمال روشنایی و کنتراست بر روی تصویر...";
            SetImageBrightnessAndContrast(documentPath);
        }
Ejemplo n.º 3
0
 private void btnSelectScanner_Click(object sender, EventArgs e)
 {
     try
     {
         VsTwain.StartDevice();
         if (VsTwain.SelectSource())
         {
             this.ScanSource = VsTwain.GetSourceProductName(VsTwain.SourceIndex);
         }
     }
     catch (Exception ex)
     {
         PersianMessageBox.Show("خطا" + "\r\n" + ex.Message);
     }
 }