private void btnAddCustomVariable_Click(object sender, RoutedEventArgs e) { VariableEditor editor = new VariableEditor(); if (editor.ShowDialog() == true) { VariableListitem variable = new VariableListitem(editor.Variable, editor.Formula, editor.Label, editor.AllowFiltering); CustomVariables.Children.Add(variable); } }
private void MenuAction_Open(object sender, RoutedEventArgs e) { if (_openDialog.ShowDialog() == true) { StockFinderSettings settings = StockFinderSettings.Load(_saveLocation = _openDialog.FileName); if (settings != null) { HideAllFilters(); ClearGridColumns(); foreach (UIElement element in CustomVariables.Children.Cast <UIElement>().ToList()) { VariableListitem listitem = element as VariableListitem; listitem?.Remove(); } StockInfo.PropertyDefinitions.Clear(); foreach (CustomStockProperty property in settings.CustomProperties) { VariableListitem listitem = new VariableListitem(property.Variable, property.Formula, property.Label, property.AllowFiltering); CustomVariables.Children.Add(listitem); } foreach (FilterState filter in settings.Filters) { FilterCriteria criteria = AddFilter(filter.Variable, true); criteria.IsUsed = filter.IsUsed; criteria.Min = filter.Min; criteria.Max = filter.Max; } foreach (GridColumnState column in settings.Columns.OrderBy(col => col.Id)) { AddGridColumn(column.Variable); } ClearAllScanners(); foreach (ScannerSettings scanner in settings.Scanners) { AddScanner(scanner); } } } }