public override void Initialize(DataQueryResult query, VisualizerSettingsCollection settings, bool preserveSort = true) { if (query == null) { throw new ArgumentNullException("query"); } if (settings == null) { throw new ArgumentNullException("settings"); } try { if (initializing) { return; } initializing = true; initialized = false; currentSettings = settings.GetSettings <TableVisualizerSettings> () ?? new TableVisualizerSettings(); skip = new List <DbField> (currentSettings.SkippedColumns); if (dataQueryResult != null) { dataQueryResult.Result.ListChanged -= OnModelListChanged; } dataQueryResult = query; if (model != null && preserveSort) { dataQueryResult.Result.Sort(model.SortColumn); } dataQueryResult.Result.ListChanged += OnModelListChanged; LazyTableModel oldModel = model; model = dataQueryResult.Result; model.SortChanged += sortModel_SortChanged; if (oldModel != null && !ReferenceEquals(oldModel, model)) { oldModel.SortChanged -= sortModel_SortChanged; oldModel.Dispose(); } listReset = true; listChangedRized = false; if (!dataQueryResult.Result.Start()) { // Already started and possibly finished OnModelListChanged(query.Result, new ListChangedEventArgs(ListChangedType.Reset, query.Result.Count - 1)); } else { SwitchToWidget(imgLoading); } } finally { initializing = false; } }
public override object Clone() { TableVisualizerSettings ret = (TableVisualizerSettings)MemberwiseClone(); List <DbField> skipped = new List <DbField> (); foreach (DbField dbField in skippedColumns) { skipped.Add(new DbField(dbField.Field)); } ret.skippedColumns = skipped.ToArray(); return(ret); }
public override bool LoadSettings(DataQueryResult result, VisualizerSettingsCollection settings) { if (result == null) { throw new ArgumentNullException("result"); } if (settings == null) { throw new ArgumentNullException("settings"); } if (initialized) { throw new ApplicationException("The settings are already initialized"); } TableVisualizerSettings tableSettings = settings.GetSettings <TableVisualizerSettings> () ?? new TableVisualizerSettings(); chkShowTotals.Active = tableSettings.ShowTotals; List <DbField> skip = new List <DbField> (tableSettings.SkippedColumns); for (uint i = 0; i < result.Columns.Length; i++) { string columnName = ReportProvider.GetReportFieldColumnName(result, (int)i); DbField columnField = result.Columns [i].Field; CheckButton btn = new CheckButton(columnName); tblColumns.Attach(btn, 0, 1, i, i + 1, AttachOptions.Expand | AttachOptions.Fill | AttachOptions.Shrink, AttachOptions.Fill, 0, 0); btn.Active = !skip.Contains(columnField); btn.Show(); buttons.Add(new KeyValuePair <CheckButton, DbField> (btn, columnField)); } currentSettings = tableSettings; initialized = true; return(true); }