Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new VisualTreeWalkerTimer with the given <see cref="IVisualTreeWalker"/> as walker that will being used for scanning.
        /// The milliSeconds parameter will be used to determine the frequency of the scanning.
        /// </summary>
        /// <param name="visualTreeWalker">The <see cref="IVisualTreeWalker"/> that will be used for scanning.</param>
        /// <param name="milliSeconds">The amount of milliseconds between scans.</param>
        public VisualTreeWalkerTimer(IVisualTreeWalker visualTreeWalker, int milliSeconds)
        {
            if (milliSeconds <= 0)
            {
                throw new ArgumentException("Parameter milliSeconds must be strictly positive.", nameof(milliSeconds));
            }

            this.visualTreeWalker = visualTreeWalker ?? throw new ArgumentNullException(nameof(visualTreeWalker));

            timer          = new DispatcherTimer();
            timer.Tick    += Timer_Tick;
            timer.Interval = TimeSpan.FromMilliseconds(milliSeconds);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new VisualTreeWalkerTimer with the given <see cref="IVisualTreeWalker"/> as walker that will being used for scanning.
 /// A scan will occur every 5 seconds.
 /// </summary>
 /// <param name="visualTreeWalker">The <see cref="IVisualTreeWalker"/> that will be used for scanning.</param>
 public VisualTreeWalkerTimer(IVisualTreeWalker visualTreeWalker) : this(visualTreeWalker, 5000)
 {
 }