Beispiel #1
0
        private void _RemoveErrorByGrid(GridData gridedit)
        {
            if (null == gridedit)
            {
                return;
            }

            // 现在只显示打开grid的文件错误。如果要显示所有文件的。
            // 就不能记住Cell的引用,应该使用文件名+(ColIndex, RowIndex)。
            // 但是由于文件会变化,(ColIndex, RowIndex)可能不再准确(看看怎么处理这种情况)。

            grid.SuspendLayout();
            Dictionary <GridData.Cell, int> removed
                = new Dictionary <GridData.Cell, int>(new IdentityEqualityComparer());

            for (int i = grid.RowCount - 1; i >= 0; --i)
            {
                GridData.Cell c = grid.Rows[i].Cells["Level"].Tag as GridData.Cell;
                if (c.Row.GridData == gridedit)
                {
                    removed[c]    = 1;
                    c.BackColor   = Color.White;
                    c.ToolTipText = null;
                    c.Invalidate();
                    grid.Rows.RemoveAt(i);
                }
            }
            grid.ResumeLayout();

            foreach (var c in removed.Keys)
            {
                Errors.Remove(c);
            }
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        private void UpdateErrorCell(GridData.Cell cell, SortedDictionary <string, Error> errors)
        {
            Property.ErrorLevel max = Property.ErrorLevel.Warn;
            StringBuilder       sb  = new StringBuilder();

            foreach (var e in errors)
            {
                sb.Append(e.Key).Append(": ").Append(e.Value.Description).Append(Environment.NewLine);
                if (e.Value.Level > max)
                {
                    max = e.Value.Level;
                }
            }
            cell.BackColor   = max == Property.ErrorLevel.Error ? Color.Red : Color.Yellow;
            cell.ToolTipText = sb.ToString();
            cell.Invalidate();
        }