This project has moved. For the latest updates, please go here.

General (not strongly typed) accessing to a capabilities

This way is versatile and can be used for any capabilities. Following methods of a Twain32 class, provide necessary functionality
  • TwQC IsCapSupported(TwCap)
  • object GetCap(TwCap)
  • object GetCurrentCap(TwCap)
  • object GetDefaultCap(TwCap)
  • void ResetCap(TwCap)
  • void SetCap(TwCap,object)
  • void SetCap(TwCap,object[])
  • void SetCap(TwCap,Twain32.Range)
  • void SetCap(TwCap,Twain32.Enumeration)
  • void SetConstraint(TwCap,object)
  • void SetConstraint(TwCap,object[])
  • void SetConstraint(TwCap,Twain32.Range)
  • void SetConstraint(TwCap,Twain32.Enumeration)

//Brightness
if((this._twain32.IsCapSupported(TwCap.Brightness)&TwQC.Set)!=0) {
    this._twain32.SetCap(TwCap.Brightness,100f); //Allowed Values: -1000f to +1000f; Default Value: 0f;
}

//Contrast
if((this._twain32.IsCapSupported(TwCap.Contrast)&TwQC.Set)!=0) {
    this._twain32.SetCap(TwCap.Contrast,-150f); //Allowed Values: -1000f to +1000f; Default Value: 0f;
}

//Feeder & Duplex
if((this._twain32.IsCapSupported(TwCap.Duplex)&TwQC.GetCurrent)!=0) {
    var _duplexCapValue=(TwDX)this._twain32.GetCurrentCap(TwCap.Duplex);
    if(_duplexCapValue!=TwDX.None) {
        if((this._twain32.IsCapSupported(TwCap.FeederEnabled)&TwQC.Set)!=0) {
            this._twain32.SetCap(TwCap.FeederEnabled,true);

            if((this._twain32.IsCapSupported(TwCap.DuplexEnabled)&TwQC.Set)!=0) {
                this._twain32.SetCap(TwCap.DuplexEnabled,true);
            }
            this._twain32.SetCap(TwCap.XferCount,(short)-1);
        }
    }
}

Very important to correctly identify the type of value.

Last edited Nov 26, 2016 at 7:07 PM by SARAFF, version 1