123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- namespace HistoryDLL
- {
- public class ScrollViewerUtilities
- {
- #region HorizontalOffset
- /// <summary>
- /// HorizontalOffset Attached Dependency Property
- /// </summary>
- public static DependencyProperty HorizontalOffsetProperty =
- DependencyProperty.RegisterAttached("HorizontalOffset", typeof(double), typeof(ScrollViewerUtilities),
- new FrameworkPropertyMetadata(ScrollViewerUtilitieschange(),
- new PropertyChangedCallback(OnHorizontalOffsetChanged)));
- public static bool UseMotionStop = false;
- private static object ScrollViewerUtilitieschange()
- {
- double result = (double)(int.Parse(System.Windows.Application.Current.Properties["ReturnPos"].ToString()));
- return result;
- }
- /// <summary>
- /// Gets the HorizontalOffset property. This dependency property
- /// indicates ....
- /// </summary>
- public static double GetHorizontalOffset(DependencyObject d)
- {
- return (double)d.GetValue(HorizontalOffsetProperty);
- }
- /// <summary>
- /// Sets the HorizontalOffset property. This dependency property
- /// indicates ....
- /// </summary>
- public static void SetHorizontalOffset(DependencyObject d, double value)
- {
- d.SetValue(HorizontalOffsetProperty, value);
- }
- /// <summary>
- /// Handles changes to the HorizontalOffset property.
- /// </summary>
- private static void OnHorizontalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!UseMotionStop)
- {
- var viewer = (ScrollViewer)d;
- viewer.ScrollToHorizontalOffset((double)e.NewValue);
- }
- }
- #endregion
- #region VerticalOffset
- /// <summary>
- /// VerticalOffset Attached Dependency Property
- /// </summary>
- public static readonly DependencyProperty VerticalOffsetProperty =
- DependencyProperty.RegisterAttached("VerticalOffset", typeof(double), typeof(ScrollViewerUtilities),
- new FrameworkPropertyMetadata((double)0.0,
- new PropertyChangedCallback(OnVerticalOffsetChanged)));
- /// <summary>
- /// Gets the VerticalOffset property. This dependency property
- /// indicates ....
- /// </summary>
- public static double GetVerticalOffset(DependencyObject d)
- {
- return (double)d.GetValue(VerticalOffsetProperty);
- }
- /// <summary>
- /// Sets the VerticalOffset property. This dependency property
- /// indicates ....
- /// </summary>
- public static void SetVerticalOffset(DependencyObject d, double value)
- {
- d.SetValue(VerticalOffsetProperty, value);
- }
- /// <summary>
- /// Handles changes to the VerticalOffset property.
- /// </summary>
- private static void OnVerticalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var viewer = (ScrollViewer)d;
- viewer.ScrollToVerticalOffset((double)e.NewValue);
- }
- #endregion
- }
- }
|