private void AcquireBuffered_Click(object sender, EventArgs e) { if (SelectedSource != 0) { TwainAPI.DTWAIN_SetBlankPageDetection(SelectedSource, 98.5, (int)TwainAPI.DTWAIN_BP_AUTODISCARD_ANY, DiscardBlankPages.Checked ? 1 : 0); DTWAIN_ARRAY acquireArray = TwainAPI.DTWAIN_CreateAcquisitionArray(); this.Enabled = false; int status = 0; if (TwainAPI.DTWAIN_AcquireBufferedEx(SelectedSource, TwainAPI.DTWAIN_PT_DEFAULT, TwainAPI.DTWAIN_ACQUIREALL, UseSourceUI.Checked ? 1 : 0, 0, acquireArray, ref status) == 0) { MessageBox.Show("Acquisition Failed", "TWAIN Error"); return; } if (TwainAPI.DTWAIN_ArrayGetCount(acquireArray) == 0) { MessageBox.Show("No Images Acquired", ""); return; } // Display the DIBS //... DIBDisplayerDlg sDIBDlg = new DIBDisplayerDlg(acquireArray); sDIBDlg.ShowDialog(); TwainAPI.DTWAIN_DestroyAcquisitionArray(acquireArray, 0); this.Enabled = true; } }
private void CustomSelectSource_Load(object sender, EventArgs e) { sourceSelected = false; DTWAIN_ARRAY SourceArray = 0; TwainAPI.DTWAIN_EnumSources(ref SourceArray); int nCount = TwainAPI.DTWAIN_ArrayGetCount(SourceArray); if (nCount <= 0) { Close(); } // Display the sources DTWAIN_SOURCE CurSource = 0; for (int i = 0; i < nCount; ++i) { StringBuilder szName = new StringBuilder(256); TwainAPI.DTWAIN_ArrayGetAtLong(SourceArray, i, ref CurSource); TwainAPI.DTWAIN_GetSourceProductName(CurSource, szName, 255); listSources.Items.Add(szName.ToString()); } listSources.SelectedIndex = 0; // Display Info about sources string sText = nCount.ToString() + " TWAIN Source(s) Available for Selection"; editSourceInfo.Text = sText; }
private void SourcePropertiesDlg_Load(object sender, EventArgs e) { StringBuilder szInfo = new StringBuilder(256); TwainAPI.DTWAIN_GetSourceProductName(m_Source, szInfo, 255); this.edProductName.Text = szInfo.ToString(); TwainAPI.DTWAIN_GetSourceProductFamily(m_Source, szInfo, 255); this.edFamilyName.Text = szInfo.ToString(); TwainAPI.DTWAIN_GetSourceManufacturer(m_Source, szInfo, 255); this.edManufacturer.Text = szInfo.ToString(); TwainAPI.DTWAIN_GetSourceVersionInfo(m_Source, szInfo, 255); this.edVersionInfo.Text = szInfo.ToString(); int lMajor = 0, lMinor = 0; TwainAPI.DTWAIN_GetSourceVersionNumber(m_Source, ref lMajor, ref lMinor); string sVersion = lMajor.ToString() + "." + lMinor.ToString(); this.edVersion.Text = sVersion; DTWAIN_ARRAY AllCaps = 0; int Val = 0; TwainAPI.DTWAIN_EnumSupportedCaps(m_Source, ref AllCaps); int nSize = TwainAPI.DTWAIN_ArrayGetCount(AllCaps); for (int i = 0; i < nSize; ++i) { // get the cap value TwainAPI.DTWAIN_ArrayGetAtLong(AllCaps, i, ref Val); // get the name from the cap TwainAPI.DTWAIN_GetNameFromCap(Val, szInfo, 255); this.listCaps.Items.Add(szInfo.ToString()); } this.edTotalCaps.Text = nSize.ToString(); TwainAPI.DTWAIN_EnumCustomCaps(m_Source, ref AllCaps); this.edCustomCaps.Text = TwainAPI.DTWAIN_ArrayGetCount(AllCaps).ToString(); TwainAPI.DTWAIN_EnumExtendedCaps(m_Source, ref AllCaps); this.edExtendedCaps.Text = TwainAPI.DTWAIN_ArrayGetCount(AllCaps).ToString(); }