示例#1
0
        protected override bool IsInSelectionPhase()
        {
            if (KeyboardUtils.IsModifierPressed(Keys.Shift, true))
            {
                return(true);
            }

            var task = QueuedTask.Run(
                () =>
            {
                bool result;

                IList <Feature> selection =
                    SelectionUtils.GetSelectedFeatures(ActiveMapView).ToList();

                if (!CanUseSelection(selection))
                {
                    result = true;
                }
                else
                {
                    result = !CanUseDerivedGeometries();
                }

                return(result);
            });

            return(task.Result);
        }
示例#2
0
        protected void StartSelectionPhase()
        {
            SketchOutputMode = SelectionSettings.SketchOutputMode;

            // NOTE: CompleteSketchOnMouseUp must be set before the sketch geometry type,
            // otherwise it has no effect!
            CompleteSketchOnMouseUp = true;

            SketchType = SelectionSettings.SketchGeometryType;

            UseSnapping = false;

            GeomIsSimpleAsFeature = false;

            if (KeyboardUtils.IsModifierPressed(Keys.Shift, true))
            {
                SetCursor(SelectionCursorShift);
            }
            else
            {
                SetCursor(SelectionCursor);
            }

            OnSelectionPhaseStarted();
        }
示例#3
0
        private bool CanStartSketchPhase(IList <Feature> selectedFeatures)
        {
            if (KeyboardUtils.IsModifierPressed(Keys.Shift, true))
            {
                return(false);
            }

            return(CanStartSketchPhaseCore(selectedFeatures));
        }
示例#4
0
 protected override void OnKeyUpCore(MapViewKeyEventArgs k)
 {
     if (KeyboardUtils.IsModifierPressed(Keys.Shift, true))
     {
         SetCursor(SelectionCursorShift);
     }
     else
     {
         SetCursor(SelectionCursor);
     }
 }
示例#5
0
        protected override void OnKeyDownCore(MapViewKeyEventArgs k)
        {
            if (KeyboardUtils.IsModifierPressed(Keys.Shift, true))
            {
                SetCursor(SelectionCursorShift);
            }
            else
            {
                SetCursor(SelectionCursor);
            }

            _msg.VerboseDebug($"Key {k.Key} was pressed.");
        }
示例#6
0
        private SelectionMode GetSelectionSketchMode()
        {
            if (KeyboardUtils.IsModifierPressed(Keys.Alt))
            {
                return(SelectionMode.Original);
            }

            if (KeyboardUtils.IsModifierPressed(Keys.Control))
            {
                return(SelectionMode.UserSelect);
            }

            return(SelectionMode.Normal);
        }
示例#7
0
        private bool SelectTargets(List <Feature> selectedFeatures, Geometry sketch,
                                   CancelableProgressor progressor)
        {
            const TargetFeatureSelection targetFeatureSelection =
                TargetFeatureSelection.VisibleFeatures;

            sketch = ToolUtils.SketchToSearchGeometry(sketch, GetSelectionTolerancePixels(),
                                                      out bool _);

            Predicate <Feature> canUseAsTargetFeature =
                t => CanUseAsTargetFeature(selectedFeatures, t);

            SpatialRelationship spatialRel =
                SketchType == SketchGeometryType.Polygon
                                        ? SpatialRelationship.Contains
                                        : SpatialRelationship.Intersects;

            var foundOidsByLayer =
                MapUtils.FindFeatures(ActiveMapView, sketch, spatialRel,
                                      targetFeatureSelection, CanUseAsTargetLayer,
                                      canUseAsTargetFeature, selectedFeatures, progressor);

            // TODO: Picker if single click and several found

            if (progressor != null && progressor.CancellationToken.IsCancellationRequested)
            {
                _msg.Warn("Calculation of reshape lines was cancelled.");
                return(false);
            }

            IList <Feature> allTargetFeatures =
                GetDistinctSelectedFeatures(foundOidsByLayer, _changeAlongCurves?.TargetFeatures,
                                            KeyboardUtils.IsModifierPressed(Keys.Shift));

            _changeAlongCurves =
                allTargetFeatures.Count > 0
                                        ? CalculateReshapeCurves(selectedFeatures, allTargetFeatures, progressor)
                                        : new ChangeAlongCurves(new List <CutSubcurve>(),
                                                                ReshapeAlongCurveUsability.NoTarget);

            _feedback.Update(_changeAlongCurves);

            return(true);
        }
示例#8
0
        public void HandleFindKeyEvent(KeyEventArgs e)
        {
            if (FindResultCount == 0)
            {
                return;
            }

            bool shiftPressed = KeyboardUtils.IsModifierPressed(Keys.Shift);

            if ((e.KeyCode == Keys.Down || (e.KeyCode == Keys.Return && !shiftPressed)))
            {
                MoveToNext();
                e.Handled = true;
            }

            if (e.KeyCode == Keys.Up || (e.KeyCode == Keys.Return && shiftPressed))
            {
                MoveToPrevious();
                e.Handled = true;
            }
        }
示例#9
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);
        }
示例#10
0
 protected bool IsInSubcurveSelectionPhase()
 {
     return(HasReshapeCurves() &&
            !KeyboardUtils.IsModifierPressed(Keys.Shift, true));
 }
示例#11
0
 protected bool IsInSelectionPhase()
 {
     return(IsInSelectionPhase(KeyboardUtils.IsModifierPressed(Keys.Shift, true)));
 }