/// <summary> /// Remove column from "selected" (and add to "available" list) /// </summary> /// <param name="column"></param> private void RemoveColumn(GuiGridColumn column) { AvailableColumns.Add(column); SelectedColumns.Remove(column); SelectedAvailableColumn = column; SelectedSelectedColumn = null; }
/// <summary> /// Sets the displayed column settings to the given settings. /// </summary> /// <param name="columnSettings">A mapping of <see cref="Column"/>s to their visibility state.</param> public void SetVisibleColumns(IReadOnlyDictionary <Column, bool> columnSettings) { Contract.RequiresNotNull(columnSettings, nameof(columnSettings)); AvailableColumns.Clear(); VisibleColumns.Clear(); SelectedAvailableColumns.Clear(); SelectedVisibleColumns.Clear(); foreach (Column col in Enum.GetValues(typeof(Column))) { bool isVisible; if (!columnSettings.TryGetValue(col, out isVisible)) { isVisible = false; } if (isVisible) { VisibleColumns.Add(col); } else { AvailableColumns.Add(col); } } }
public void Add(Column col, string def) { AvailableColumns.Add(col); if (def == "Y") { ActiveColumns.Add(col); } _lookup.Add(col.Name, col); }
public void Remove() { var selected = SelectedColumns.Where(c => c.IsSelected).ToArray(); foreach (var item in selected) { SelectedColumns.Remove(item); item.IsSelected = false; AvailableColumns.Add(item); } }
private void HideColumns() { // ToArray used to detach the selection collection while we change the lists. foreach (var col in SelectedVisibleColumns.ToArray()) { VisibleColumns.Remove(col); AvailableColumns.Add(col); } SelectedVisibleColumns.Clear(); }
public void Reset() { while (SelectedColumns.Count > 0) { AvailableColumns.Add(SelectedColumns[0]); SelectedColumns.RemoveAt(0); } foreach (var column in DefaultColumns) { AvailableColumns.Remove(column); SelectedColumns.Add(column); } }
/// <summary> /// Initializes a new instance of <see cref="ColumnPropertiesViewModel"/>. /// </summary> /// <param name="columnSettings">The existing column settings to show.</param> public ColumnPropertiesViewModel(IReadOnlyDictionary <Column, bool> columnSettings) { ShowColumnsCmd = new RelayCommand(ShowColumns, CanShowColumns); HideColumnsCmd = new RelayCommand(HideColumns, CanHideColumns); MoveColumnsUpCmd = new RelayCommand(MoveColumnsUp, CanMoveColumnsUp); MoveColumnsDownCmd = new RelayCommand(MoveColumnsDown, CanMoveColumnsDown); if (columnSettings != null) { SetVisibleColumns(columnSettings); } else { // no settings given - just say they're all hidden. foreach (Column col in Enum.GetValues(typeof(Column))) { AvailableColumns.Add(col); } } }
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); } } }
/// <summary> /// Build columns list for available and selected boxes /// </summary> /// <param name="selectedColumns"></param> private void SetColumns(IEnumerable <GuiGridColumn> selectedColumns) { AvailableColumns.Clear(); foreach (var col in EventDefinition.Instance.Columns) { var item = selectedColumns.FirstOrDefault(x => x.ColumnType == col.ColumnType) ?? new GuiGridColumn() { ColumnType = col.ColumnType, Width = 100 }; AvailableColumns.Add(item); } // when adding selected column they will be auto-removed from "available" list SelectedColumns.Clear(); foreach (var item in selectedColumns) { AddColumn(item); } SelectedSelectedColumn = SelectedAvailableColumn = null; }