private void SaveUserSettings() { EventSubscriptionTool.Properties.Settings cfg = EventSubscriptionTool.Properties.Settings.Default; cfg.Initialized = true; cfg.WindowMaximized = (this.WindowState == FormWindowState.Maximized); if (this.WindowState == FormWindowState.Normal) { cfg.WindowSize = this.Size; } ArrayList colWidths = new ArrayList(); ArrayList colDisplayIndices = new ArrayList(); foreach (ColumnHeader col in this.subscriptionslistView.Columns) { colWidths.Add(col.Width); colDisplayIndices.Add(col.DisplayIndex); } cfg.ColumnWidths = colWidths; cfg.ColumnDisplayIndices = colDisplayIndices; cfg.Save(); }
private void LoadUserSettings() { EventSubscriptionTool.Properties.Settings cfg = EventSubscriptionTool.Properties.Settings.Default; // has the config file been created before? if (!cfg.Initialized) { return; } this.Size = cfg.WindowSize; foreach (ColumnHeader col in subscriptionslistView.Columns) { int i = col.Index; if (i < cfg.ColumnWidths.Count) { col.Width = (int)cfg.ColumnWidths[i]; } if (i < cfg.ColumnDisplayIndices.Count) { col.DisplayIndex = (int)cfg.ColumnDisplayIndices[i]; } } if (cfg.WindowMaximized) { this.WindowState = FormWindowState.Maximized; } }