コード例 #1
0
 /// <summary>
 /// Occurs when the control handles a <see cref="ScrollViewer.ScrollChangedEvent"/> routed event.
 /// </summary>
 private static void HandleScrollChanged(DependencyObject dobj, ref ScrollChangedInfo scrollInfo, ref RoutedEventData data)
 {
     if (!MathUtil.IsApproximatelyZero(scrollInfo.ViewportHeightChange))
     {
         ((TextBox)dobj).UpdateScrollViewerSize();
     }
     data.Handled = true;
 }
コード例 #2
0
        /// <summary>
        /// Retrieves an instance of the <see cref="ScrollChangedRoutedEventData"/> class from the global
        /// pool and initializes it for use with a routed event handler.
        /// </summary>
        /// <param name="source">The object that raised the event.</param>
        /// <param name="info">A <see cref="ScrollChangedInfo"/> which describes the change.</param>
        /// <param name="handled">A value indicating whether the event has been handled.</param>
        /// <param name="autorelease">A value indicating whether the data is automatically released
        /// back to the global pool after it has been used by an event handler delegate.</param>
        /// <returns>The <see cref="ScrollChangedRoutedEventData"/> instance that was retrieved.</returns>
        public static ScrollChangedRoutedEventData Retrieve(Object source, ScrollChangedInfo info, Boolean handled = false, Boolean autorelease = true)
        {
            var data = default(ScrollChangedRoutedEventData);

            lock (pool)
                data = pool.Retrieve();

            data.OnRetrieved(pool, source, handled, autorelease);
            data.HorizontalOffset     = info.HorizontalOffset;
            data.HorizontalChange     = info.HorizontalChange;
            data.VerticalOffset       = info.VerticalOffset;
            data.VerticalChange       = info.VerticalChange;
            data.ExtentWidth          = info.ExtentWidth;
            data.ExtentWidthChange    = info.ExtentWidthChange;
            data.ExtentHeight         = info.ExtentHeight;
            data.ExtentHeightChange   = info.ExtentHeightChange;
            data.ViewportWidth        = info.ViewportWidth;
            data.ViewportWidthChange  = info.ViewportWidthChange;
            data.ViewportHeight       = info.ViewportHeight;
            data.ViewportHeightChange = info.ViewportHeightChange;

            return(data);
        }
コード例 #3
0
        /// <summary>
        /// Retrieves an instance of the <see cref="ScrollChangedRoutedEventData"/> class from the global
        /// pool and initializes it for use with a routed event handler.
        /// </summary>
        /// <param name="source">The object that raised the event.</param>
        /// <param name="info">A <see cref="ScrollChangedInfo"/> which describes the change.</param>
        /// <param name="handled">A value indicating whether the event has been handled.</param>
        /// <param name="autorelease">A value indicating whether the data is automatically released
        /// back to the global pool after it has been used by an event handler delegate.</param>
        /// <returns>The <see cref="ScrollChangedRoutedEventData"/> instance that was retrieved.</returns>
        public static ScrollChangedRoutedEventData Retrieve(DependencyObject source, ScrollChangedInfo info, Boolean handled = false, Boolean autorelease = true)
        {
            var data = default(ScrollChangedRoutedEventData);

            lock (pool)
                data = pool.Retrieve();

            data.OnRetrieved(pool, source, handled, autorelease);
            data.HorizontalOffset = info.HorizontalOffset;
            data.HorizontalChange = info.HorizontalChange;
            data.VerticalOffset = info.VerticalOffset;
            data.VerticalChange = info.VerticalChange;
            data.ExtentWidth = info.ExtentWidth;
            data.ExtentWidthChange = info.ExtentWidthChange;
            data.ExtentHeight = info.ExtentHeight;
            data.ExtentHeightChange = info.ExtentHeightChange;
            data.ViewportWidth = info.ViewportWidth;
            data.ViewportWidthChange = info.ViewportWidthChange;
            data.ViewportHeight = info.ViewportHeight;
            data.ViewportHeightChange = info.ViewportHeightChange;

            return data;
        }
コード例 #4
0
        /// <inheritdoc/>
        protected override void PositionOverride()
        {
            if (PART_ContentPresenter != null)
                PART_ContentPresenter.PositionChildren();

            var newHorizontalOffset = HorizontalOffset;
            var newVerticalOffset = VerticalOffset;
            var newExtentWidth = ExtentWidth;
            var newExtentHeight = ExtentHeight;
            var newViewportWidth = ViewportWidth;
            var newViewportHeight = ViewportHeight;

            var scrollChanged =
                !MathUtil.AreApproximatelyEqual(oldHorizontalOffset, newHorizontalOffset) ||
                !MathUtil.AreApproximatelyEqual(oldVerticalOffset, newVerticalOffset) ||
                !MathUtil.AreApproximatelyEqual(oldExtentWidth, newExtentWidth) ||
                !MathUtil.AreApproximatelyEqual(oldExtentHeight, newExtentHeight) ||
                !MathUtil.AreApproximatelyEqual(oldViewportWidth, newViewportWidth) ||
                !MathUtil.AreApproximatelyEqual(oldViewportHeight, newViewportHeight);

            if (scrollChanged)
            {
                var evtDelegate = EventManager.GetInvocationDelegate<UpfScrollChangedEventHandler>(ScrollChangedEvent);
                var evtData = new RoutedEventData(this);

                var scrollInfo = new ScrollChangedInfo(
                    newHorizontalOffset, newHorizontalOffset - oldHorizontalOffset,
                    newVerticalOffset, newVerticalOffset - oldVerticalOffset,
                    newExtentWidth, newExtentWidth - oldExtentWidth,
                    newExtentHeight, newExtentHeight - oldExtentHeight,
                    newViewportWidth, newViewportWidth - oldViewportWidth,
                    newViewportHeight, newViewportHeight - oldViewportHeight);

                oldHorizontalOffset = newHorizontalOffset;
                oldVerticalOffset = newVerticalOffset;
                oldExtentWidth = newExtentWidth;
                oldExtentHeight = newExtentHeight;
                oldViewportWidth = newViewportWidth;
                oldViewportHeight = newViewportHeight;

                evtDelegate(this, ref scrollInfo, ref evtData);
            }

            base.PositionOverride();
        }