Beispiel #1
0
 public void DoAddColumn(GridOilColumnGroup column)
 {
     if (column == null)
     {
         return;
     }
     DoAddColumns(new List <GridOilColumnGroup>(new GridOilColumnGroup[] { column }));
 }
Beispiel #2
0
 internal GridOilCellGroup(GridOilColumnGroup column, int rowIndex, IOilDataEntity dataEntity = null)
 {
     Column      = column;
     RowIndex    = rowIndex;
     LabCell     = new GridOilCellItem(this, GridOilColumnType.Lab);
     CalcCell    = new GridOilCellItem(this, GridOilColumnType.Calc);
     _dataEntity = dataEntity;
     //SetDataEntity(dataEntity);
 }
Beispiel #3
0
 public GridOilColumnItem(GridOilColumnGroup group, GridOilColumnType type)
 {
     Group        = group;
     Type         = type;
     Width        = group.Width;
     AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
     SortMode     = DataGridViewColumnSortMode.NotSortable;
     Visible      = !group.List.HiddenColumnType.HasFlag(type);
 }
Beispiel #4
0
        public void DoChangeColumn(GridOilColumnGroup oldColumn, GridOilColumnGroup newColumn, List <DataGridViewUndoRedoValue> values)
        {
            if (oldColumn == null || newColumn == null)
            {
                return;
            }
            var cmd = new DataGridViewUndoRedoCommand()
            {
                CommandType = DataGridViewUndoRedoCommandType.ChangeColumn,
                Values      = values,
                NewColumns  = new List <GridOilColumnGroup>(new GridOilColumnGroup[] { newColumn }),
                OldColumns  = new List <GridOilColumnGroup>(new GridOilColumnGroup[] { oldColumn })
            };

            Do(cmd);
        }
Beispiel #5
0
        private void menuColumnAdd_Click(object sender, EventArgs e)
        {
            if (AllowEditColumn == false)
            {
                return;
            }
            if (SelectedColumns.Count == 0)
            {
                return;
            }
            bool isLeft;

            if (sender == menuColumnAddOnLeft)
            {
                isLeft = true;
            }
            else if (sender == menuColumnAddOnRight)
            {
                isLeft = false;
            }
            else
            {
                return;
            }
            GridOilColumnGroup lastColumn = null;
            List <DataGridViewUndoRedoValue> updatedValues = null;

            if (columnList.FixColumnCount > 0)
            {
                lastColumn    = columnList.LastOrDefault();
                updatedValues = GetColumnUndoRedoValues(lastColumn);
                lastColumn.Remove();
            }
            List <GridOilColumnGroup> groups = new List <GridOilColumnGroup>();

            foreach (DataGridViewColumn c in SelectedColumns)
            {
                if (c is GridOilColumnItem)
                {
                    groups.Add((c as GridOilColumnItem).Group);
                }
            }
            groups.Distinct();
            int index = 0;

            if (groups.Count > 0)
            {
                if (isLeft)
                {
                    index = groups.Min(o => o.Index);
                }
                else
                {
                    index = groups.Max(o => o.Index) + 1;
                }
            }
            else
            {
                index = columnList.Count;
            }
            var g = columnList.Insert(index);

            if (columnList.FixColumnCount < 0)
            {
                undoRedoManager.DoAddColumn(g);
            }
            else
            {
                undoRedoManager.DoChangeColumn(lastColumn, g, updatedValues);
            }
            needSave = true;
        }