public DataSource(TwainDevice twain, TwIdentity identity)
 {
   fTwain = twain;
   fIdent = identity;
   fState = StateType.Closed;
   fSettings = null;
   fCapabilities = null;
 }
      public DataSourceCapabilities GetCapabilities()
      {
        DataSourceCapabilities result = null;

        if(this.Open())
        {
          result = new DataSourceCapabilities();

          result.ColorModes = new List<ColorModeEnum>() { ColorModeEnum.BW, ColorModeEnum.Gray, ColorModeEnum.RGB };
          result.PageTypes = new List<PageTypeEnum>() { PageTypeEnum.Letter, PageTypeEnum.Legal };
          result.Resolutions = new List<int>() { 100, 200, 300 };

          this.Close();
        }

        return result;
      }
      public DataSourceCapabilities GetCapabilities()
      {
        if(fCapabilities == null)
        {
          if(this.Open())
          {
            fCapabilities = new DataSourceCapabilities();

            fCapabilities.ColorModes = GetAvailableValuesForColorMode();
            fCapabilities.PageTypes = GetAvailableValuesForPageType();
            fCapabilities.Resolutions = GetAvailableValuesForResolution();

            this.Close();
          }
        }

        return fCapabilities;
      }