Ejemplo n.º 1
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);
        }