protected override void OnToolKeyUp(MapViewKeyEventArgs k) { _msg.VerboseDebug("OnToolKeyUp"); try { QueuedTaskUtils.Run( delegate { if (IsShiftKey(k.Key)) { ShiftReleasedCore(); } OnKeyUpCore(k); return(true); }); } catch (Exception e) { HandleError($"Error in tool key up ({Caption}): {e.Message}", e, true); } finally { PressedKeys.Remove(k.Key); } }
protected override Task HandleKeyDownAsync(MapViewKeyEventArgs k) { var camera = MapView.Active.Camera; switch (k.Key) { case Key.J: { camera.Pitch += 5; camera.Z += 5; _timer.Enabled = true; } break; case Key.R: camera.Roll -= 45; break; case Key.L: camera.Roll += 45; break; case Key.Q: _active = !_active; break; } return(MapView.Active.ZoomToAsync(camera, new TimeSpan(0, 0, 0, 0, 250))); }
protected override void OnToolKeyUp(MapViewKeyEventArgs k) { System.Diagnostics.Debug.WriteLine($"OnToolKeyUp Key: {k.Key.ToString()}"); if (k.Key == System.Windows.Input.Key.W) { //if (_inSelMode) System.Diagnostics.Debug.WriteLine($"OnToolKeyUp: _inSelMode {_inSelMode}"); if (_inSelMode) { _inSelMode = false; k.Handled = true; //process this one System.Diagnostics.Debug.WriteLine($"OnToolKeyUp: ActivateSelectAsync(false)"); //Toggle us back to sketch mode. With UseSelection = true //the sketch is restored ActivateSelectAsync(false); //Check if sketching was actually started when we toggled modes if (!_sketchStarted) { //As sketching was not actually started we need to //start it manually this.StartSketchAsync(); } } } else if (_inSelMode) { //disable effect of Shift or Ctrl key //in the base class. We do not want it to intefere with our tool. //Mark the key event as handled to prevent further processing k.Handled = Module1.Current.IsShiftKey(k); } }
protected override async Task HandleKeyDownAsync(MapViewKeyEventArgs k) { try { if (k.Key == _keyToggleNonDefaultSide) { _nonDefaultSideMode = !_nonDefaultSideMode; _msg.Info(_nonDefaultSideMode ? "Enabled non-default reshape mode. The next reshape to the inside of a polygon will remove the larger area. The next Y-Reshape will use the farther end-point." : "Disabled non-default reshape mode"); if (_updateFeedbackTask != null) { // Still working on the previous update (large poylgons!) return; } _updateFeedbackTask = UpdateFeedbackAsync(_nonDefaultSideMode); await _updateFeedbackTask; } } catch (Exception e) { _msg.Warn("Error generating preview", e); } finally { _updateFeedbackTask = null; } }
protected override void OnToolKeyUp(MapViewKeyEventArgs k) { _msg.VerboseDebug("OnToolKeyUp"); // TODO: Key pressed management //_shiftIsPressed = false; try { QueuedTaskUtils.Run( delegate { if ((k.Key == Key.LeftShift || k.Key == Key.RightShift) && SelectionCursor != null && IsInSelectionPhase()) { SetCursor(SelectionCursor); } OnKeyUpCore(k); return(true); }); } catch (Exception e) { HandleError($"Error in tool key up ({Caption}): {e.Message}", e, true); } }
protected override void OnKeyUpCore(MapViewKeyEventArgs k) { if (IsShiftKey(k.Key)) { Cursor = IsInSelectionPhase(true) ? SelectionCursor : SecondPhaseCursor; } }
protected override void OnKeyUpCore(MapViewKeyEventArgs k) { if (k.Key == Key.LeftShift || k.Key == Key.RightShift) { Cursor = IsInSelectionPhase() ? SelectionCursor : SecondPhaseCursor; } }
// If the user presses Escape cancel the sketch protected override void OnToolKeyDown(MapViewKeyEventArgs k) { if (k.Key == Key.Escape) { k.Handled = true; Mediator.NotifyColleagues(DistanceAndDirectionLibrary.Constants.KEYPRESS_ESCAPE, null); } }
protected override void OnToolKeyDown(MapViewKeyEventArgs k) { base.OnToolKeyDown(k); if (k.Key == System.Windows.Input.Key.Escape) { this.OnToolDeactivateAsync(false); } }
protected override void OnToolKeyDown(MapViewKeyEventArgs k) { // using key up and down in order to zoom out and in // if those keys are used we need to mark them as handled if (k.Key == Key.Up || k.Key == Key.Down) k.Handled = true; base.OnToolKeyDown(k); }
protected override void OnKeyDownCore(MapViewKeyEventArgs k) { if (k.Key == Key.P) { SketchType = SketchGeometryType.Polygon; SetCursor(PolygonSketchCursor); } }
protected override void OnToolKeyDown(MapViewKeyEventArgs k) { //We will do some basic key handling to allow panning //from the arrow keys if (k.Key == Key.Left || k.Key == Key.Right || k.Key == Key.Up || k.Key == Key.Down) k.Handled = true; base.OnToolKeyDown(k); }
protected override void OnToolKeyDown(MapViewKeyEventArgs k) { // using key up and down in order to zoom out and in // if those keys are used we need to mark them as handled if (k.Key == Key.Up || k.Key == Key.Down) { k.Handled = true; } base.OnToolKeyDown(k); }
protected override void OnKeyUpCore(MapViewKeyEventArgs k) { if (KeyboardUtils.IsModifierPressed(Keys.Shift, true)) { SetCursor(SelectionCursorShift); } else { SetCursor(SelectionCursor); } }
/// <summary> /// Set whether the ctrl or shift key is pressed. /// </summary> protected override void OnToolKeyUp(MapViewKeyEventArgs k) { if (k.Key == Key.LeftCtrl) { _ctrlPressed = false; } if (k.Key == Key.LeftShift) { _shiftPressed = false; } }
protected override Task HandleKeyDownAsync(MapViewKeyEventArgs k) { var camera = MapView.Active.Camera; double dx = MapView.Active.Extent.Width / 20; double dy = MapView.Active.Extent.Height / 20; double dz = 20.0;//20 meters vertical change per key stroke bool shiftKey = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift; //When in 3D mode use the Shift key to switch from "Y" position change //which is 'Up','Down' in 2D but is 'forward','back' in 3D to //"Z" position change which is 'Up','Down' in 3D if (!_zMode && ActiveMapView.ViewingMode != MapViewingMode.Map) { _zMode = shiftKey; } switch (k.Key) { case Key.Left: camera.X -= dx; break; case Key.Right: camera.X += dx; break; case Key.Up: if (_zMode) { camera.Z += 20; } else { camera.Y += dy; } break; case Key.Down: if (_zMode) { camera.Z -= 20; } else { camera.Y -= dy; } break; } return(MapView.Active.ZoomToAsync(camera, new TimeSpan(0, 0, 0, 0, 250))); }
protected override void OnKeyDownCore(MapViewKeyEventArgs k) { if (KeyboardUtils.IsModifierPressed(Keys.Shift, true)) { SetCursor(SelectionCursorShift); } else { SetCursor(SelectionCursor); } _msg.VerboseDebug($"Key {k.Key} was pressed."); }
protected override void OnToolKeyDown(MapViewKeyEventArgs k) { //We will do some basic key handling to allow panning //from the arrow keys if (k.Key == Key.Left || k.Key == Key.Right || k.Key == Key.Up || k.Key == Key.Down) { k.Handled = true; } base.OnToolKeyDown(k); }
protected override Task HandleKeyDownAsync(MapViewKeyEventArgs k) { // only called when 'handled' in OnToolKeyDown if (k.Key == Key.Up) { // Key.Up => zoom out return(ActiveMapView.ZoomOutFixedAsync(TimeSpan.FromSeconds(1))); } // Key.Down => zoom in // else if (k.Key == Key.Down) { return(ActiveMapView.ZoomInFixedAsync(TimeSpan.FromSeconds(1))); } }
protected override void OnToolKeyDown(MapViewKeyEventArgs k) { //display options form to set help set start value if (k.Key == System.Windows.Input.Key.Multiply | k.Key == System.Windows.Input.Key.O) { var svf = new StartValue(); svf.ShowDialog(); if (svf.DialogResult.HasValue && svf.DialogResult.Value) { _vm.startValue = svf._svalue; } } }
protected override void OnToolKeyDown(MapViewKeyEventArgs k) { //We will do some basic key handling to allow jumping and rolling if ((k.Key == Key.J) || (k.Key == Key.R) || (k.Key == Key.L) || (k.Key == Key.Q)) { k.Handled = true; } else { base.OnToolKeyDown(k); } }
protected override void OnKeyUpCore(MapViewKeyEventArgs k) { if (k.Key == Key.P) { SketchType = SketchGeometryType.Rectangle; if (!IsInSelectionPhase()) { SetCursor(TargetSelectionCursor); } else { SetCursor(SelectionCursor); } } }
protected override void OnToolKeyDown(MapViewKeyEventArgs k) { _msg.VerboseDebug("OnToolKeyDown"); try { PressedKeys.Add(k.Key); if (IsModifierKey(k.Key) || HandledKeys.Contains(k.Key)) { k.Handled = true; } if (k.Key == _keyShowOptionsPane) { ShowOptionsPane(); } // Cancel outside a queued task otherwise the current task that blocks the queue // cannot be cancelled. if (k.Key == Key.Escape) { HandleEscape(); } QueuedTaskUtils.Run( delegate { if (IsShiftKey(k.Key) && SelectionCursorShift != null && IsInSelectionPhase()) { SetCursor(SelectionCursorShift); } OnKeyDownCore(k); return(true); }); } catch (Exception e) { HandleError($"Error in tool key down ({Caption}): {e.Message}", e, true); } }
protected override void OnKeyUpCore(MapViewKeyEventArgs k) { _msg.VerboseDebug("OnKeyUpCore"); if (IsShiftKey(k.Key)) { _intermittentSelectionPhase = false; // TODO: Maintain selection by using SelectionChanged? Event? IList <Feature> selection = SelectionUtils.GetSelectedFeatures(ActiveMapView).ToList(); if (CanUseSelection(selection)) { StartSketchPhase(); if (_editSketchBackup != null) { ActiveMapView.SetCurrentSketchAsync(_editSketchBackup); // This puts back the edit operations in the undo stack, but when clicking on the top one, the sketch // is cleared and undoing any previous operation has no effect any more. ActiveMapView.Map.OperationManager.ClearUndoCategory("SketchOperations"); if (_sketchOperations != null) { foreach (Operation operation in _sketchOperations) { ActiveMapView.Map.OperationManager.AddUndoOperation(operation); } } } } _editSketchBackup = null; } if (k.Key == _keyRestorePrevious) { RestorePreviousSketch(); } }
protected override Task HandleKeyDownAsync(MapViewKeyEventArgs k) { var camera = MapView.Active.Camera; double dx = MapView.Active.Extent.Width / 20; double dy = MapView.Active.Extent.Height / 20; double dz = 20.0;//20 meters vertical change per key stroke bool shiftKey = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift; //When in 3D mode use the Shift key to switch from "Y" position change //which is 'Up','Down' in 2D but is 'forward','back' in 3D to //"Z" position change which is 'Up','Down' in 3D if (!_zMode && ActiveMapView.ViewingMode != MapViewingMode.Map) _zMode = shiftKey; switch (k.Key) { case Key.Left: camera.X -= dx; break; case Key.Right: camera.X += dx; break; case Key.Up: if (_zMode) { camera.Z += dz; } else { camera.Y += dy; } break; case Key.Down: if (_zMode) { camera.Z -= dz; } else { camera.Y -= dy; } break; } return MapView.Active.ZoomToAsync(camera, new TimeSpan(0, 0, 0, 0, 250)); }
protected override void OnKeyDownCore(MapViewKeyEventArgs k) { _msg.VerboseDebug("OnKeyDownCore"); if (IsShiftKey(k.Key)) { if (_intermittentSelectionPhase) { // This is called repeatedly while keeping the shift key pressed return; } if (!IsInSketchMode) { return; } _intermittentSelectionPhase = true; // TODO: How can we not destroy the undo stack? OperationManager operationManager = ActiveMapView.Map.OperationManager; // It is technically possible to put back the operations by calling operationManager.AddUndoOperation(). // But whether we can make them work when actually executed requires more tests.. and this is probably not the good way to do it! _sketchOperations = operationManager.FindUndoOperations(operation => operation.Category == "SketchOperations"); // By backing up and re-setting the edit sketch the individual operations that made up the // sketch are lost. _editSketchBackup = GetCurrentSketchAsync().Result; // TODO: Only clear the sketch and switch to selection phase if REALLY required // (i.e. because a rectangle sketch must be drawn on MouseMove) ClearSketchAsync(); StartSelectionPhase(); } }
protected override void OnToolKeyUp(MapViewKeyEventArgs k) { if (k.Key == System.Windows.Input.Key.W) { if (_inSelMode) { _inSelMode = false; k.Handled = true;//process this one // Toggle back to sketch mode. If UseSelection = true // the sketch will be restored ActivateSelectAsync(false); } } else if (_inSelMode) { //disable effect of Shift in the base class. //Mark the key event as handled to prevent further processing k.Handled = IsShiftKey(k); } }
protected override void OnToolKeyDown(MapViewKeyEventArgs k) { _msg.VerboseDebug("OnToolKeyDown"); try { if (IsModifierKey(k.Key) || HandledKeys.Contains(k.Key)) { k.Handled = true; } if (k.Key == _keyShowOptionsPane) { ShowOptionsPane(); } QueuedTaskUtils.Run( delegate { if (k.Key == Key.Escape) { return(HandleEscape()); } if ((k.Key == Key.LeftShift || k.Key == Key.RightShift) && SelectionCursorShift != null && IsInSelectionPhase()) { SetCursor(SelectionCursorShift); } OnKeyDownCore(k); return(true); }); } catch (Exception e) { HandleError($"Error in tool key down ({Caption}): {e.Message}", e, true); } }
protected override void OnToolKeyDown(MapViewKeyEventArgs k) { System.Diagnostics.Debug.WriteLine($"OnToolKeyDown Key: {k.Key.ToString()}"); //toggle sketch selection mode with a custom key if (k.Key == System.Windows.Input.Key.W) { if (!_inSelMode) { _inSelMode = true; k.Handled = true; System.Diagnostics.Debug.WriteLine($"OnToolKeyDown: ActivateSelectAsync(true)"); //toggle the tool to select mode. //The sketch is saved if UseSelection = true; ActivateSelectAsync(true); } } else if (!_inSelMode) { //disable effect of Shift or Ctrl key //in the base class. We do not want it to intefere with our tool. //Mark the key event as handled to prevent further processing k.Handled = Module1.Current.IsShiftKey(k); } }
protected override async void OnToolKeyDown(MapViewKeyEventArgs k) { //toggle sketch selection mode with a custom key if (k.Key == System.Windows.Input.Key.W) { if (!_inSelMode) { k.Handled = true; // Toggle the tool to select mode. // The sketch is saved if UseSelection = true; if (await ActivateSelectAsync(true)) { _inSelMode = true; } } } else if (!_inSelMode) { //disable effect of Shift in the base class. //Mark the key event as handled to prevent further processing k.Handled = IsShiftKey(k); } }
protected override Task HandleKeyDownAsync(MapViewKeyEventArgs k) { //Called when we return "k.Handled = true;" from OnToolKeyDown //TODO any additional key down handling logic here return(Task.FromResult(0)); }
/// <summary> /// Set whether the ctrl or shift key is pressed. /// </summary> protected override void OnToolKeyUp(MapViewKeyEventArgs k) { if (k.Key == Key.LeftCtrl) _ctrlPressed = false; if (k.Key == Key.LeftShift) _shiftPressed = false; }
protected override void OnToolKeyUp(MapViewKeyEventArgs k) { _zMode = false; base.OnToolKeyUp(k); }
public bool IsShiftKey(MapViewKeyEventArgs k) { return(k.Key == System.Windows.Input.Key.LeftShift || k.Key == System.Windows.Input.Key.RightShift); }
protected override Task HandleKeyDownAsync(MapViewKeyEventArgs k) { // only called when 'handled' in OnToolKeyDown if (k.Key == Key.Up) { // Key.Up => zoom out return ActiveMapView.ZoomOutFixedAsync(TimeSpan.FromSeconds(1)); } // Key.Down => zoom in // else if (k.Key == Key.Down) { return ActiveMapView.ZoomInFixedAsync(TimeSpan.FromSeconds(1)); } }