Ejemplo n.º 1
0
        /// <summary>
        /// 设置单元格的颜色标记
        /// </summary>
        /// <param name="rowItemCode"></param>
        /// <param name="color"></param>
        /// <param name="columnIndex"></param>
        /// <param name="remarkFlag"></param>
        /// <param name="updateTypes"></param>
        public void SetRemarkFlag(string rowItemCode, Color color, int columnIndex, bool remarkFlag, GridOilColumnType updateTypes = GridOilColumnType.Calc)
        {
            if (updateTypes == GridOilColumnType.None)
            {
                return;
            }
            var cellGroup = GetGridOilCellGroup(rowItemCode, columnIndex);

            if (cellGroup == null)
            {
                return;
            }

            if (updateTypes.HasFlag(GridOilColumnType.Calc))
            {
                var cell = cellGroup.CalcCell;
                cell.CellBackgroudColor = color;
                cell.RemarkFlag         = remarkFlag;
                this.InvalidateCell(cell);
            }
            if (updateTypes.HasFlag(GridOilColumnType.Lab))
            {
                var cell = cellGroup.LabCell;
                cell.CellBackgroudColor = color;
                cell.RemarkFlag         = remarkFlag;
                this.InvalidateCell(cell);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 设置右上角提示
        /// </summary>
        /// <param name="rowItemCode"></param>
        /// <param name="columnIndex"></param>
        /// <param name="tips"></param>
        /// <param name="updateTypes"></param>
        public void SetTips(string rowItemCode, int columnIndex, string tips, GridOilColumnType updateTypes = GridOilColumnType.Calc)
        {
            if (updateTypes == GridOilColumnType.None)
            {
                return;
            }
            var cellGroup = GetGridOilCellGroup(rowItemCode, columnIndex);

            if (cellGroup == null)
            {
                return;
            }

            if (updateTypes.HasFlag(GridOilColumnType.Calc))
            {
                var cell = cellGroup.CalcCell;
                cell.Tips = tips;
                this.InvalidateCell(cell);
            }
            if (updateTypes.HasFlag(GridOilColumnType.Lab))
            {
                var cell = cellGroup.LabCell;
                cell.Tips = tips;
                this.InvalidateCell(cell);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 设置右上角提示
        /// </summary>
        /// <param name="rowItemCode"></param>
        /// <param name="columnIndex"></param>
        /// <param name="tips"></param>
        /// <param name="updateTypes"></param>
        public void SetTips(string rowItemCode, int columnIndex, string tips, GridOilColumnType updateTypes = GridOilColumnType.Calc)
        {
            if (updateTypes == GridOilColumnType.None)
            {
                return;
            }
            var cellGroup = GetGridOilCellGroup(rowItemCode, columnIndex);

            if (cellGroup == null)
            {
                return;
            }

            if (updateTypes.HasFlag(GridOilColumnType.Calc))
            {
                var cell = cellGroup.CalcCell;
                //string tempTips = oilTool.calDataDecLimit(tips, cell.RowEntity.decNumber);
                string tempTips = oilTool.calDataDecLimit(tips, cell.RowEntity.decNumber, cell.RowEntity.valDigital);
                cell.Tips = tempTips;
                this.InvalidateCell(cell);
            }
            if (updateTypes.HasFlag(GridOilColumnType.Lab))
            {
                var cell = cellGroup.LabCell;
                cell.Tips = tips;
                this.InvalidateCell(cell);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 设置值
        /// </summary>
        /// <param name="data"></param>
        /// <param name="updateTypes"></param>
        public void SetData(string rowItemCode, int columnIndex, string value, GridOilColumnType updateTypes = GridOilColumnType.Calc, bool enableUndoRedo = true)
        {
            if (updateTypes == GridOilColumnType.None)
            {
                return;
            }
            var cellGroup = GetGridOilCellGroup(rowItemCode, columnIndex);

            if (cellGroup == null)
            {
                return;
            }
            List <DataGridViewUndoRedoValue> updatedValues = new List <DataGridViewUndoRedoValue>();

            string oldValue;

            if (updateTypes.HasFlag(GridOilColumnType.Calc))
            {
                var cell = cellGroup.CalcCell;
                oldValue    = cell.Value2;
                cell.Value2 = value;
                if (enableUndoRedo)
                {
                    updatedValues.Add(new DataGridViewUndoRedoValue()
                    {
                        NewValue    = cell.Value2,
                        OldValue    = oldValue,
                        ColumnIndex = cell.ColumnIndex,
                        RowIndex    = cell.RowIndex
                    });
                }
            }
            if (updateTypes.HasFlag(GridOilColumnType.Lab))
            {
                var cell = cellGroup.LabCell;
                oldValue    = cell.Value2;
                cell.Value2 = value;
                if (enableUndoRedo)
                {
                    updatedValues.Add(new DataGridViewUndoRedoValue()
                    {
                        NewValue    = cell.Value2,
                        OldValue    = oldValue,
                        ColumnIndex = cell.ColumnIndex,
                        RowIndex    = cell.RowIndex
                    });
                }
            }
            if (enableUndoRedo && updatedValues.Count > 0)
            {
                undoRedoManager.DoChangeValues(updatedValues);
            }
            needSave = true;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 显示或者隐藏列
 /// </summary>
 /// <param name="type">列类型</param>
 /// <param name="isVisible">显示</param>
 /// <param name="indexes">需要操作的索引</param>
 public void Visible(GridOilColumnType type, bool isVisible, params int[] indexes)
 {
     lock (this)
     {
         foreach (var index in indexes.Where(o => o >= 0 && o < Count))
         {
             var t = this[index];
             if (type.HasFlag(GridOilColumnType.Lab))
             {
                 t.LabColumn.Visible = isVisible && !hiddenColumnType.HasFlag(GridOilColumnType.Lab);
             }
             if (type.HasFlag(GridOilColumnType.Calc))
             {
                 t.CalcColumn.Visible = isVisible && !hiddenColumnType.HasFlag(GridOilColumnType.Calc);
             }
         }
     }
 }
Ejemplo n.º 6
0
        public void CancelTips(string rowItemCode, int columnIndex, GridOilColumnType updateTypes = GridOilColumnType.Calc)
        {
            if (updateTypes == GridOilColumnType.None)
            {
                return;
            }
            var cellGroup = GetGridOilCellGroup(rowItemCode, columnIndex);

            if (cellGroup == null)
            {
                return;
            }

            if (updateTypes.HasFlag(GridOilColumnType.Calc))
            {
                var cell = cellGroup.CalcCell;
                if (!string.IsNullOrWhiteSpace(cell.Tips))
                {
                    cell.Tips = string.Empty;
                }
                else
                {
                    return;
                }
                this.InvalidateCell(cell);
            }
            if (updateTypes.HasFlag(GridOilColumnType.Lab))
            {
                var cell = cellGroup.LabCell;
                if (!string.IsNullOrWhiteSpace(cell.Tips))
                {
                    cell.Tips = string.Empty;
                }
                else
                {
                    return;
                }
                this.InvalidateCell(cell);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 设置值
        /// </summary>
        /// <param name="data"></param>
        /// <param name="updateTypes"></param>
        public void SetData(List <OilDataEntity> data, GridOilColumnType updateTypes = GridOilColumnType.Calc, bool enableUndoRedo = true)
        {
            if (_rows == null || _cols == null || _rows.Count == 0 || _cols.Count == 0 || data == null || updateTypes == GridOilColumnType.None)
            {
                return;
            }
            List <DataGridViewUndoRedoValue> updatedValues = new List <DataGridViewUndoRedoValue>();

            foreach (var c in data.GroupBy(o => o.ColumnIndex))
            {
                var col = columnList[c.Key];
                foreach (var r in c)
                {
                    var cell = this[col.LabColumn.Index, r.RowIndex] as GridOilCellItem;
                    GridOilCellGroup cellGroup;
                    if (cell == null)
                    {
                        cellGroup = new GridOilCellGroup(col, r.RowIndex);
                        cellGroup.Bind();
                    }
                    else
                    {
                        cellGroup = cell.Group;
                    }

                    string oldValue;
                    if (updateTypes.HasFlag(GridOilColumnType.Calc))
                    {
                        cell        = cellGroup.CalcCell;
                        oldValue    = cell.Value2;
                        cell.Value2 = r.calData;
                        if (enableUndoRedo)
                        {
                            updatedValues.Add(new DataGridViewUndoRedoValue()
                            {
                                NewValue    = cell.Value2,
                                OldValue    = oldValue,
                                ColumnIndex = cell.ColumnIndex,
                                RowIndex    = cell.RowIndex
                            });
                        }
                    }
                    if (updateTypes.HasFlag(GridOilColumnType.Lab))
                    {
                        cell        = cellGroup.LabCell;
                        oldValue    = cell.Value2;
                        cell.Value2 = r.labData;
                        if (enableUndoRedo)
                        {
                            updatedValues.Add(new DataGridViewUndoRedoValue()
                            {
                                NewValue    = cell.Value2,
                                OldValue    = oldValue,
                                ColumnIndex = cell.ColumnIndex,
                                RowIndex    = cell.RowIndex
                            });
                        }
                    }
                }
                Application.DoEvents();
            }
            if (enableUndoRedo && updatedValues.Count > 0)
            {
                undoRedoManager.DoChangeValues(updatedValues);
            }
        }