Example #1
0
        public /*static*/ void RunProcessingTask(SearchResult result)
        {
            // todo

            var task = new Task(InspectTask);

            task.Start();

            void InspectTask()
            {
                if (!result.IsProcessed)
                {
                    string?type    = Network.IdentifyType(result.Url);
                    bool   isImage = Network.IsImage(type);

                    result.MimeType    = type;
                    result.IsImage     = isImage;
                    result.IsProcessed = true;

                    Debug.WriteLine("Process {0}", new object[] { result.Name });
                }
            }

            NConsoleIO.Refresh();
        }
Example #2
0
        private void SearchMonitor()
        {
            Task.WaitAll(m_tasks);

            var p = new SoundPlayer(RuntimeInfo.RuntimeResources.SndHint);

            p.Play();

            Complete         = true;
            Interface.Status = "OK";
            NConsoleIO.Refresh();
        }
Example #3
0
        public void AddExtendedResults(ISearchResult[] bestImages)
        {
            // todo?

            var rg = FromExtendedResult(bestImages);

            ExtendedResults.AddRange(rg);

            foreach (var result in rg)
            {
                SearchClient.Client.RunProcessingTask(result);
            }

            AltFunction = () =>
            {
                NConsoleIO.HandleOptions(ExtendedResults);

                return(null);
            };
        }
Example #4
0
        private static bool IsFileValid(string img)
        {
            if (String.IsNullOrWhiteSpace(img))
            {
                return(false);
            }

            if (!File.Exists(img))
            {
                NConsole.WriteError($"File does not exist: {img}");
                return(false);
            }

            bool isImageType = FileOperations.ResolveFileType(img).Type == FileType.Image;

            if (!isImageType)
            {
                return(NConsoleIO.ReadConfirmation("File format is not recognized as a common image format. Continue?"));
            }

            return(true);
        }
Example #5
0
        private void RunSearchTask(ISearchEngine currentEngine)
        {
            var result = currentEngine.GetResult(m_imgUrl);

            m_results.Add(result);

            RunProcessingTask(result);

            // If the engine is priority, open its result in the browser
            if (SearchConfig.Config.PriorityEngines.HasFlag(currentEngine.Engine))
            {
                Network.OpenUrl(result.Url);
            }

            //Update();

            // Sort results
            m_results.Sort(CompareResults);

            // Reload console UI
            NConsoleIO.Refresh();
        }
Example #6
0
 internal static void Run()
 {
     //
     NConsoleIO.HandleOptions(Interface);
 }
Example #7
0
        //  ____                       _   ___
        // / ___| _ __ ___   __ _ _ __| |_|_ _|_ __ ___   __ _  __ _  ___
        // \___ \| '_ ` _ \ / _` | '__| __|| || '_ ` _ \ / _` |/ _` |/ _ \
        //  ___) | | | | | | (_| | |  | |_ | || | | | | | (_| | (_| |  __/
        // |____/|_| |_| |_|\__,_|_|   \__|___|_| |_| |_|\__,_|\__, |\___|
        //                                                     |___/

        /*
         * todo: refactor access modifiers
         * todo: maybe create a separate unit testing project
         */

        /*
         * Entry point
         */

        private static void Main(string[] args)
        {
            /*
             * Set up console
             */

            Console.Title = RuntimeInfo.NAME;
            Console.SetWindowSize(120, 50);
            Console.OutputEncoding = Encoding.Unicode;
            Console.Clear();
            NConsole.Init();

            NConsoleUI.DefaultName = RuntimeInfo.NAME_BANNER;

            /*
             * Run search
             */

            try {
                // Setup
                SearchConfig.Config.Setup();
                Integration.Setup();

                // Run UI if not using command line arguments
                if (SearchConfig.Config.NoArguments)
                {
                    MainMenu.Run();
                    Console.Clear();
                }

                // Image is automatically read from command line arguments,
                // or it is input through the main menu


                // Exit if no image is given
                if (String.IsNullOrWhiteSpace(SearchConfig.Config.Image))
                {
                    return;
                }

                // Run search
                SearchClient.Client.Start();

                // Show results
                NConsoleIO.HandleOptions(SearchClient.Client.Interface);
            }
            catch (Exception exception) {
#if !DEBUG
                var cr = new CrashReport(exception);

                Console.WriteLine(cr);


                var src = cr.WriteToFile();

                Console.WriteLine("Crash log written to {0}", src);

                Console.WriteLine("Please file an issue and attach the crash log.");

                Network.OpenUrl(RuntimeInfo.Issue);

                NConsoleIO.WaitForInput();
#else
                Console.WriteLine(exception);
#endif
            }
            finally {
                // Exit
                SearchConfig.Config.UpdateFile();
            }
        }