public void DoScanBatchDoc() { this._acq = AppContext.GetInstance().GetVal <SharpAcquirerFactory>(typeof(SharpAcquirerFactory)).GetAdapter(""); this._acq.OnAcquired -= new EventHandler <TEventArg <string> >(this._acq_OnAcquired); this._acq.OnError -= new EventHandler <TEventArg <string> >(this._acq_OnError); this._acq.OnAcquired += new EventHandler <TEventArg <string> >(this._acq_OnAcquired); this._acq.OnError += new EventHandler <TEventArg <string> >(this._acq_OnError); IAcquirerParam initparam = new IAcquirerParam { HostWnd = base.Handle }; this._acq.Initialize(initparam); using (new DurTimeJob("采集中..")) { this._acq.Acquire(); } /* * if (((navigateTree.Nodes.Count > 0) && (navigateTree.Nodes[navigateTree.Nodes.Count - 1].Nodes.Count > 0)) && (this._lastScanOpeType != ScanOpe.ReplaceCurrent)) * { * RadTreeNode node = navigateTree.Nodes[navigateTree.Nodes.Count - 1]; * RadTreeNode input = node.Nodes[node.Nodes.Count - 1]; * if (this.OnItemSelectChanged != null) * { * this.OnItemSelectChanged(this, new TEventArg<RadTreeNode>(input)); * } * }*/ }
private void comboBox1_SelectedValueChanged(object sender, EventArgs e) { AppContext.GetInstance().Config.SetConfigParamValue("AdapterSetting", "DefaultAdapter", this.comboBox1.SelectedValue.ToString()); bool flag = this.AdaptsFactory != null; if (flag) { IFileAcquirer adapter = this.AdaptsFactory.GetAdapter(this.comboBox1.SelectedValue.ToString()); this.propertyGrid1.SelectedObject = adapter.GetSetting(); } }
private bool InitializeAdapters() { string[] files = Directory.GetFiles(".", "DocScanner.Adapter.dll"); bool result; if (files.Length == 0) { //TODO } else { //string[] array = files; //for (int i = 0; i < array.Length; i++) //{ string assemblyFile = files[0]; try { Assembly assembly = Assembly.LoadFrom(assemblyFile); Type[] exportedTypes = assembly.GetExportedTypes(); List <Type> types = exportedTypes.Where <Type>(o => o.Name.EndsWith("Acquirer")).ToList(); foreach (Type type in types) { IFileAcquirer fileAcquirer = assembly.CreateInstance(type.FullName) as IFileAcquirer; if (fileAcquirer != null) { this._acqs[fileAcquirer.Name] = fileAcquirer; } } // IEnumerable<Type> arg_53_0 = exportedTypes; //Func<Type, bool> arg_53_1; //if ((arg_53_1 = SharpAcquirerFactory.<>c.<>9__6_0) == null) //{ // arg_53_1 = (SharpAcquirerFactory.<>c.<>9__6_0 = new Func<Type, bool>(SharpAcquirerFactory.<>c.<>9.<InitializeAdapters>b__6_0)); //} //string fullName = arg_53_0.First(arg_53_1).FullName; } catch (Exception) { result = false; return(result); } } result = true; return(result); }
private void button1_Click(object sender, EventArgs e) { // IniConfigSetting.Default.SetConfigParamValue("TEST", "SelectIndex", this.comboBox1.SelectedIndex.ToString()); this.textBox1.Text = ""; if (acq != null) { acq.Dispose(); acq = null; } acq = new SharpTwainAcquirer();// mgr.GetAdapter(this.comboBox1.Text);//"WebCam"); acq.OnAcquired -= acq_OnAcquired; acq.OnError -= acq_OnError; acq.OnAcquired += acq_OnAcquired; acq.OnError += acq_OnError; acq.Initialize(null); acq.Acquire(); }