예제 #1
0
 public Confirm(string optionKey, string LabelText)
 {
     InitializeComponent();
     _optionKey             = optionKey;
     lblConfirmText.Text    = LabelText;
     chkShowConfirm.Checked = RepositoryUtils.GetOptionValue(_optionKey) == "1" ? true : false;
 }
예제 #2
0
        public Options()
        {
            InitializeComponent();

            chkRecrawlConfirm.Checked = RepositoryUtils.GetOptionValue(Constants.CONFIRM_RECRAWL) == "1" ? true : false;
            var vsLoc = RepositoryUtils.GetOptionValue(Constants.VS_LOCATION);

            txtVSLocation.Text = String.IsNullOrWhiteSpace(vsLoc) ? Constants.DEFAULT_VS_LOCATION : vsLoc;
        }
예제 #3
0
        private void btnVSLocation_Click(object sender, EventArgs e)
        {
            var vsLoc = RepositoryUtils.GetOptionValue(Constants.VS_LOCATION);
            var exec  = String.IsNullOrWhiteSpace(vsLoc) ? Constants.DEFAULT_VS_LOCATION : vsLoc;

            var initDir = File.Exists(exec) ? Path.GetDirectoryName(exec) : String.Empty;
            var f       = new OpenFileDialog {
                FileName = Path.GetFileName(exec), InitialDirectory = initDir
            };

            if (f.ShowDialog() == DialogResult.OK)
            {
                txtVSLocation.Text = f.FileName;
            }
        }
예제 #4
0
        private void OpenSolution()
        {
            if (gridResults.Rows.Count == 0)
            {
                return;
            }

            var file   = String.Empty;
            var errors = new Collection <string>();
            var vsLoc  = RepositoryUtils.GetOptionValue(Constants.VS_LOCATION);
            var exec   = String.IsNullOrWhiteSpace(vsLoc) ? Constants.DEFAULT_VS_LOCATION : vsLoc;

            try
            {
                var sol = _repo.GetSourceData(gridResults.SelectedRows[0].Cells[0].Value.ToString());
                file = sol.SolutionPathAndFileName;
                if (!File.Exists(sol.SolutionPathAndFileName))
                {
                    errors.Add("File doesn't exist: " + sol.SolutionPathAndFileName);
                }
                else if (!File.Exists(exec))
                {
                    errors.Add($"Visual Studio executable file doesn't exist: {exec}. Please change it in the Options.");
                }
                else
                {
                    System.Diagnostics.Process.Start(exec, file);
                }
            }
            catch (Exception ex)
            {
                errors.Add("File = " + file + "\r\n" + ex.Message);
            }

            if (errors.Any())
            {
                var er = String.Join("\r\n", errors);
                MessageBox.Show("Exception!\r\n" + er);
            }
        }
예제 #5
0
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            try
            {
                var conf = new Confirm(Constants.CONFIRM_RECRAWL, "Are you sure?");
                var dr   = DialogResult.OK;

                if (RepositoryUtils.GetOptionValue(Constants.CONFIRM_RECRAWL) == "1" && _repo.GetSourceCount() > 0)
                {
                    dr = conf.ShowDialog();
                }

                if (dr == DialogResult.OK)
                {
                    RemoveAllButMainTab();
                    txtSourceFile.Text = String.Empty;
                    txtGrep.Text       = String.Empty;
                    txtDLL.Text        = String.Empty;

                    if (_timerGrep != null)
                    {
                        _timerGrep_Tick(null, null);
                    }

                    ManageControls(true);
                    lblCount.Text       = "0";
                    lblResultCount.Text = "0";
                    lblHitAt.Text       = String.Empty;

                    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 sw = Stopwatch.StartNew();
                    var t  = Task.Run(() => { _repo.CrawlSource(progress); });

                    t.ContinueWith(r =>
                    {
                        lblCount.Text = _repo.GetSourceCount().ToString();
                        ManageControls(false);
                        progressRefresh.Value = 0;

                        sw.Stop();
                        _timerGrep = new Timer {
                            Interval = MILLISECOND_SEARCH_DELAY
                        };
                        _timerGrep.Tick += _timerGrep_Tick;
                    }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext());

                    t.ContinueWith(r =>
                    {
                        sw.Stop();
                        ManageControls(false);
                    }, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.FromCurrentSynchronizationContext());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }