public mdiSettings(DocumentCapture docCap) { //get AppPath AppPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); if (!AppPath.EndsWith(@"\")) AppPath += @"\"; InitializeComponent(); //open html file webBrowser1.Url = new Uri(@"file:\\" +AppPath + @"MDIhelp.htm"); //label17.Text = "Samples:\r\nTime/Date stamp $(time), in the format YYYY-MM-DD HH_MM_SS. "; //Document number $(num), which is an automatically incremented number for every file stored. cboColorMode.Items.Add("None"); cboColorMode.Items.Add("Monochrome_Normal"); cboColorMode.Items.Add("Monochrome_Enhanced_TIFF_Quality"); comboContrast.Items.Add(ImageConditioning.ContrastEnhancementValue.None.ToString()); comboContrast.Items.Add(ImageConditioning.ContrastEnhancementValue.Photo.ToString()); comboContrast.Items.Add(ImageConditioning.ContrastEnhancementValue.Black_text_on_white_background.ToString()); comboContrast.Items.Add(ImageConditioning.ContrastEnhancementValue.White_text_on_black_background.ToString()); comboBrightnessTreshold.Items.Add(ImageConditioning.ColorModeBrightnessThresholdValue.VeryDark.ToString()); comboBrightnessTreshold.Items.Add(ImageConditioning.ColorModeBrightnessThresholdValue.Dark.ToString()); comboBrightnessTreshold.Items.Add(ImageConditioning.ColorModeBrightnessThresholdValue.Normal.ToString()); comboBrightnessTreshold.Items.Add(ImageConditioning.ColorModeBrightnessThresholdValue.Bright.ToString()); comboBrightnessTreshold.Items.Add(ImageConditioning.ColorModeBrightnessThresholdValue.VeryBright.ToString()); comboImageRotation.Items.Add(ImageConditioning.ImageRotationValue.None.ToString()); comboImageRotation.Items.Add(ImageConditioning.ImageRotationValue.Degrees_90.ToString()); comboImageRotation.Items.Add(ImageConditioning.ImageRotationValue.Degrees_180.ToString()); comboImageRotation.Items.Add(ImageConditioning.ImageRotationValue.Degrees_270.ToString()); comboOutputCompression.Items.Insert(0, "None"); comboOutputCompression.Items.Insert(1, "JPEG"); comboOutputCompression.Items.Insert(2, "TIFF"); //the following did not work: //comboOutputCompression.Items.Add(ImageConditioning.OutputCompressionValue.Jpeg.ToString()); //comboOutputCompression.Items.Add(ImageConditioning.OutputCompressionValue.Bitmap.ToString()); //comboOutputCompression.Items.Add(ImageConditioning.OutputCompressionValue.TIFF.ToString()); comboTextEnhancement.Items.Add(ImageConditioning.TextEnhancementValue.None.ToString()); comboTextEnhancement.Items.Add(ImageConditioning.TextEnhancementValue.Low.ToString()); comboTextEnhancement.Items.Add(ImageConditioning.TextEnhancementValue.Medium.ToString()); comboTextEnhancement.Items.Add(ImageConditioning.TextEnhancementValue.High.ToString()); comboFocusCheck.Items.Add(DocumentCapture.FocusCheckValue.Disable.ToString()); comboFocusCheck.Items.Add(DocumentCapture.FocusCheckValue.Medium.ToString()); comboFocusCheck.Items.Add(DocumentCapture.FocusCheckValue.High.ToString()); m_docCap = docCap; //eMdiMail.ViewFinderSettings vSett = new eMdiMail.ViewFinderSettings(); readSettings(); }
private bool stopMDI() { bool bRet = false; if (doccap != null) { doccap.Dispose(); doccap = null; bRet = true; } return bRet; }
public static bool saveSettings(ref DocumentCapture docCap, string sXMLfile) { //ITCSSApi ss = new ITCSSApi(); string ssConfig = ""; ssConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DevInfo Action=\"Set\">\r\n"; ssConfig = "<Subsystem Name=\"Data Collection\">\r\n"; ssConfig += " <Group Name=\"Scanners\" Instance=\"0\">\r\n"; ssConfig += " <Group Name=\"Imager Settings\">\r\n"; ssConfig += " <Group Name=\"Document Imaging\">\r\n"; ssConfig += string.Format(" <Field Name=\"Focus Check\">{0}</Field>\r\n", (int)docCap.FocusCheck); ssConfig += string.Format(" <Field Name=\"Image/Area to Capture Ratio\">{0}</Field>\r\n", (int)docCap.ImageAreaCaptureRatio); ssConfig += string.Format(" <Field Name=\"Output Compression\">{0}</Field>\r\n",(int)docCap.OutputCompression); ssConfig += string.Format(" <Field Name=\"Output Compression Quality\">{0}</Field>\r\n",(int)docCap.OutputCompressionQuality); ssConfig += string.Format(" <Field Name=\"Perspective Correction\">{0}</Field>\r\n", (int)docCap.PerspectiveCorrection); ssConfig += string.Format(" <Field Name=\"Output Format\">0</Field>\r\n", (int)docCap.OutputCompression); //see docCap.OutputCompression, looks like used twice ssConfig += string.Format(" <Field Name=\"Color Mode Brightness Threshold\">{0}</Field>\r\n", (int)docCap.ColorModeBrightnessThreshold); ssConfig += string.Format(" <Field Name=\"Contrast Enhancement\">{0}</Field>\r\n", (int)docCap.ContrastEnhancement); ssConfig += string.Format(" <Field Name=\"Text Enhancement\">{0}</Field>\r\n",(int)docCap.TextEnhancement); ssConfig += string.Format(" <Field Name=\"Noise Reduction\">{0}</Field>\r\n",(int)docCap.NoiseReduction); ssConfig += string.Format(" <Field Name=\"Image Rotation\">{0}</Field>\r\n", (int)docCap.ImageRotation); //ssConfig += string.Format(" <Field Name=\"Anti-vignetting\">1</Field>\r\n", (int)docCap.; ssConfig += string.Format(" <Field Name=\"Image File Location\">{0}</Field>\r\n", escapeXML(docCap.CapturedDocumentLocation)); //do not use quotes around strings ssConfig += string.Format(" <Field Name=\"Document File Name\">{0}</Field>\r\n", escapeXML(docCap.FileNameTemplate)); //do not use quotes around strings ssConfig += string.Format(" <Field Name=\"Folder Memory Limit\">{0}</Field>\r\n", (int)docCap.FolderMemoryLimit); ssConfig += " </Group>\r\n"; ssConfig += " </Group>\r\n"; ssConfig += " </Group>\r\n"; ssConfig += "</Subsystem>\r\n"; try { using (StreamWriter sw = new StreamWriter(sXMLfile)) { sw.WriteLine(ssConfig); sw.Flush(); sw.Close(); } } catch (Exception) { } return true; }
private bool startMDI() { bool bRet = false; try { string sModel = getModelNumber(); if (sModel.StartsWith("CK7") || sModel.StartsWith("CN7") || sModel.StartsWith("CS40")) doccap = new DocumentCapture("Camera"); else throw new NotSupportedException("Only Cozumel or CS40 supported"); //get free space ulong freeBytesAvail, totalBytes, totalFree; if (GetDiskFreeSpaceEx("\\My Documents", out freeBytesAvail, out totalBytes, out totalFree)) statusBar1.Text = "Memory Limit=" + doccap.FolderMemoryLimit.ToString() + " free mem=" + totalFree.ToString(); else statusBar1.Text = "Memory Limit=" + doccap.FolderMemoryLimit.ToString(); doccap.FolderMemoryLimit = 0; doccap.Capture += new DocumentCaptureEventHandler(doccap_Capture); doccap.Error += new DocumentCaptureErrorEventHandler(doccap_Error); doccap.Guidance += new DocumentCaptureGuidanceEventHandler(doccap_Guidance); doccap.CapturedDocumentLocation = @"\My Documents"; try { doccap.ViewFinderEnable = true; }catch{} try { doccap.ManualTorchControl(DocumentCapture.ManualTorchControlType.TorchOn); short torchIntensStep = doccap.TorchIncrementValue; short torchMaxVal = doccap.TorchIntensityMaximumValue; short torchMinVal = doccap.TorchIntensityMinimumValue; short torchCurVal = doccap.TorchIntensitySetting; short torchNew = (short)( torchMaxVal % torchIntensStep ); torchNew = (short)(torchNew * torchIntensStep); } catch (DocumentCaptureException ex) { System.Diagnostics.Debug.WriteLine("Exception " + ex.Message + " in ManualTorchControl"); } doccap.ImageRotation = ImageConditioning.ImageRotationValue.Degrees_90; doccap.OutputCompression = ImageConditioning.OutputCompressionValue.Jpeg; doccap.OutputCompressionQuality = 100; if(doccap.isFlashConfigSupported) doccap.FlashMethod = DocumentCapture.FlashMethodType.NoFlash; //disable hardware trigger doccap.TriggerEnable = DocumentCapture.TriggerEnableValue.Disable; doccap.EnableDocumentCapture = DocumentCapture.EnableDocumentCaptureValue.Disable; try { doccap.SetButtonAction(DocumentCapture.ButtonID.Center, DocumentCapture.ButtonActionType.Scan); } catch { } enableCapture(true); bRet = true; } catch (DocumentCaptureFirmwareSupportException ex) { System.Windows.Forms.MessageBox.Show("Failed to init DocCapture: " + ex.Message + "\nDocumentCaptureFirmwareSupportException"); } catch (DocumentCaptureException ex) { System.Windows.Forms.MessageBox.Show("Failed to init DocCapture: " + ex.Message + "\nDid you install DC_NET.CAB"); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Failed to init DocCapture: " + ex.Message + "\nDid you install DC_NET.CAB"); } if (doccap == null) { MessageBox.Show("Cannot start without DocCap object. Will exit now!"); bRet = false; Application.Exit(); } return bRet; }
public static bool loadSettings(ref DocumentCapture docCap, string sXMLfile) { bool bRet = false; loadSettings(sXMLfile); return bRet; }