I am trying to implement zooming in on the diagram using Shift key continuously pressed and mouse drag (mouse dragged with left key pressed, and released, to zoom into selected area).
Here when we keep Shift pressed i want only the blue selection box to appear, and None of the nodes on the diagram should get selected and it should also Not allow link creation at this time.
I tried:..
diagram.KeyDown += OnDiagramKeyDown;
diagram.KeyUp += OnDiagramKeyUp;
diagram.MouseUp += OnMouseUp;
..
void OnDiagramKeyDown(object sender..
{
if (Keyboard.Modifiers == ModifierKeys.Shift)
{
shiftPressed = true;
diagram.Behavior = Behavior.SelectOnly; // ! doesn't help.
}
}
void OnDiagramKeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
{
isShiftPressed = false;
diagram.Behavior = Behavior.DrawLinks;
}
}
private void OnMouseUp(object sender, MouseButtonEventArgs e)
{
if (isShiftPressed)
diagram.ZoomToRect(diagram.Selection.Bounds, true);
}
The zooming is fine but, even though the diagram Behavior is set to 'SelectOnly' the nodes also gets selected, that i am not looking for.
. Any help is appreciated. Thanks a lot.