public void Load() { if (File.Exists(Main.AppSettingsSavePath)) { JsonParser jsonString = JsonParser.Deserialize(File.ReadAllText(Main.AppSettingsSavePath)); Main.AppSettings = jsonString.Value.ToObject <SettingsStore>(); Main.Filters = string.IsNullOrEmpty(Main.AppSettings.DefaultFilterList) ? Main.Filters : JsonParser.Deserialize(Main.AppSettings.DefaultFilterList).Value.ToObject <List <Filter> >(); Main.AppSettings.IsDefault = false; } else { Main.AppSettings.InputLocation = $@"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\CSVs"; Main.AppSettings.OutputLocation = $@"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\CSVs\FilterOutputs"; Main.AppSettings.DefaultInputType = Filter.InputType.Numeric; Main.AppSettings.DefaultType = (Filter.Type) 2; Main.AppSettings.DefaultFilterList = ""; Main.AppSettings.IsDefault = true; } }
private void loadFiltersBtn_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Filter = @"Filter list file|*.flt"; open.FileName = $"{openedFile.Name}.flt"; open.Title = "Open filter list..."; open.DefaultExt = ".flt"; if (open.ShowDialog() == DialogResult.OK) { filterListBox.Items.Clear(); string jsonContent = File.ReadAllText(open.FileName); JsonParser deSerialize = JsonParser.Deserialize(jsonContent); Filters = deSerialize.Value.ToObject <List <Filter> >(); foreach (Filter filter in Filters) { filterListBox.Items.Add(filter.DisplayName); } filterListBox.Refresh(); doRemoveBtn.Enabled = filterListBox.Items.Count > 0 && openedFile != null; } }