/// <summary> /// Update with our new violation viewer, and set everything up. /// </summary> /// <param name="ViolViewer">The violation viewer</param> public void SetViolationViews(MM_Violation_Viewer ViolViewer) { this.violView = ViolViewer; foreach (ListViewItem l in this.lvSearch.Items) { MM_Element Elem = l.Tag as MM_Element; //If we have a violation, let's add it in. MM_AlarmViolation_Type WorstViol = Elem.WorstVisibleViolation(violView.ShownViolations, this.Parent); if (WorstViol != null) { l.ImageIndex = WorstViol.ViolationIndex; } } }
/// <summary> /// Handle the row post-paint, in order to show violations when they occur. /// </summary> /// <param name="e"></param> protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e) { try { MM_Element ThisElem = (Rows[e.RowIndex].Cells["TEID"].Value as MM_Element); if (ThisElem == null) { return; } MM_AlarmViolation_Type ViolType = ThisElem.WorstVisibleViolation(violView.ShownViolations, this.Parent); if (ViolType != null) { e.Graphics.DrawImage(MM_Repository.ViolationImages.Images[ViolType.ViolationIndex], new Rectangle(e.RowBounds.Location, new Size(this.RowHeadersWidth, e.RowBounds.Height))); } else if (ThisElem.FindNotes().Length > 0) { e.Graphics.DrawImage(MM_Repository.ViolationImages.Images["Note"], new Rectangle(e.RowBounds.Location, new Size(this.RowHeadersWidth, e.RowBounds.Height))); } base.OnRowPostPaint(e); } catch (Exception) { } }