/// <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); } } }
/// <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; }