Ejemplo n.º 1
0
        protected override bool HandleEscape()
        {
            if (IsInSketchMode)
            {
                // if sketch is empty, also remove selection and return to selection phase

                if (!RequiresSelection)
                {
                    // remain in sketch mode, just reset the sketch
                    ResetSketch();
                }
                else
                {
                    Geometry sketch = GetCurrentSketchAsync().Result;

                    if (sketch != null && !sketch.IsEmpty)
                    {
                        ResetSketch();
                    }
                    else
                    {
                        SelectionUtils.ClearSelection(ActiveMapView.Map);

                        StartSelectionPhase();
                    }
                }
            }
            else
            {
                SelectionUtils.ClearSelection(ActiveMapView.Map);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public static void SelectLayersFeaturesByOids(
            KeyValuePair <BasicFeatureLayer, List <long> > featuresOfLayer,
            SelectionCombinationMethod method)
        {
            if (!featuresOfLayer.Value.Any())
            {
                return;
            }

            if (method == SelectionCombinationMethod.New)
            {
                //since SelectionCombinationMethod.New is only applied to
                //the current layer but selections of other layers remain,
                //we manually need to clear all selections first.
                SelectionUtils.ClearSelection(MapView.Active.Map);
            }

            {
                var qf = new QueryFilter
                {
                    ObjectIDs = featuresOfLayer.Value
                };
                featuresOfLayer.Key.Select(qf, method);
            }
        }
Ejemplo n.º 3
0
        public static void SelectLayersFeaturesByOids(
            [CanBeNull] Dictionary <BasicFeatureLayer, List <long> > featuresPerLayer,
            SelectionCombinationMethod method)
        {
            if (featuresPerLayer == null)
            {
                return;
            }

            if (method == SelectionCombinationMethod.New)
            {
                //since SelectionCombinationMethod.New is only applied to
                //the current layer but selections of other layers remain,
                //we manually need to clear all selections first.
                SelectionUtils.ClearSelection(MapView.Active.Map);
            }

            foreach (KeyValuePair <BasicFeatureLayer, List <long> > kvp in featuresPerLayer)
            {
                var qf = new QueryFilter
                {
                    ObjectIDs = kvp.Value
                };
                kvp.Key.Select(qf, method);
            }
        }
Ejemplo n.º 4
0
 protected override void AfterSelection(IList <Feature> selectedFeatures,
                                        CancelableProgressor progressor)
 {
     WorkListsModule.Current.OnWorkItemPicked(new WorkItemPickArgs
     {
         features = selectedFeatures.ToList()
     });
     SelectionUtils.ClearSelection(ActiveMapView.Map);
 }
Ejemplo n.º 5
0
        protected override bool HandleEscape()
        {
            SelectionUtils.ClearSelection(ActiveMapView.Map);

            ResetDerivedGeometries();

            StartSelectionPhase();

            return(true);
        }
Ejemplo n.º 6
0
        protected override bool OnToolActivatedCore(bool hasMapViewChanged)
        {
            var featureLayers = ActiveMapView.Map.Layers.OfType <FeatureLayer>();

            foreach (FeatureLayer featureLayer in featureLayers)
            {
                if (WorkListsModule.Current.LayerByWorkList.ContainsValue(featureLayer))
                {
                    LayerUtils.SetLayerSelectability(featureLayer, true);
                }
            }

            SelectionUtils.ClearSelection(ActiveMapView.Map);

            return(true);
        }
Ejemplo n.º 7
0
        private void TreeView_SelectedItemChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs <object> e)
        {
            var oldItemSource = e.OldValue as ICloudExplorerItemSource;

            if (oldItemSource != null)
            {
                oldItemSource.ItemChanged -= OnItemChanged;
            }

            var newItemSource = e.NewValue as ICloudExplorerItemSource;

            if (newItemSource == null)
            {
                _selectionUtils.ClearSelection();
                return;
            }
            newItemSource.ItemChanged += OnItemChanged;

            _selectionUtils.SelectItem(newItemSource.Item);
        }
Ejemplo n.º 8
0
        protected override bool HandleEscape()
        {
            QueuedTaskUtils.Run(
                () =>
            {
                if (IsInSubcurveSelectionPhase())
                {
                    ResetDerivedGeometries();
                }
                else
                {
                    SelectionUtils.ClearSelection(ActiveMapView.Map);
                    StartSelectionPhase();
                }

                return(true);
            });

            return(true);
        }
Ejemplo n.º 9
0
        private void InvalidateSelectedItem()
        {
            RaisePropertyChanged(nameof(SelectedItem));

            if (SelectedItem != null)
            {
                PropertyWindowItemBase item;
                if (SelectedItem.IsDirectory)
                {
                    item = new GcsDirectoryItem(SelectedItem);
                }
                else
                {
                    item = new GcsFileItem(SelectedItem);
                }
                _selectionUtils.SelectItem(item);
            }
            else
            {
                _selectionUtils.ClearSelection();
            }
        }
Ejemplo n.º 10
0
        private async Task <bool> OnSelectionSketchComplete(Geometry sketchGeometry,
                                                            CancelableProgressor progressor)
        {
            // TODO: Add Utils method to KeyboardUtils to do it in the WPF way
            SelectionCombinationMethod selectionMethod =
                KeyboardUtils.IsModifierPressed(Keys.Shift)
                                        ? SelectionCombinationMethod.XOR
                                        : SelectionCombinationMethod.New;

            Geometry selectionGeometry;
            var      pickerWindowLocation = new Point(0, 0);

            Dictionary <BasicFeatureLayer, List <long> > candidatesOfManyLayers =
                await QueuedTaskUtils.Run(() =>
            {
                DisposeOverlays();

                selectionGeometry    = GetSelectionGeometry(sketchGeometry);
                pickerWindowLocation =
                    MapView.Active.MapToScreen(selectionGeometry.Extent.Center);

                // find all features spatially related with selectionGeometry
                return(FindFeaturesOfAllLayers(selectionGeometry));
            });

            if (!candidatesOfManyLayers.Any())
            {
                //no candidate (user clicked into empty space): clear selection
                await QueuedTask.Run(() =>
                {
                    SelectionUtils.ClearSelection(ActiveMapView.Map);
                });

                return(false);
            }

            if (SketchingMoveType == SketchingMoveType.Click)
            {
                //note if necessary add a virtual core method here for overriding

                if (GetSelectionSketchMode() == SelectionMode.Original
                    )             //alt was pressed: select all xy
                {
                    await QueuedTask.Run(() =>
                    {
                        Selector.SelectLayersFeaturesByOids(
                            candidatesOfManyLayers, selectionMethod);
                    });
                }

                // select a single feature using feature reduction and picker
                else
                {
                    IEnumerable <KeyValuePair <BasicFeatureLayer, List <long> > > candidatesOfLayers =
                        await QueuedTask.Run(
                            () => GeometryReducer.GetReducedset(candidatesOfManyLayers));

                    // show picker if more than one candidate
                    if (GeometryReducer.ContainsManyFeatures(candidatesOfManyLayers))
                    {
                        List <IPickableItem> pickables = new List <IPickableItem>();
                        foreach (var layerCandidates in candidatesOfLayers)
                        {
                            pickables.AddRange(
                                await QueuedTask.Run(
                                    () => PickerUI.Picker.CreatePickableFeatureItems(
                                        layerCandidates)));
                        }

                        var picker = new PickerUI.Picker(pickables, pickerWindowLocation);

                        var item = await picker.PickSingle() as PickableFeatureItem;

                        if (item != null)
                        {
                            var kvp = new KeyValuePair <BasicFeatureLayer, List <long> >(
                                item.Layer, new List <long> {
                                item.Oid
                            });

                            await QueuedTask.Run(() =>
                            {
                                Selector.SelectLayersFeaturesByOids(
                                    kvp, selectionMethod);
                            });
                        }
                    }
                    else
                    {
                        await QueuedTask.Run(() =>
                        {
                            Selector.SelectLayersFeaturesByOids(
                                candidatesOfLayers.First(), selectionMethod);
                        });
                    }
                }
            }

            if (SketchingMoveType == SketchingMoveType.Drag)
            {
                //CTRL was pressed: picker shows FC's to select from
                if (GetSelectionSketchMode() == SelectionMode.UserSelect)
                {
                    List <IPickableItem> pickingCandidates = await QueuedTask.Run(() =>
                    {
                        List <FeatureClassInfo> featureClassInfos =
                            Selector.GetSelectableFeatureclassInfos();

                        return(PickableItemAdapter.Get(featureClassInfos));
                    });

                    var picker = new PickerUI.Picker(pickingCandidates, pickerWindowLocation);

                    var item = await picker.PickSingle() as PickableFeatureClassItem;

                    if (item != null)
                    {
                        await QueuedTask.Run(() =>
                        {
                            item.BelongingFeatureLayers.ForEach(layer =>
                            {
                                List <long> oids = candidatesOfManyLayers[layer];
                                QueryFilter qf   = new QueryFilter {
                                    ObjectIDs = oids
                                };
                                layer.Select(qf, selectionMethod);
                            });
                        });
                    }
                }

                //no modifier pressed: select all in envelope
                else
                {
                    await QueuedTask.Run(() =>
                    {
                        Selector.SelectLayersFeaturesByOids(
                            candidatesOfManyLayers, selectionMethod);
                    });
                }
            }

            MapView activeMapView = MapView.Active;

            await QueuedTask.Run(() =>
                                 ProcessSelection(
                                     SelectionUtils.GetSelectedFeatures(activeMapView),
                                     progressor));

            return(true);
        }