public bool ScrollBy(double delta, bool animated)
 {
     //System.Diagnostics.Debug.WriteLine(P42.Utils.ReflectionExtensions.CallerMemberName() + "(" + delta + ", " + animated + ")");
     if (_scrollViewer != null)
     {
         return(_scrollViewer.ChangeView(null, _scrollViewer.VerticalOffset + delta, null, !animated));
     }
     return(false);
 }
        /// <summary>
        /// Scroll a ScrollViewer horizontally by a given offset.
        /// </summary>
        /// <param name="viewer">The ScrollViewer.</param>
        /// <param name="offset">The horizontal offset to scroll.</param>
        private static void ScrollByHorizontalOffset(ScrollViewer viewer, double offset)
        {
            Debug.Assert(viewer != null, "viewer should not be null!");

            offset += viewer.HorizontalOffset;
            offset = Math.Max(Math.Min(offset, viewer.ExtentWidth), 0);
            viewer.ChangeView(offset, null, null);
        }
        /// <summary>
        /// Scroll a ScrollViewer vertically by a given offset.
        /// </summary>
        /// <param name="viewer">The ScrollViewer.</param>
        /// <param name="offset">The vertical offset to scroll.</param>
        private static void ScrollByVerticalOffset(ScrollViewer viewer, double offset)
        {
            Debug.Assert(viewer != null, "viewer should not be null!");

            offset += viewer.VerticalOffset;
            offset = Math.Max(Math.Min(offset, viewer.ExtentHeight), 0);
            viewer.ChangeView(null, offset, null);
        }
Exemple #4
0
        private void UpdateHeaderPosition(object sender, ScrollViewerViewChangedEventArgs e)
        {
            var headerBackgroundOffset = _mainScrollViewer.VerticalOffset - (_mainScrollViewer.VerticalOffset / 1.5);
            var headerForegroundOffset = _mainScrollViewer.VerticalOffset - (_mainScrollViewer.VerticalOffset / 2);

            if (_mainScrollViewer.VerticalOffset < _screenHeight)
            {
                if (headerBackgroundOffset < _mainScrollViewer.VerticalOffset)
                {
                    _headerBackground.ChangeView(0, headerBackgroundOffset, 1, DisableAnimation);
                    _headerForeground.ChangeView(0, headerForegroundOffset, 1, DisableAnimation);
                }
                else
                {
                    _headerBackground.ChangeView(0, 0, 1, DisableAnimation);
                    _headerForeground.ChangeView(0, 0, 1, DisableAnimation);
                }
            }
        }
        public static void ScrollToProportion(ScrollViewer scrollViewer, double scrollViewerOffsetProportion)
        {
            // Update the Horizontal and Vertical offset
            if (scrollViewer == null)
            {
                return;
            }

            var scrollViewerHorizontalOffset = scrollViewerOffsetProportion * scrollViewer.ScrollableWidth;
            var scrollViewerVerticalOffset = scrollViewerOffsetProportion * scrollViewer.ScrollableHeight;

            scrollViewer.ChangeView(scrollViewerHorizontalOffset, scrollViewerVerticalOffset, null);
        }
Exemple #6
0
            protected override void OnApplyTemplate()
            {
                Debug.Assert((m_scrollLeft == null && m_scrollRight == null) || (m_scrollLeft != null && m_scrollRight != null));
                if (m_textContainer != null)
                {
                    // UNO TODO
                    // m_textContainer.LayoutUpdated -= m_textContainerLayoutChangedToken;
                }
                m_textContainer = (ScrollViewer)(GetTemplateChild("TextContainer"));
                if (m_textContainer != null)
                {
                    m_textContainer.SizeChanged += TextContainerSizeChanged;
                    // We want to know when the size of the container changes so
                    // we can rescale the textbox
                    m_textContainer.LayoutUpdated += OnTextContainerLayoutUpdated;

                    m_textContainer.ChangeView(m_textContainer.ExtentWidth - m_textContainer.ViewportWidth, null, null);
                    m_scrollLeft  = (HyperlinkButton)(GetTemplateChild("ScrollLeft"));
                    m_scrollRight = (HyperlinkButton)(GetTemplateChild("ScrollRight"));
                    var borderContainer = (UIElement)(GetTemplateChild("Border"));
                    if (m_scrollLeft != null && m_scrollRight != null)
                    {
                        m_scrollLeft.Click             += OnScrollClick;
                        m_scrollRight.Click            += OnScrollClick;
                        borderContainer.PointerEntered += OnPointerEntered;
                        borderContainer.PointerExited  += OnPointerExited;
                    }
                    m_textBlock = (TextBlock)(m_textContainer.FindName("NormalOutput"));
                    if (m_textBlock != null)
                    {
                        m_textBlock.Visibility = Visibility.Visible;
                    }
                }
                UpdateAllState();
                VisualStateManager.GoToState(this, s_UnfocusedState, false);
            }
Exemple #7
0
        private static void ScrollPageHorizontal(ScrollViewer scrollViewer, ScrollDirection direction)
        {
            if (scrollViewer == null || direction == ScrollDirection.None)
            {
                return;
            }

            double actualWidth = scrollViewer.ActualWidth;
            double currentOffset = scrollViewer.HorizontalOffset;
            double newWidth = 0;

            if (direction == ScrollDirection.Left)
            {
                newWidth = currentOffset - actualWidth;
            }
            else if (direction == ScrollDirection.Right)
            {
                newWidth = currentOffset + actualWidth;
            }

            if (newWidth > scrollViewer.ExtentWidth)
            {
                newWidth = currentOffset;
            }

            if (newWidth < 0)
            {
                newWidth = 0;
            }

            scrollViewer.ChangeView(newWidth, null, null);
        }
Exemple #8
0
        private static void ScrollPageVertical(ScrollViewer scrollViewer, ScrollDirection direction)
        {
            if (scrollViewer == null || direction == ScrollDirection.None)
            {
                return;
            }

            double actualHeight = scrollViewer.ActualHeight;
            double currentOffset = scrollViewer.VerticalOffset;
            double newHeight = 0;

            if (direction == ScrollDirection.Up)
            {
                newHeight = currentOffset - actualHeight;
            }
            else if (direction == ScrollDirection.Down)
            {
                newHeight = currentOffset + actualHeight;
            }

            if (newHeight > scrollViewer.ExtentHeight)
            {
                newHeight = currentOffset;
            }

            if (newHeight < 0)
            {
                newHeight = 0;
            }

            scrollViewer.ChangeView(null, newHeight, null);
        }
Exemple #9
0
            void UpdateTextState()
            {
                if ((m_textContainer == null) || (m_textBlock == null))
                {
                    return;
                }

                var    containerSize = m_textContainer.ActualWidth;
                string oldText       = m_textBlock.Text;
                string newText       = Utils.LRO + DisplayValue + Utils.PDF;

                // Initiate the scaling operation
                // UpdateLayout will keep calling us until we make it through the below 2 if-statements
                if (!m_isScalingText || oldText != newText)
                {
                    m_textBlock.Text = newText;

                    m_isScalingText     = true;
                    m_haveCalculatedMax = false;
                    m_textBlock.InvalidateArrange();
                    return;
                }
                if (containerSize > 0)
                {
                    double widthDiff      = Math.Abs(m_textBlock.ActualWidth - containerSize);
                    double fontSizeChange = INCREMENTOFFSET;

                    if (widthDiff > WIDTHCUTOFF)
                    {
                        fontSizeChange = Math.Min(Math.Max(Math.Floor(WIDTHTOFONTSCALAR * widthDiff) - WIDTHTOFONTOFFSET, INCREMENTOFFSET), MAXFONTINCREMENT);
                    }
                    if (m_textBlock.ActualWidth < containerSize && Math.Abs(m_textBlock.FontSize - MaxFontSize) > FONTTOLERANCE && !m_haveCalculatedMax)
                    {
                        ModifyFontAndMargin(m_textBlock, fontSizeChange);
                        m_textBlock.InvalidateArrange();
                        return;
                    }
                    if (fontSizeChange < 5)
                    {
                        m_haveCalculatedMax = true;
                    }
                    if (m_textBlock.ActualWidth >= containerSize && Math.Abs(m_textBlock.FontSize - MinFontSize) > FONTTOLERANCE)
                    {
                        ModifyFontAndMargin(m_textBlock, -1 * fontSizeChange);
                        m_textBlock.InvalidateArrange();
                        return;
                    }
                    Debug.Assert(m_textBlock.FontSize >= MinFontSize && m_textBlock.FontSize <= MaxFontSize);
                    m_isScalingText = false;
                    if (IsOperatorCommand)
                    {
                        m_textContainer.ChangeView(0.0, null, null);
                    }
                    else
                    {
                        m_textContainer.ChangeView(m_textContainer.ExtentWidth - m_textContainer.ViewportWidth, null, null);
                    }

                    if (m_scrollLeft != null && m_scrollRight != null)
                    {
                        if (m_textBlock.ActualWidth < containerSize)
                        {
                            ShowHideScrollButtons(Visibility.Collapsed, Visibility.Collapsed);
                        }
                        else
                        {
                            if (IsOperatorCommand)
                            {
                                ShowHideScrollButtons(Visibility.Collapsed, Visibility.Visible);
                            }
                            else
                            {
                                ShowHideScrollButtons(Visibility.Visible, Visibility.Collapsed);
                            }
                        }
                    }
                    m_textBlock.InvalidateArrange();
                }
            }
 private async void FloatTab_Holding(object sender, HoldingRoutedEventArgs e)
 {
     _scrollViewer = listView.GetScrollViewer();
     bool succeed = _scrollViewer.ChangeView(null, 0, null);
     await Task.Yield();
 }
 private async void listView_Loaded(object sender, RoutedEventArgs e)
 {
     
     _scrollViewer = listView.GetScrollViewer();
     TimeSpan period = TimeSpan.FromMilliseconds(1000);
     Windows.System.Threading.ThreadPoolTimer.CreateTimer(async (source) => {
         await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() =>
         {
             _scrollViewer.ChangeView(null, App._scrollViewerVerticalOffset, null, true);
         }));
     }, period);
     await TLVm.RefreshNotification();
 }