private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
// save consideredStats
int consideredStats = 0;
for (int s = 0; s < 8; s++)
{
if (considerStatHighlight[s])
consideredStats += (1 << s);
}
Properties.Settings.Default.consideredStats = consideredStats;
// save window-position and size
if (this.WindowState != FormWindowState.Minimized)
{
Properties.Settings.Default.formSize = this.Size;
Properties.Settings.Default.formLocation = this.Location;
}
// save column-widths
Int32[] cw = new Int32[listViewLibrary.Columns.Count];
for (int c = 0; c < listViewLibrary.Columns.Count; c++)
cw[c] = listViewLibrary.Columns[c].Width;
Properties.Settings.Default.columnWidths = cw;
// save listViewSorting
Properties.Settings.Default.listViewSortCol = lvwColumnSorterLibrary.SortColumn;
Properties.Settings.Default.listViewSortAsc = (lvwColumnSorterLibrary.Order == SortOrder.Ascending);
// save custom statweights
List<string> custWs = new List<string>();
List<double[]> custWd = new List<double[]>();
foreach (KeyValuePair<string, double[]> w in statWeighting1.CustomWeightings)
{
custWs.Add(w.Key);
custWd.Add(w.Value);
}
custWd.Add(statWeighting1.Values); // add current values
Properties.Settings.Default.customStatWeights = custWd.ToArray();
Properties.Settings.Default.customStatWeightNames = custWs.ToArray();
// save settings for next session
Properties.Settings.Default.Save();
// remove old cache-files
if (Directory.Exists("img/cache"))
{
var directory = new System.IO.DirectoryInfo("img/cache");
var oldCacheFiles = directory.GetFiles().Where(f => f.LastAccessTime < DateTime.Now.AddDays(-5)).ToList();
foreach (FileInfo f in oldCacheFiles)
{
f.Delete();
}
}
}