Example #1
0
        /// <summary>
        /// IsBusyProperty property changed handler.
        /// </summary>
        /// <param name="e">Event arguments.</param>
        protected virtual void OnIsBusyChanged(DependencyPropertyChangedEventArgs e)
        {
            if (IsBusy)
            {
                if (DisplayAfter.Equals(TimeSpan.Zero))
                {
                    // Go visible now
                    IsContentVisible = true;
                }
                else
                {
                    // Set a timer to go visible
                    _displayAfterTimer.Interval = DisplayAfter;
                    _displayAfterTimer.Start();
                }
            }
            else
            {
                // No longer visible
                _displayAfterTimer.Stop();
                IsContentVisible = false;

                if (this.FocusAfterBusy != null)
                {
                    this.FocusAfterBusy.Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(() =>
                    {
                        this.FocusAfterBusy.Focus();
                    }
                                                                                                    ));
                }
            }

            ChangeVisualState(true);
        }
Example #2
0
        /// <summary>
        /// IsBusyProperty property changed handler.
        /// </summary>
        /// <param name="e">Event arguments.</param>
        protected virtual void OnIsBusyChanged(DependencyPropertyChangedEventArgs e)
        {
            if (IsBusy)
            {
                if (DisplayAfter.Equals(TimeSpan.Zero))
                {
                    // Go visible now
                    IsContentVisible = true;
                }
                else
                {
                    // Set a timer to go visible
                    _displayAfterTimer.Interval = DisplayAfter;
                    _displayAfterTimer.Start();
                }
            }
            else
            {
                // No longer visible
                _displayAfterTimer.Stop();
                IsContentVisible = false;
            }

            ChangeVisualState(true);
        }
 private void IsActiveChanged()
 {
     if (this.IsActive)
     {
         VisualStateManager.GoToState(this, "Active", true);
         if (!DisplayAfter.Equals(TimeSpan.Zero))
         {
             activeTimer.Change(this.DisplayAfter, TimeSpan.FromMilliseconds(-1));
         }
         else
         {
             ActiveDelayCallback(null);
         }
     }
     else
     {
         VisualStateManager.GoToState(this, "Inactive", true);
         if (IsActivityVisible)
         {
             TimeSpan duration = DateTime.Now - displayStart;
             if (MinDisplayTime > duration)
             {
                 inactiveTimer.Change(this.MinDisplayTime - duration, TimeSpan.FromMilliseconds(-1));
             }
             else
             {
                 InactiveDelayCallback(null);
             }
         }
     }
 }
Example #4
0
        /// <summary>
        /// IsBusyProperty property changed handler.
        /// </summary>
        /// <param name="e"></param>
        private void OnIsBusyChanged(AvaloniaPropertyChangedEventArgs e)
        {
            if (IsBusy)
            {
                if (DisplayAfter.Equals(TimeSpan.Zero))
                {
                    // Go visible now
                    IsContentVisible = true;
                }
                else
                {
                    // Set a timer to go visible
                    _displayAfterTimer.Interval = DisplayAfter;
                    _displayAfterTimer.Start();
                }
            }
            else
            {
                // No longer visible
                _displayAfterTimer.Stop();
                IsContentVisible = false;

                if (this.FocusAfterBusy != null)
                {
                    //this.FocusAfterBusy.Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(() =>
                    //{
                    //    this.FocusAfterBusy.Focus();
                    //}
                    //));
                    this.FocusAfterBusy.Focus();
                }
            }
        }
Example #5
0
        private void SetIsBusy(bool isBusy)
        {
            if (isBusy)
            {
                if (DisplayAfter.Equals(TimeSpan.Zero))
                {
                    this.Visibility = Visibility.Visible;
                }
                else
                {
                    this.displayAfterTimer.Interval = DisplayAfter;
                    this.displayAfterTimer.Start();
                }
            }
            else
            {
                this.displayAfterTimer.Stop();
                this.Visibility = Visibility.Collapsed;

                if (FocusAfterBusy != null)
                {
                    FocusHelper.Focus(FocusAfterBusy, this.Parent);
                }
            }
        }
Example #6
0
 /// <summary>
 /// IsBusyProperty 属性更改处理程序。
 /// </summary>
 /// <param name="e">事件参数。</param>
 protected virtual void OnIsBusyChanged(DependencyPropertyChangedEventArgs e)
 {
     if (IsBusy)
     {
         if (DisplayAfter.Equals(TimeSpan.Zero))
         {
             // 立即转为可见
             IsContentVisible = true;
         }
         else
         {
             // 设置定时器以转为可见
             _displayAfterTimer.Interval = DisplayAfter;
             _displayAfterTimer.Start();
         }
     }
     else
     {
         // 不再可见
         _displayAfterTimer.Stop();
         IsContentVisible = false;
     }
     ChangeVisualState(true);
 }