Exemple #1
0
        private SearchClient(string img)
        {
            if (!IsFileValid(img))
            {
                throw new SmartImageException("Invalid image");
            }

            string auth     = SearchConfig.Config.ImgurAuth;
            bool   useImgur = !String.IsNullOrWhiteSpace(auth);

            var engines = SearchConfig.Config.SearchEngines;

            if (engines == SearchEngineOptions.None)
            {
                engines = SearchConfig.ENGINES_DEFAULT;
            }

            m_results = null !;
            m_engines = engines;
            m_img     = new FileInfo(img);
            m_bmp     = new Bitmap(img);
            m_imgUrl  = Upload(img, useImgur);
            m_tasks   = CreateSearchTasks();

            // Joining each thread isn't necessary as this object is disposed upon program exit
            // Background threads won't prevent program termination

            m_monitor = new Thread(SearchMonitor)
            {
                Priority     = ThreadPriority.Highest,
                IsBackground = true
            };

            Complete = false;

            Interface = new NConsoleUI(Results)
            {
                SelectMultiple = false,
                Prompt         = InterfacePrompt
            };
        }