Esempio n. 1
0
        public FEditScanSettings()
        {
            InitializeComponent();

            cmbPage.Items.AddRange(CPageSizes.GetPageSizeList());
        }
        private void setupItem(Item item)
        {
            int resolution = 0;

            switch (settings.Depth)
            {
            case CScanSettings.BitDepth.GRAYSCALE:
                setItemIntProperty(item, 2, DATA_TYPE);
                break;

            case CScanSettings.BitDepth.C24BIT:
                setItemIntProperty(item, 3, DATA_TYPE);
                break;

            case CScanSettings.BitDepth.BLACKWHITE:
                setItemIntProperty(item, 0, DATA_TYPE);
                break;
            }

            switch (settings.Resolution)
            {
            case CScanSettings.DPI.DPI100:
                setItemIntProperty(item, 100, VERTICAL_RESOLUTION);
                setItemIntProperty(item, 100, HORIZONTAL_RESOLUTION);
                resolution = 100;
                break;

            case CScanSettings.DPI.DPI200:
                setItemIntProperty(item, 200, VERTICAL_RESOLUTION);
                setItemIntProperty(item, 200, HORIZONTAL_RESOLUTION);
                resolution = 200;
                break;

            case CScanSettings.DPI.DPI300:
                setItemIntProperty(item, 300, VERTICAL_RESOLUTION);
                setItemIntProperty(item, 300, HORIZONTAL_RESOLUTION);
                resolution = 300;
                break;

            case CScanSettings.DPI.DPI600:
                setItemIntProperty(item, 600, VERTICAL_RESOLUTION);
                setItemIntProperty(item, 600, HORIZONTAL_RESOLUTION);
                resolution = 600;
                break;

            case CScanSettings.DPI.DPI1200:
                setItemIntProperty(item, 1200, VERTICAL_RESOLUTION);
                setItemIntProperty(item, 1200, HORIZONTAL_RESOLUTION);
                resolution = 120;
                break;
            }

            Size pageSize       = CPageSizes.TranslatePageSize(settings.PageSize);
            int  pageWidth      = pageSize.Width * resolution / 1000;
            int  pageHeight     = pageSize.Height * resolution / 1000;
            int  horizontalSize = 0;

            if (settings.Source == CScanSettings.ScanSource.GLASS)
            {
                horizontalSize = getDeviceIntProperty(HORIZONTAL_BED_SIZE);
            }
            else
            {
                horizontalSize = getDeviceIntProperty(HORIZONTAL_FEED_SIZE);
            }
            int horizontalPos = 0;

            if (settings.PageAlign == CScanSettings.HorizontalAlign.CENTER)
            {
                horizontalPos = (horizontalSize * resolution / 1000 - pageWidth) / 2;
            }
            else if (settings.PageAlign == CScanSettings.HorizontalAlign.LEFT)
            {
                horizontalPos = (horizontalSize * resolution / 1000 - pageWidth);
            }
            setItemIntProperty(item, pageWidth, HORIZONTAL_EXTENT);
            setItemIntProperty(item, pageHeight, VERTICAL_EXTENT);
            setItemIntProperty(item, horizontalPos, HORIZONTAL_START);
            setItemIntProperty(item, settings.Contrast, CONTRAST);
            setItemIntProperty(item, settings.Brightnes, BRIGHTNESS);
        }