コード例 #1
0
        private void CountOccurrences(UrlInfoModel el)
        {
            var elementProgress          = new Progress <int>();
            var orccurencesCountProgress = new Progress <int>();

            elementProgress.ProgressChanged += (sender, e) =>
            {
                RecalculateTotalProgress();
                el.FirstProgressBarValue = e;
            };
            orccurencesCountProgress.ProgressChanged += (sender, e) =>
            {
                if (e > maxOccurrence)
                {
                    maxOccurrence = e;
                }
                RecalculateProgress();
                el.OccurrencesCount = e;
            };
            var task = Task.Factory.StartNew(async() =>
            {
                await Common.CountTagsInUrlAsync(new Uri(el.Url), "a", elementProgress, orccurencesCountProgress, commonCancellationToken.Token);
            }, commonCancellationToken.Token);

            task.Wait();
        }
コード例 #2
0
        private void LoadFromFile()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "txt files (*.txt)|*.txt";
            if (openFileDialog.ShowDialog() == true)
            {
                var lines = File.ReadAllLines(openFileDialog.FileName);
                UrlInfoModel.Clear();
                foreach (var url in lines)
                {
                    if (Common.IsUrlValid(url))
                    {
                        UrlInfoModel.Add(new UrlInfoModel(url));
                    }
                }
            }
        }
コード例 #3
0
 private void RecalculateTotalProgress()
 {
     TotalProgress = UrlInfoModel.Sum(x => x.FirstProgressBarValue) / UrlInfoModel.Count;
 }