예제 #1
0
        private void IssueList_ListChanged(object sender, ListChangedEventArgs e)
        {
            var list = IssueList.ToArray();

            foreach (var item in list)
            {
                // If issue is unchecked or no longer a problem then...
                if (Warnings.Contains(item) && (!item.IsEnabled || !item.Severity.HasValue || item.Severity == IssueSeverity.None))
                {
                    // Remove from warnings list.
                    Warnings.Remove(item);
                }
                // If issue not found and problem found then...
                else if (!Warnings.Contains(item) && item.IsEnabled && item.Severity.HasValue && item.Severity.Value != IssueSeverity.None)
                {
                    // Add to warnings list.
                    Warnings.Add(item);
                }
            }
            // Get issues in progress.
            list = IssueList.Where(x => x.Status != IssueStatus.Idle).ToArray();
            var sb = new StringBuilder();

            foreach (var item in list)
            {
                if (sb.Length > 0)
                {
                    sb.Append(", ");
                }
                sb.AppendFormat("{0}/{1} {2}: {3}", IssueList.IndexOf(item), IssueList.Count, item.GetType().Name, item.Status);
            }
            StatusLabel.Text = sb.ToString();
            UpdateIgnoreAllButton();
            UpdateNoIssuesPanel();
        }
예제 #2
0
        void CheckAll()
        {
            bool clearRest = false;

            foreach (var issue in IssueList)
            {
                if (clearRest)
                {
                    issue.Severity = IssueSeverity.None;
                }
                else
                {
                    issue.Check();
                }
                // If issue is critical then...
                if (issue.Severity == IssueSeverity.Critical)
                {
                    // Skip checking other issues.
                    clearRest = true;
                }
                // Try to get issue from warnings list.
                var item = Warnings.FirstOrDefault(x => x.Name == issue.Name);
                // If issue found and not a problem then...
                if (item != null && issue.Severity == IssueSeverity.None)
                {
                    // Remove from the list.
                    Warnings.Remove(item);
                }
                // If issue not found and there is a problem then...
                else if (item != null && issue.Severity != IssueSeverity.None)
                {
                    // Add to the list.
                    Warnings.Add(issue);
                }
            }
            HasIssues = IgnoreAll
                                ? false
                                : Warnings.Any(x => x.Severity > IssueSeverity.Moderate);
            var ev = CheckCompleted;

            if (ev != null)
            {
                CheckCompleted(this, new EventArgs());
            }
        }