コード例 #1
0
        private void ChangeQuantizer()
        {
            activeQuantizer = quantizerList[listMethod.SelectedIndex];

            // turns off the color option for the uniform quantizer, as it doesn't make sense
            listColors.Enabled = listMethod.SelectedIndex != 1 && listMethod.SelectedIndex != 6 && listMethod.SelectedIndex != 7;

            // enables the color cache option; where available
            listColorCache.Enabled = activeQuantizer is BaseColorCacheQuantizer;
            // listColorModel.Enabled = listColorCache.Enabled && turnOnEvents && activeColorCache is BaseColorCache && ((BaseColorCache)activeColorCache).IsColorModelSupported;

            // enables dithering when applicable
            listDitherer.Enabled = listMethod.SelectedIndex != 5;

            // enabled parallelism when supported
            listParallel.Enabled = activeQuantizer.AllowParallel;

            // applies current UI selection
            if (activeQuantizer is BaseColorCacheQuantizer)
            {
                System.Diagnostics.Debug.WriteLine(activeQuantizer.ToString() + " is a BaseColorCacheQuantizer");
                BaseColorCacheQuantizer quantizer = (BaseColorCacheQuantizer) activeQuantizer;
                quantizer.ChangeCacheProvider(activeColorCache);
            }

            if (listMethod.SelectedIndex == 1 ||
                listMethod.SelectedIndex == 6 ||
                listMethod.SelectedIndex == 7)
            {
                turnOnEvents = false;
                listColors.SelectedIndex = 7;
                turnOnEvents = true;
            }
        }