예제 #1
0
        private void GetRoot()
        {
            ManageControls(true);

            cboOperator.SelectedIndex = 0;
            txtSourceFile.Text        = String.Empty;
            txtGrep.Text  = String.Empty;
            lblHitAt.Text = String.Empty;

            var defaultRoot = RepositoryUtils.GetDefaultRootId();

            if (defaultRoot != null)
            {
                var progressHandler = new Progress <ProgressResult>(value =>
                {
                    var percent = (int)(((double)progressRefresh.Value / (double)progressRefresh.Maximum) * 100);
                    progressRefresh.ProgressBar.Refresh();
                    progressRefresh.ProgressBar.CreateGraphics().DrawString(percent.ToString() + "%", new Font("Arial", (float)8.25, FontStyle.Regular), Brushes.Black, new PointF(progressRefresh.Width / 2 - 10, progressRefresh.Height / 2 - 7));
                    progressRefresh.Value  = value.ProgressValue;
                    tsCurrentSolution.Text = value.WorkingOn;
                });
                var progress = progressHandler as IProgress <ProgressResult>;

                var t = Task.Run(() => _repo = new RepositoryFile(defaultRoot[0], progress));
                t.ContinueWith(r =>
                {
                    MessageBox.Show($"Error retrieving root {defaultRoot[1]}. Please remove and re-add it.");
                    ManageControls(false);
                }, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.FromCurrentSynchronizationContext());

                t.ContinueWith(r =>
                {
                    lblRoot.Text = _repo.Root.RootPath;
                    ManageControls(false);
                    RefreshCount();
                    lblResultCount.Text = "0";
                    _timerGrep          = new Timer {
                        Interval = MILLISECOND_SEARCH_DELAY
                    };
                    _timerGrep.Tick += _timerGrep_Tick;
                }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext())
                .ContinueWith(r1 => Task.Run(() => System.Threading.Thread.Sleep(3000))
                              .ContinueWith(r2 =>
                {
                    progressRefresh.Value = 0;
                }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext()),
                              CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext());
            }
            else
            {
                btnRefresh.Enabled             = false;
                picWaiting.Visible             = false;
                toolStripButtonRoots.Enabled   = true;
                toolStripButtonOptions.Enabled = true;
                lblRoot.Text = "No default source root found. Please add at least one.";
            }
        }
예제 #2
0
        public ManageRoots(RepositoryFile currentRepo)
        {
            InitializeComponent();

            _allRoots              = new BindingList <RootObject>(RepositoryUtils.GetAllRoots());
            lbxRoots.DataSource    = _allRoots;
            lbxRoots.DisplayMember = "RootPath";

            if (_allRoots.Count > 0)
            {
                lbxRoots.SelectedItem = _allRoots.FirstOrDefault(r => r.IsDefault);
            }
            else
            {
                btnRemove.Enabled = false;
            }
            _currentRepo = currentRepo;
            lbxRoots.Focus();
        }
예제 #3
0
        static void Main(string[] args)
        {
            if (args.Length > 0 && args[0].Equals("-crawldefault"))
            {
                var progressWindow = new RecrawlProgressCommandLine();
                progressWindow.SetProgress(0, "");

                var progressHandler = new Progress <ProgressResult>(value =>
                {
                    var percent   = (int)(((double)progressWindow.GetCurrentProgressValue() / (double)progressWindow.GetMaxProgressValue()) * 100);
                    var workingOn = String.Empty;

                    if (value.WorkingOn != null && value.WorkingOn.Contains(".sln"))
                    {
                        workingOn = Path.GetFileName(value.WorkingOn);
                    }
                    else
                    {
                        workingOn = value.WorkingOn;
                    }

                    progressWindow.SetProgress(value.ProgressValue, workingOn);

                    if (value.CloseForm.HasValue && value.CloseForm.Value)
                    {
                        progressWindow.KillSelf();
                    }
                });

                var progress = progressHandler as IProgress <ProgressResult>;
                var t        = Task.Run(() =>
                {
                    var defaultRootId = RepositoryUtils.GetDefaultRootId()[0];
                    if (defaultRootId != null)
                    {
                        progress.Report(new ProgressResult {
                            ProgressValue = 0, WorkingOn = "Caching..."
                        });

                        var repo = new RepositoryFile(defaultRootId, progress);

                        progress.Report(new ProgressResult {
                            ProgressValue = 0, WorkingOn = $"Refreshing default repository: {repo.Root.RootPath}..."
                        });
                        repo.CrawlSource(progress);

                        progress.Report(new ProgressResult {
                            ProgressValue = 0, CloseForm = true
                        });
                    }
                    else
                    {
                        //Console.WriteLine("No default source repository exists.");
                    }
                });

                progressWindow.ShowDialog();
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Main());
            }
        }