public void RefreshFeatureEntities(Dictionary <FeatureLayer, Collection <Feature> > selectedFeatureEntities)
        {
            FeatureEntities.Clear();
            SelectedEntity = null;

            Application.Current.Dispatcher.BeginInvoke(() =>
            {
                FeatureEntities.Clear();
                foreach (var item in selectedFeatureEntities)
                {
                    FeatureLayerViewModel entity = new FeatureLayerViewModel {
                        LayerName = item.Key.Name
                    };
                    foreach (var tmpFeature in item.Value)
                    {
                        entity.FoundFeatures.Add(new FeatureViewModel(tmpFeature, item.Key));
                    }
                    FeatureEntities.Add(entity);
                }

                if (FeatureEntities.Count > 0 && FeatureEntities[0].FoundFeatures.Count > 0)
                {
                    selectedEntity = FeatureEntities[0].FoundFeatures[0];
                    RaisePropertyChanged(() => SelectedDataView);
                }
            }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
        }
Example #2
0
        private void FindFeatures(IEnumerable <FeatureLayer> selectedLayers)
        {
            IsBusy = true;
            foreach (var layer in selectedLayers)
            {
                Task.Factory.StartNew(() =>
                {
                    Collection <Feature> features = new Collection <Feature>();
                    layer.SafeProcess(() =>
                    {
                        Collection <Feature> allFeatures = new Collection <Feature>();
                        allFeatures         = layer.QueryTools.GetAllFeatures(layer.GetDistinctColumnNames());
                        var queriedFeatures = allFeatures.Where(f =>
                        {
                            bool hasValue = f.ColumnValues.Values
                                            .Any(value => value.ToUpperInvariant().Contains(FindValue.ToUpperInvariant()));
                            return(hasValue);
                        });

                        foreach (var item in queriedFeatures)
                        {
                            features.Add(item);
                        }
                    });

                    FeatureLayerViewModel entity = new FeatureLayerViewModel {
                        LayerName = layer.Name
                    };
                    foreach (var tmpFeature in features)
                    {
                        entity.FoundFeatures.Add(new FeatureViewModel(tmpFeature, layer));
                    }

                    Application.Current.Dispatcher.BeginInvoke(() =>
                    {
                        if (!FeatureEntities.Any(f => f.LayerName == entity.LayerName) && entity.FoundFeatures.Count > 0)
                        {
                            FeatureEntities.Add(entity);
                            if (FeatureEntities.Count > 0 && FeatureEntities[0].FoundFeatures.Count > 0)
                            {
                                selectedEntity = FeatureEntities[0].FoundFeatures[0];
                                RaisePropertyChanged(() => SelectedDataView);
                            }
                        }
                        IsBusy = false;
                    }, DispatcherPriority.ApplicationIdle);
                });
            }
        }