private void btnSetCapability_Click(object sender, EventArgs e) { List <string> tempList = new List <string>(); for (int i = 0; i <= m_TwainManager.SourceCount - 1; i++) { tempList.Add(m_TwainManager.SourceNameItems(Convert.ToInt16(i))); } SourceListWrapper tempSourceListWrapper = new SourceListWrapper(tempList); int iSelectIndex = tempSourceListWrapper.SelectSource(); if (iSelectIndex == -1) { return; } else { m_TwainManager.SelectSourceByIndex(iSelectIndex); m_TwainManager.OpenSource(); m_TwainManager.Capability = (Dynamsoft.TWAIN.Enums.TWCapability) 0x8001; m_TwainManager.CapType = Dynamsoft.TWAIN.Enums.TWCapType.TWON_ONEVALUE; m_TwainManager.CapValue = 1; bool bRet = m_TwainManager.CapSet(); double dblValue = m_TwainManager.CapValue; if (bRet) { MessageBox.Show("Successful."); } else { MessageBox.Show("Failed."); } } }
private void cbxSources_SelectedIndexChanged(object sender, EventArgs e) { if (((ComboBox)sender).SelectedIndex >= 0 && ((ComboBox)sender).SelectedIndex < m_TwainManager.SourceCount) { m_TwainManager.SelectSourceByIndex(cbxSources.SelectedIndex); m_TwainManager.OpenSource(); m_TwainManager.ResetImageLayout(); Margin tempMargin = m_TwainManager.GetImageLayout(); fDefaultFrameLeft = tempMargin.Left; fDefaultFrameTop = tempMargin.Top; fDefaultFrameRight = tempMargin.Right; fDefaultFrameBottom = tempMargin.Bottom; fDefaultFrameLeft = (float)((int)(fDefaultFrameLeft * 10)) / 10; fDefaultFrameTop = (float)((int)(fDefaultFrameTop * 10)) / 10; fDefaultFrameRight = (float)((int)(fDefaultFrameRight * 10)) / 10; fDefaultFrameBottom = (float)((int)(fDefaultFrameBottom * 10)) / 10; edtFrameLeft.Text = fDefaultFrameLeft.ToString(); edtFrameTop.Text = fDefaultFrameTop.ToString(); edtFrameRight.Text = fDefaultFrameRight.ToString(); edtFrameBottom.Text = fDefaultFrameBottom.ToString(); lblFrameLeft.Text = string.Format("(0 ~ " + fDefaultFrameRight.ToString() + ")"); lblFrameTop.Text = string.Format("(0 ~ " + fDefaultFrameBottom.ToString() + ")"); lblFrameRight.Text = string.Format("(0 ~ " + fDefaultFrameRight.ToString() + ")"); lblFrameBottom.Text = string.Format("(0 ~ " + fDefaultFrameBottom.ToString() + ")"); } }
private void btnScan_Click(object sender, EventArgs e) { //m_TwainManager.SelectSource(); //m_TwainManager.OpenSource(); //m_TwainManager.IfAutoFeed = true; //m_TwainManager.IfFeederEnabled = true; //m_TwainManager.IfShowUI = false; //m_TwainManager.AcquireImage(this as IAcquireCallback); //dsViewer1.Visible = true; List <string> tempList = new List <string>(); for (int i = 0; i < m_TwainManager.SourceCount; i++) { tempList.Add(m_TwainManager.SourceNameItems((short)i)); } SourceListWrapper tempSourceListWrapper = new SourceListWrapper(tempList); int iSelectIndex = tempSourceListWrapper.SelectSource(); if (iSelectIndex == -1) { return; } m_TwainManager.SelectSourceByIndex((short)iSelectIndex); m_TwainManager.OpenSource(); m_TwainManager.IfAutoFeed = true; m_TwainManager.IfFeederEnabled = true; m_TwainManager.IfShowUI = false; m_TwainManager.AcquireImage(this as IAcquireCallback); dsViewer1.Visible = true; }
public bool SelectSource() { bool bRet = false; Console.WriteLine("Select a scanner:"); short sSourceCount = m_TwainManager.SourceCount; for (short sIndex = 0; sIndex < sSourceCount; sIndex++) { Console.WriteLine(sIndex.ToString() + ". " + m_TwainManager.SourceNameItems(sIndex)); } Console.WriteLine("Enter the scanner index:"); string temp = Console.ReadLine(); int res = Int32.Parse(temp); if (res > -1 && res < m_TwainManager.SourceCount) { bRet = m_TwainManager.SelectSourceByIndex((short)res); Console.WriteLine("Current Source name: " + m_TwainManager.CurrentSourceName); } if (!bRet) { Console.WriteLine("Fail to select source."); } return(bRet); }
private void lbScan_MouseDown(object sender, MouseButtonEventArgs e) { string key = "active/" + "scan_now"; if (!Window1.icons.ContainsKey(key)) { try { Window1.icons.Add(key, new ImageBrush(new BitmapImage(new Uri(Window1.imageDirectory + key + ".png", UriKind.RelativeOrAbsolute)))); } catch { } } try { lbScan.Background = Window1.icons[key]; } catch { } if (twain != null) { if (!IsFrameworkSatisfied()) { MessageBox.Show("WPF requires .NET Framework 3.5 SP1 or above. Please upgrade your .NET Framework.", "WpfControlsDemo", MessageBoxButton.OK, MessageBoxImage.Information); return; } twain.SelectSourceByIndex(cbxSources.SelectedIndex); twain.OpenSource(); twain.IfDisableSourceAfterAcquire = true; twain.IfShowUI = ckbShowUI.IsChecked.Value; twain.IfFeederEnabled = ckbADF.IsChecked.Value; twain.IfDuplexEnabled = ckbDuplex.IsChecked.Value; if (rbBW.IsChecked.Value) { twain.PixelType = Dynamsoft.TWAIN.Enums.TWICapPixelType.TWPT_BW; twain.BitDepth = 1; } else if (rbGrey.IsChecked.Value) { twain.PixelType = Dynamsoft.TWAIN.Enums.TWICapPixelType.TWPT_GRAY; twain.BitDepth = 8; } else if (rbColorful.IsChecked.Value) { twain.PixelType = Dynamsoft.TWAIN.Enums.TWICapPixelType.TWPT_RGB; twain.BitDepth = 24; } twain.AcquireImage(this as IAcquireCallback); } }
private void btnSelectSource_Click(object sender, System.EventArgs e) { List <string> tempList = new List <string>(); for (int i = 0; i < m_TwainManager.SourceCount; i++) { tempList.Add(m_TwainManager.SourceNameItems((short)i)); } SourceListForm temp = new SourceListForm(tempList); temp.ShowDialog(); int iSelectSource = temp.GetSelectedIndex(); m_TwainManager.SelectSourceByIndex((short)iSelectSource); }
private void AcquireImage() { try { m_TwainManager.SelectSourceByIndex(Convert.ToInt16(cmbSource.SelectedIndex)); m_TwainManager.IfShowUI = chkboxIfShowUI.Checked; m_TwainManager.OpenSource(); m_TwainManager.IfDisableSourceAfterAcquire = true; m_TwainManager.IfShowUI = chkboxIfShowUI.Checked; m_TwainManager.AcquireImage(this as IAcquireCallback); } catch (Exception exp) { this.txtboxErrMessage.AppendText(exp.Message); this.txtboxErrMessage.AppendText("\r\n"); } }
private void btnScan_Click(object sender, EventArgs e) { List <string> tempList = new List <string>(); for (int i = 0; i < m_TwainManager.SourceCount; i++) { tempList.Add(m_TwainManager.SourceNameItems((short)i)); } SourceListWrapper tempSourceListWrapper = new SourceListWrapper(tempList); int iSelectIndex = tempSourceListWrapper.SelectSource(); if (iSelectIndex == -1) { return; } else { m_TwainManager.IfDisableSourceAfterAcquire = true; m_TwainManager.IfShowUI = true; m_TwainManager.SelectSourceByIndex((short)iSelectIndex); m_TwainManager.AcquireImage(this as IAcquireCallback); } }