protected override void ExecuteScrollCommand(ScrollCommandKind command) { var commandOrientation = ScrollViewUtils.GetCommandOrientation(command); var orientation = Orientation; var orientedViewport = Viewport.AsOriented(orientation); var orientedExtent = Extent.AsOriented(orientation); var orientedOffset = Offset.AsOriented(orientation); var directScrollView = new OrientedScrollView(orientation, orientedViewport.Direct, orientedExtent.Direct, orientedOffset.Direct); var indirectScrollView = new OrientedScrollView(orientation.Rotate(), orientedViewport.Indirect, orientedExtent.Indirect, orientedOffset.Indirect); directScrollView.ExecuteScrollCommand(command, commandOrientation == orientation ? ScrollViewUtils.DefaultUnitSmallChange : ScrollViewUtils.DefaultPixelSmallChange, commandOrientation == orientation ? ScrollViewUtils.DefaultUnitWheelChange : ScrollViewUtils.DefaultPixelWheelChange); indirectScrollView.ExecuteScrollCommand(command, commandOrientation != orientation ? ScrollViewUtils.DefaultUnitSmallChange : ScrollViewUtils.DefaultPixelSmallChange, commandOrientation != orientation ? ScrollViewUtils.DefaultUnitWheelChange : ScrollViewUtils.DefaultPixelWheelChange); orientedOffset.Direct = directScrollView.Offset; orientedOffset.Indirect = indirectScrollView.Offset; Offset = orientedOffset.Vector; }
public static Orientation?GetCommandOrientation(ScrollCommandKind command) { switch (command) { case ScrollCommandKind.LineUp: case ScrollCommandKind.LineDown: case ScrollCommandKind.PageUp: case ScrollCommandKind.PageDown: case ScrollCommandKind.MouseWheelUp: case ScrollCommandKind.MouseWheelDown: case ScrollCommandKind.ScrollToTop: case ScrollCommandKind.ScrollToBottom: return(Orientation.Vertical); case ScrollCommandKind.LineLeft: case ScrollCommandKind.LineRight: case ScrollCommandKind.PageLeft: case ScrollCommandKind.PageRight: case ScrollCommandKind.MouseWheelLeft: case ScrollCommandKind.MouseWheelRight: case ScrollCommandKind.ScrollToLeft: case ScrollCommandKind.ScrollToRight: return(Orientation.Horizontal); case ScrollCommandKind.ScrollToHome: case ScrollCommandKind.ScrollToEnd: return(null); default: throw new ArgumentOutOfRangeException(nameof(command), command, null); } }
public void ExecuteScrollCommand(ScrollCommandKind command) { }
public static Vector ExecuteScrollCommand(Vector offset, ScrollCommandKind command, Size viewport, Size extent, double smallChange, double wheelChange) { switch (command) { case ScrollCommandKind.LineUp: offset.Y -= smallChange; break; case ScrollCommandKind.LineDown: offset.Y += smallChange; break; case ScrollCommandKind.LineLeft: offset.X -= smallChange; break; case ScrollCommandKind.LineRight: offset.X += smallChange; break; case ScrollCommandKind.PageUp: offset.Y -= viewport.Height; break; case ScrollCommandKind.PageDown: offset.Y += viewport.Height; break; case ScrollCommandKind.PageLeft: offset.X -= viewport.Width; break; case ScrollCommandKind.PageRight: offset.X += viewport.Width; break; case ScrollCommandKind.MouseWheelUp: offset.Y -= wheelChange; break; case ScrollCommandKind.MouseWheelDown: offset.Y += wheelChange; break; case ScrollCommandKind.MouseWheelLeft: offset.X -= wheelChange; break; case ScrollCommandKind.MouseWheelRight: offset.X += wheelChange; break; case ScrollCommandKind.ScrollToHome: offset = new Vector(0, 0); break; case ScrollCommandKind.ScrollToBottom: offset.Y = extent.Height - viewport.Height; break; case ScrollCommandKind.ScrollToTop: offset.Y = 0; break; case ScrollCommandKind.ScrollToRight: offset.X = extent.Width - viewport.Width; break; case ScrollCommandKind.ScrollToLeft: offset.X = 0; break; case ScrollCommandKind.ScrollToEnd: offset = new Vector(extent.Width - viewport.Width, extent.Height - viewport.Height); break; default: throw new ArgumentOutOfRangeException(nameof(command)); } return(offset); }