private void OnScroll(ScrollAction scrollAction) { var handler = RelayedScroll; if (null != handler) { handler(this, new RelayedScrollEventArgs(scrollAction)); } }
private bool ScrollUntil(SomethingToScrollTo check, FailureToScrollHandler handler, ScrollAction action, ScrollPercentCheck percentCheck) { while (!check(this) && percentCheck()) { action(); } if (!check(this)) { handler(this); } return !check(this); }
public virtual void PerformScroll(int direction) { if (OutOfBounds || Disabled) { return; } ScrollAction?.Invoke(direction, this); foreach (UIElement child in Children) { child.PerformScroll(direction); } }
/// <summary> /// scroll /// </summary> /// <param name="config"></param> /// <param name="touch"></param> /// <param name="relativePosition"></param> /// <param name="totalmovingPosition"></param> /// <returns></returns> protected void OnScroll(SingleAnixConfig config, bool touch, double relativePosition, double totalmovingPosition) { if (config == null) { return; } var scrollAction = new ScrollAction { KaraokeScrollAction = config.KaraokeScrollAction, Touch = touch, RelativeMovingPosition = relativePosition, TotalMovingPosition = totalmovingPosition }; InputAction.Value = scrollAction; }
/// <summary> /// Image is loading in image viewer. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ImageLoadingEventArgs"/> instance containing the event data.</param> private void ImageViewer_ImageLoading(object sender, ImageLoadingEventArgs e) { // if scrolling is in progress if (_scrollAction != ScrollAction.None) { ImageViewer.ImageLoading -= new EventHandler <ImageLoadingEventArgs>(ImageViewer_ImageLoading); float autoScrollPositionX; float autoScrollPositionY; // autoScrollPositionX float proportion = (float)ImageViewer.Image.Width / _previouslyFocusedImageWidth; autoScrollPositionX = _previouslyFocusedImageAutoScrollPositionX * proportion; // autoScrollPositionY switch (_scrollAction) { case ScrollAction.MoveToNextPage: autoScrollPositionY = 0; break; case ScrollAction.MoveToPreviousPage: autoScrollPositionY = ImageViewer.Image.Height; break; default: throw new Exception(); } // set scroll of new focused image ImageViewer.ViewerState.AutoScrollPosition = new PointF(autoScrollPositionX, autoScrollPositionY); _scrollAction = ScrollAction.None; } _isPageChanging = false; }
private void Viewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e) { if (!isHold) { e.Handled = true; // Scroll Factor acceleration = 0.1; isBounding = false; lastScroll = ScrollAction.Wheel; // Scroll Direction int sDelta = -Math.Sign(e.Delta); if (sDelta != lastDelta) { toOffset = virtualOffset; } lastDelta = sDelta; // Target Offset & Bounding toOffset = BoundingOffsetLimit(toOffset + sDelta * StepSize); } }
private void OnScroll( ScrollAction scrollAction ) { var handler = RelayedScroll; if ( null != handler ) { handler( this, new RelayedScrollEventArgs( scrollAction ) ); } }
public void PerformScroll(ScrollAction action, Orientation scrollBar) { if (scrollBar == Orientation.Horizontal) { int pos = -_displayRect.X; int maxPos = _horizontalScroll.Maximum; switch (action) { case ScrollAction.LineUp: if (pos > _horizontalScroll.SmallChange) pos -= _horizontalScroll.SmallChange; else pos = 0; break; case ScrollAction.LineDown: if (pos < maxPos - _horizontalScroll.SmallChange) pos += _horizontalScroll.SmallChange; else pos = maxPos; break; case ScrollAction.PageUp: if (pos > _horizontalScroll.LargeChange) pos -= _horizontalScroll.LargeChange; else pos = 0; break; case ScrollAction.PageDown: if (pos < maxPos - _horizontalScroll.LargeChange) pos += _horizontalScroll.LargeChange; else pos = maxPos; break; case ScrollAction.Home: pos = 0; break; case ScrollAction.End: pos = maxPos; break; } SetDisplayRectLocation(-pos, _displayRect.Y); } else { int pos = -_displayRect.Y; int maxPos = _verticalScroll.Maximum; switch (action) { case ScrollAction.LineUp: if (pos > 0) pos -= _verticalScroll.SmallChange; else pos = 0; break; case ScrollAction.LineDown: if (pos < maxPos - _verticalScroll.SmallChange) pos += _verticalScroll.SmallChange; else pos = maxPos; break; case ScrollAction.PageUp: if (pos > _verticalScroll.LargeChange) pos -= _verticalScroll.LargeChange; else pos = 0; break; case ScrollAction.PageDown: if (pos < maxPos - _verticalScroll.LargeChange) pos += _verticalScroll.LargeChange; else pos = maxPos; break; case ScrollAction.Home: pos = 0; break; case ScrollAction.End: pos = maxPos; break; } SetDisplayRectLocation(_displayRect.X, -pos); } SyncScrollbars(); }
private bool ScrollUntil(SomethingToScrollTo check, FailureToScrollHandler handler, ScrollAction action, ScrollPercentCheck percentCheck) { while (!check(this) && percentCheck()) { action(); } if (!check(this)) { handler(this); } return(!check(this)); }
public RelayedScrollEventArgs( ScrollAction scrollAction ) { ScrollAction = scrollAction; }
public RelayedScrollEventArgs(ScrollAction scrollAction) { ScrollAction = scrollAction; }
/// <summary> /// Simulates a click on a scroll-bar component. /// </summary> /// <remarks> /// Cascading Style Sheets (CSS) allow you to scroll on all objects through the IHTMLStyle::overflow property. /// <para>When the content of an element changes and causes scroll bars to display, the IHTMLElement2::doScroll method might not work correctly immediately following the content update. When this happens, you can use the IHTMLWindow2::setTimeout method to enable the browser to recognize the dynamic changes that affect scrolling.</para> /// </remarks> /// <param name="scroll"></param> public void DoScroll(ScrollAction scroll) { el2.DoScroll(scroll.ToString()); }
protected override void OnProcess(Action.IAction action) { ScrollAction scrollAction = action as ScrollAction; if (scrollAction == null) { return; } LoggerManager.Debug(action.AutomationActionData); // page if (scrollAction.Position == Position.None) { return; } InitScroll(); this.period = scrollAction.Period; if (scrollAction.Position == Position.PageBottom) { bottom = GetMaxPosition(); } else if (scrollAction.Position == Position.Middle) { bottom = GetMaxPosition(); bottom = bottom / 2; } else if (scrollAction.Position == Position.Element) { HtmlElement element = this.GetData(action) as HtmlElement; if (element == null) { LoggerManager.Error("Element Not Found"); throw new ElementNoFoundException("Element Not Found", action); } bottom = GetY(element); if (bottom == 0) { bottom = GetYoffset(element); } } if (scrollAction.Factor > 0) { bottom = bottom / scrollAction.Factor; } int current = GetY(); if (bottom == current) { return; } else if (bottom > current) { positive = true; bottom += scrollAction.Offset; } else { positive = false; bottom -= scrollAction.Offset; } timer.Change(this.period, Timeout.Infinite); }
/// <summary> /// Scrolls the content in ScrollViewerFresh according to the indicated action. /// </summary> /// <param name="scrollAction">The indicated action.</param> public void ScrollTo(ScrollAction scrollAction) { switch (scrollAction) { case ScrollAction.LineDown: { LineDown(); } break; case ScrollAction.LineLeft: { LineLeft(); } break; case ScrollAction.LineRight: { LineRight(); } break; case ScrollAction.LineUp: { LineUp(); } break; case ScrollAction.PageDown: { PageDown(); } break; case ScrollAction.PageLeft: { PageLeft(); } break; case ScrollAction.PageRight: { PageRight(); } break; case ScrollAction.PageUp: { PageUp(); } break; case ScrollAction.ToBottom: { ScrollToBottom(); } break; case ScrollAction.ToEnd: { ScrollToEnd(); } break; case ScrollAction.ToHome: { ScrollToHome(); } break; case ScrollAction.ToLeftEnd: { ScrollToLeftEnd(); } break; case ScrollAction.ToRightEnd: { ScrollToRightEnd(); } break; case ScrollAction.ToTop: { ScrollToTop(); } break; //case ScrollAction.ToHorizontalOffset: // { // ScrollToHorizontalOffset(double offset); // } // break; //case ScrollAction.ToVerticalOffset: // { // ScrollToVerticalOffset(double offset); // } // break; } }
public void PerformScroll(ScrollAction action, Orientation scrollBar) { if (scrollBar == Orientation.Horizontal) { int pos = -_displayRect.X; int maxPos = _horizontalScroll.Maximum; switch (action) { case ScrollAction.LineUp: if (pos > _horizontalScroll.SmallChange) { pos -= _horizontalScroll.SmallChange; } else { pos = 0; } break; case ScrollAction.LineDown: if (pos < maxPos - _horizontalScroll.SmallChange) { pos += _horizontalScroll.SmallChange; } else { pos = maxPos; } break; case ScrollAction.PageUp: if (pos > _horizontalScroll.LargeChange) { pos -= _horizontalScroll.LargeChange; } else { pos = 0; } break; case ScrollAction.PageDown: if (pos < maxPos - _horizontalScroll.LargeChange) { pos += _horizontalScroll.LargeChange; } else { pos = maxPos; } break; case ScrollAction.Home: pos = 0; break; case ScrollAction.End: pos = maxPos; break; } SetDisplayRectLocation(-pos, _displayRect.Y); } else { int pos = -_displayRect.Y; int maxPos = _verticalScroll.Maximum; switch (action) { case ScrollAction.LineUp: if (pos > 0) { pos -= _verticalScroll.SmallChange; } else { pos = 0; } break; case ScrollAction.LineDown: if (pos < maxPos - _verticalScroll.SmallChange) { pos += _verticalScroll.SmallChange; } else { pos = maxPos; } break; case ScrollAction.PageUp: if (pos > _verticalScroll.LargeChange) { pos -= _verticalScroll.LargeChange; } else { pos = 0; } break; case ScrollAction.PageDown: if (pos < maxPos - _verticalScroll.LargeChange) { pos += _verticalScroll.LargeChange; } else { pos = maxPos; } break; case ScrollAction.Home: pos = 0; break; case ScrollAction.End: pos = maxPos; break; } SetDisplayRectLocation(_displayRect.X, -pos); } SyncScrollbars(); }
private void ScrollBar_PreviewMouseDown(object sender, MouseButtonEventArgs e) { Visual source = e.OriginalSource as Visual; if (source.FindVisualParents <Thumb>(false).Count() > 0) { if (isHold = Mouse.Capture(ScrollBar as IInputElement)) { e.Handled = true; // Scroll Factor lastScroll = ScrollAction.Mouse; beginValue = ScrollBar.Value; beginPosition = Mouse.GetPosition(ScrollBar); } } else { RepeatButtonHolder holder = null; RepeatButton repeatButton = source .FindVisualParents <RepeatButton>(false) .FirstOrDefault(); var pos = Mouse.GetPosition(ScrollBar.Track); if (repeatButton == ScrollBar.Track.IncreaseRepeatButton || // Down Track repeatButton == ScrollBar.Track.DecreaseRepeatButton) // Up Track { e.Handled = true; double targetOffset = pos.Y * GetScrollRatio(); double thumbOffset = ScrollBar.Track.Thumb.ActualHeight * GetScrollRatio(); if (targetOffset > virtualOffset) { targetOffset -= thumbOffset; } targetOffset = OffsetLimit(targetOffset); holder = new RepeatButtonHolder(repeatButton); holder.OnClick += delegate { // Scroll Factor isBounding = false; acceleration = 0.15; lastScroll = ScrollAction.Track; // Target Offset double delta = targetOffset - toOffset; int sDelta = Math.Sign(delta); double offset = toOffset + thumbOffset * sDelta; if (Math.Abs(targetOffset - offset) < thumbOffset) { toOffset = targetOffset; } else { toOffset = offset; } }; } else { // Small RepeatButton e.Handled = true; if (pos.Y < ScrollBar.Track.ActualHeight / 2) // Up Button { holder = new RepeatButtonHolder(repeatButton); holder.OnClick += delegate { // Scroll Factor isBounding = false; acceleration = 0.15; lastScroll = ScrollAction.Track; toOffset -= StepSize / 3; toOffset = OffsetLimit(toOffset); }; } else // Down Button { holder = new RepeatButtonHolder(repeatButton); holder.OnClick += delegate { // Scroll Factor isBounding = false; acceleration = 0.15; lastScroll = ScrollAction.Track; toOffset += StepSize / 3; toOffset = OffsetLimit(toOffset); }; } } if (holder != null) { holder.Start(); repeatHolders.Add(holder); } } }
/// <summary> /// Scrolls the image viewer. /// </summary> /// <param name="scrollStepSize">A scroll step size in pixels.</param> private void Scroll(int scrollStepSize) { VintasoftImage image = ImageViewer.Image; if (image == null) { return; } // determine the scroll direction bool scrollForward = true; _scrollAction = ScrollAction.MoveToNextPage; Vintasoft.Imaging.UI.AnchorType imageEdge = Vintasoft.Imaging.UI.AnchorType.Bottom; // if scroll step size is negative if (scrollStepSize < 0) { // change the scroll direction scrollForward = false; _scrollAction = ScrollAction.MoveToPreviousPage; imageEdge = Invert(imageEdge); } // get new scroll step size according to the focused image resolution float newScrollStepSize = scrollStepSize * (float)image.Resolution.Vertical / 96.0f; // if edge (top/bottom) of focused image is visible if (GetIsImageEdgeVisible(image, imageEdge)) { // if focused image is first image in image viewer // and viewer must be scrolled backward if (ImageViewer.FocusedIndex == 0 && !scrollForward) { return; } // if focused image is last in image viewer // and viewer must be scrolled forward if (ImageViewer.FocusedIndex >= ImageViewer.Images.Count - 1 && scrollForward) { return; } _isPageChanging = true; int newFocusedIndex = ImageViewer.FocusedIndex; if (scrollForward) { newFocusedIndex++; } else { newFocusedIndex--; } // if image viewer is in multipage mode if (ImageViewer.IsMultipageDisplayMode) { // change focused image ChangeFocusedImage(newFocusedIndex); _isPageChanging = false; } // if image viewer is in single page mode else { ImageViewer.ImageLoading += new EventHandler <ImageLoadingEventArgs>(ImageViewer_ImageLoading); // save information about previous focused image _previouslyFocusedImageAutoScrollPositionX = ImageViewer.ViewerState.AutoScrollPosition.X; _previouslyFocusedImageWidth = ImageViewer.Image.Width; // change focused index ChangeFocusedImage(newFocusedIndex); } } // get the center point of previous focused image PointF previousFocusedImageCenterPoint = GetCenterPoint(ImageViewer.Image); // get the scroll point of new focused image PointF newFocusedImageScrollPoint; switch (ImageViewer.ImageRotationAngle) { case 90: newFocusedImageScrollPoint = new PointF( previousFocusedImageCenterPoint.X + newScrollStepSize, previousFocusedImageCenterPoint.Y); break; case 180: newFocusedImageScrollPoint = new PointF( previousFocusedImageCenterPoint.X, previousFocusedImageCenterPoint.Y - newScrollStepSize); break; case 270: newFocusedImageScrollPoint = new PointF( previousFocusedImageCenterPoint.X - newScrollStepSize, previousFocusedImageCenterPoint.Y); break; default: newFocusedImageScrollPoint = new PointF( previousFocusedImageCenterPoint.X, previousFocusedImageCenterPoint.Y + newScrollStepSize); break; } // scroll to the scroll point on new focused image ImageViewer.ScrollToPoint(newFocusedImageScrollPoint, Vintasoft.Imaging.UI.AnchorType.Bottom | Vintasoft.Imaging.UI.AnchorType.Left | Vintasoft.Imaging.UI.AnchorType.Right | Vintasoft.Imaging.UI.AnchorType.Top); _scrollAction = ScrollAction.None; SetFocusToVisibleImage(); }
/// <summary> /// On manipulation delta /// </summary> private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) { this.ScrollAction = this.Orientation == Orientation.Vertical ? (e.Delta.Translation.Y > 0 ? ScrollAction.Down : ScrollAction.Up) : (e.Delta.Translation.X > 0 ? ScrollAction.Right : ScrollAction.Left); // get translation var translation = e.Delta.Translation; // update position this.internalSlider.Value += this.Orientation == Orientation.Vertical ? translation.Y / 2 : translation.X / 2; }
/// <summary> /// /// </summary> /// <param name="scrollTestStep"></param> public ScrollEDA(TestStep scrollTestStep) { _scrollAction = scrollTestStep.WebAction.Action as ScrollAction; ComArgs.SigTestStep = scrollTestStep; }