public AdvancedQueryUserControl(FeatureLayer targetLayer) { InitializeComponent(); viewModel = new AdvancedQueryViewModel(targetLayer); DataContext = viewModel; Loaded += (s, e) => { Messenger.Default.Register <bool>(this, viewModel, (value) => { CloseWindow(value); }); Messenger.Default.Register <DialogMessage>(this, viewModel, (m) => { System.Windows.Forms.MessageBox.Show(m.Content, m.Caption); }); MatchComboBox.IsEnabledChanged -= MatchComboBox_IsEnabledChanged; MatchComboBox.IsEnabledChanged += MatchComboBox_IsEnabledChanged; }; }
public IEnumerable <Feature> FindFeatures(ObservableCollection <QueryConditionViewModel> conditions, QueryMatchMode queryMatchMode) { IEnumerable <Feature> filteredFeatures = new Collection <Feature>(); switch (queryMatchMode) { case QueryMatchMode.All: var featuresGroup = conditions.Select(condition => AdvancedQueryViewModel.FilterFeatures(condition)).ToArray(); for (int i = 0; i < featuresGroup.Length; i++) { if (i == 0) { filteredFeatures = featuresGroup[i]; } else { return(Intersect(featuresGroup[i - 1], featuresGroup[i])); } } break; case QueryMatchMode.Any: filteredFeatures = conditions.SelectMany(condition => AdvancedQueryViewModel.FilterFeatures(condition)); Dictionary <string, Feature> result = new Dictionary <string, Feature>(); foreach (var item in filteredFeatures) { Feature newFeature = GisEditor.SelectionManager.GetSelectionOverlay().CreateHighlightFeature(item, (FeatureLayer)item.Tag); if (!result.ContainsKey(newFeature.Id)) { result.Add(newFeature.Id, newFeature); } } return(result.Values); } return(filteredFeatures); }