public void ShowColumn() { var columnToInsert = SelectedInvisibleColumn; var oldIndex = AvailableColumns.IndexOf(columnToInsert); int newIndex = oldIndex; if (newIndex >= (AvailableColumns.Count - 1)) { --newIndex; } var currentlySelectedIndex = SelectedVisibleColumn != null?Columns.IndexOf(SelectedVisibleColumn) : -1; Columns.Remove(columnToInsert); if (currentlySelectedIndex == -1) { Columns.Add(columnToInsert); } else { Columns.Insert(currentlySelectedIndex, columnToInsert); } columnToInsert.Visible = true; SelectedInvisibleColumn = (newIndex >= 0) ? AvailableColumns[newIndex] : null; }
public void MoveAvailableDown() { var item1 = SelectedInvisibleColumn; var item2 = AvailableColumns[AvailableColumns.IndexOf(item1) + 1]; AvailableColumns.Swap(item1, item2); }
public void DragDrop(object sourceHost, FieldMapperGridColumn source, object targetHost, FieldMapperGridColumn target, out FieldMapperGridColumn showAvailable, out FieldMapperGridColumn showSelected) { showAvailable = null; showSelected = null; if (sourceHost == AvailableColumns && targetHost == AvailableColumns) { return; } if (sourceHost == AvailableColumns && targetHost == SelectedColumns && source != target) { source.Visible = true; AvailableColumns.Remove(source); if (target == null) { AvailableColumns.Add(source); } else { AvailableColumns.Insert(AvailableColumns.IndexOf(target), source); } } else if (sourceHost == SelectedColumns && targetHost == AvailableColumns) { source.Visible = false; showAvailable = source; } else if (source != target) { AvailableColumns.Remove(source); if (target == null) { AvailableColumns.Add(source); } else { AvailableColumns.Insert(AvailableColumns.IndexOf(target), source); } } }