// 空白页勾选 private void ICAP_AUTODISCARDBLANKPAGES_Checked(object sender, RoutedEventArgs e) { BlankImageThreshold.IsEnabled = true; UInt32 intValue = UInt32.Parse(BlankImageThreshold.Text) * 1024; CapInfo capInfo = twSession.GetScannerCap(TwCap.ICAP_AUTODISCARDBLANKPAGES); capInfo.CurrentIntStr = intValue.ToString(); capInfo.SetCap(); }
// 输入框失去焦点时保存值并设置 private void BlankImageThreshold_LostFocus(object sender, RoutedEventArgs e) { // 获取空白页大小 if (BlankImageThreshold.IsEnabled) { UInt32 intValue = UInt32.Parse(BlankImageThreshold.Text) * 1024; CapInfo capInfo = twSession.GetScannerCap(TwCap.ICAP_AUTODISCARDBLANKPAGES); capInfo.CurrentIntStr = intValue.ToString(); capInfo.SetCap(); } }
/// <summary> /// 设置一个值到控件和扫描仪 /// </summary> /// <param name="control"></param> /// <param name="capInfo"></param> /// <returns></returns> private bool SetOneValue(Control control, CapInfo capInfo) { if (control is ComboBox) { ComboBox comboBox = control as ComboBox; bool OK = SetCurrentValueOfComboBox(comboBox, capInfo); if (OK) // 列表中有该值 { // 将该值设置到扫描仪 bool twOk = twSession.SetCapability(capInfo); if (twOk) { return(true); } } return(false); } else { CheckBox checkBox = control as CheckBox; if (capInfo.CurrentIntStr == null) { capInfo.CurrentIntStr = "0"; } if (capInfo.CapId == TwCap.ICAP_AUTODISCARDBLANKPAGES) { { Int32 intVal = Int32.Parse(capInfo.CurrentIntStr); BlankImageThreshold.Text = (Math.Round((double)intVal / 1024)).ToString(); } checkBox.IsChecked = !(capInfo.CurrentIntStr == "0"); } else { checkBox.IsChecked = (capInfo.CurrentIntStr == "1"); } return(capInfo.SetCap()); } }