public void AddError(HashSet <GridData.Cell> cells, Property.IProperty p, Property.ErrorLevel level, string desc) { foreach (var cell in cells) { AddError(cell, p, level, desc); } }
private void _RemoveError(GridData.Cell cell, Property.IProperty p) { if (false == Errors.TryGetValue(cell, out var errors)) { return; } if (false == errors.TryGetValue(p.Name, out var error)) { return; } errors.Remove(p.Name); grid.Rows.Remove(error.Row); if (errors.Count == 0) { Errors.Remove(cell); cell.BackColor = Color.White; cell.ToolTipText = null; cell.Invalidate(); } else { UpdateErrorCell(cell, errors); } }
private void _AddError(GridData.Cell cell, Property.IProperty p, Property.ErrorLevel level, string desc) { if (false == Errors.TryGetValue(cell, out var errors)) { Errors.Add(cell, errors = new SortedDictionary <string, Error>()); } if (errors.ContainsKey(p.Name)) // 同一个cell相同的prop只报告一次。 { return; } grid.Rows.Add(); DataGridViewRow row = grid.Rows[grid.RowCount - 1]; row.Cells["Level"].Value = System.Enum.GetName(typeof(Property.ErrorLevel), level); row.Cells["Level"].Tag = cell; row.Cells["Description"].Value = desc; row.Cells["File"].Value = cell.Row.GridData.Document.RelateName; errors.Add(p.Name, new Error() { Level = level, Description = desc, Row = row, }); UpdateErrorCell(cell, errors); }
public void RemoveError(GridData.Cell cell, Property.IProperty p) { if (IsDisposed) // 某些 verify 是异步的,可能在窗口关闭后返回。 { return; } if (this.InvokeRequired) { DelegateInvoke d = delegate { _RemoveError(cell, p); }; this.BeginInvoke(d); } else { _RemoveError(cell, p); } }
private void AddButtonTo(GroupBox group, List <Property.IProperty> ps) { Point location = new Point(6, 20); int lines = 1; for (int i = 0; i < ps.Count; ++i) { Property.IProperty p = ps[i]; ButtonBase check = null; if (p.GroupRadio) { check = new RadioButton(); } else { check = new CheckBox(); } check.Location = location; check.Name = "button" + p.Name; check.Size = new Size(90, 24); check.TabIndex = i; check.Text = p.Name; toolTip1.SetToolTip(check, p.Comment); check.UseVisualStyleBackColor = true; group.Controls.Add(check); p.Button = check; location.X += 94; if ((i + 1) % 5 == 0) // new line { location.X = 6; location.Y += 29; if (i < ps.Count - 1) // 刚好满一行就不增加lines了。 { ++lines; } } } group.Size = new Size(534, 28 * lines + 20); }
public void AddError(GridData.Cell cell, Property.IProperty p, Property.ErrorLevel level, string desc) { if (IsDisposed) // 某些 verify 是异步的,可能在窗口关闭后返回。 { return; } // 在调用线程中回调。 if (OnAddError != null) { OnAddError(cell, p, level, desc); } if (this.InvokeRequired) { DelegateInvoke d = delegate { _AddError(cell, p, level, desc); }; this.BeginInvoke(d); } else { _AddError(cell, p, level, desc); } }