public void GetSubFilters(bool refresh, ObservableCollection<BaseTreeViewItem> items, Filter parent) { if (!refresh && parent != null) { if (items.Count <= 0) return; if (items[0].Title != @"...") return; } items.Clear(); var parentId = parent?.Id; foreach (var f in ACore.Db.Filters.Where(x => x.ParentId.Equals(parentId))) { Filter item = new Filter(f, parent); item.LoadFilterData(f.Data); if (ACore.Db.Filters.Count(x => x.ParentId == f.Id) != 0) { item.Items.Add(new Filter { Title = "..." }); } items.Add(item); } }
public Filter(DataModel.Filter data, Filter parent) : this() { Data = data; Parent = parent; Id = data.Id; Title = data.Name; }
private void CmdFilterNew(object sender, ExecutedRoutedEventArgs e) { var parent = e.Parameter as ViewModel.Filter; var newFilter = new ViewModel.Filter {Parent = parent, Title = "New filter"}; newFilter.FilterData.Add(new FilterGroup {Operator = FilterGroupOps.And}); var fb = new WFilterBuilder(newFilter) {Owner = this}; if (fb.ShowDialog() ?? true) { newFilter.SaveFilter(); if (parent != null) { parent.Items.Add(newFilter); } else { ACore.Filters.Items.Add(newFilter); } } }