Пример #1
0
 //=====================================================================
 public bool SetCurrentDepth(string DepthName)
 {
     foreach (NTwain.Data.PixelType depth in this.DepthList)
     {
         if (depth.ToString() == DepthName)
         {
             this.CurrentDepth = depth;
             return(true);
         }
     }
     return(false);
 }
Пример #2
0
        //=====================================================================
        public bool LoadSourceCapabilities()
        {
            if (this._TwainSession.CurrentSource == null)
            {
                return(false);
            }
            NTwain.Capabilities capabilities = this._TwainSession.CurrentSource.Capabilities;

            this.CurrentPageSize = NTwain.Data.SupportedSize.USLetter;
            this.PageSizeList    = null;

            this.CurrentDpi = 300;
            this.DpiList    = null;

            this.CurrentDepth = NTwain.Data.PixelType.RGB;
            this.DepthList    = null;

            if (capabilities.ICapSupportedSizes.IsSupported)
            {
                try
                {
                    this.PageSizeList = new List <NTwain.Data.SupportedSize>();
                    foreach (NTwain.Data.SupportedSize size in capabilities.ICapSupportedSizes.GetValues().ToList())
                    {
                        this.PageSizeList.Add(size);
                    }
                    this.CurrentPageSize = capabilities.ICapSupportedSizes.GetCurrent();
                }
                catch (Exception exception)
                {
                    this.Fire_Error(new Error_EventArgs(exception));
                }
            }

            if (capabilities.ICapXResolution.IsSupported && capabilities.ICapYResolution.IsSupported)
            {
                try
                {
                    this.DpiList = new List <NTwain.Data.TWFix32>();
                    foreach (NTwain.Data.TWFix32 dpi in capabilities.ICapXResolution.GetValues().ToList())
                    {
                        this.DpiList.Add(dpi);
                    }
                    this.CurrentDpi = capabilities.ICapXResolution.GetCurrent();
                }
                catch (Exception exception)
                {
                    this.Fire_Error(new Error_EventArgs(exception));
                }
            }

            if (capabilities.ICapPixelType.IsSupported)
            {
                try
                {
                    this.DepthList = new List <NTwain.Data.PixelType>();
                    foreach (NTwain.Data.PixelType pixel_type in capabilities.ICapPixelType.GetValues().ToList())
                    {
                        this.DepthList.Add(pixel_type);
                    }
                    this.CurrentDepth = capabilities.ICapPixelType.GetCurrent();
                }
                catch (Exception exception)
                {
                    this.Fire_Error(new Error_EventArgs(exception));
                }
            }

            return(true);
        }