public async Task OnStartCrawling(object param)
        {
            ClearCrawlerTree();

            CrawlerInputParser inputParser   = new CrawlerInputParser();
            List <Uri>         rootResources = inputParser.Parse(ViewModelsMediator.Instance.SourceFilePath);

            if (rootResources != null)
            {
                StartBtnEnabled = false;
                StopBtnEnabled  = true;

                // Init crawler
                WebCrawler.WebCrawler crawler = new WebCrawler.WebCrawler();
                crawler.MaxDepth         = crawlingDepth;
                crawler.Logger           = LoggerViewModel.Instance;
                crawler.LoadingFinished += OnPageLoadingFinished;

                foreach (var rootUri in rootResources)
                {
                    WebCrawlerOutput crawlerOutput = await crawler.PerformCrawlingAsync(rootUri, 0, -1);
                }

                StartBtnEnabled = true;
                StopBtnEnabled  = false;
            }
        }
        private void OnPageLoadingFinished(int parentId, WebCrawlerOutput output)
        {
            LoggerViewModel.Instance.LogMessage(string.Format("Resource loaded: {0}", output.SourceUri));

            var    parentItem  = FindTreeItemById(parentId);
            string elementName = string.Format("ID {0}", output.SourceId);

            AddCrawlerOutputTreeNode(parentItem, elementName, output);
        }
        public CrawlerTreeViewItem AddCrawlerOutputTreeNode(CrawlerTreeViewItem parent, string item, WebCrawlerOutput attachment)
        {
            // Construct element
            CrawlerTreeViewItem element = new CrawlerTreeViewItem();

            element.Header       = item;
            element.AttachedData = attachment;

            // Attach to the parent
            if (parent != null)
            {
                parent.Items.Add(element);
            }
            else
            {
                CrawlerOutput.Add(element);
            }

            treeNodesDict.Add(attachment.SourceId, element);             // Register for quick access
            RaisePropertyChanged(nameof(CrawlerOutput));

            return(element);
        }