Beispiel #1
0
        private async void Show()
        {
            using (var releaser = await _AnimationGenerateLock.LockAsync())
            {
                if (this.AssociatedObject == null)
                {
                    return;
                }

                Debug.WriteLine($"{_CurrentAnimation?.State}");

                _CurrentAnimation?.Dispose();
                _CurrentAnimation = null;

                if (IsAnimationEnabled)
                {
                    _CurrentAnimation = AssociatedObject.Fade(1.0f, Duration.TotalMilliseconds);

                    _CurrentAnimation?.StartAsync().ConfigureAwait(false);

                    if (IsAutoHideEnabled)
                    {
                        AutoHideSubject.OnNext(0);
                    }

                    Debug.WriteLine($"{nameof(VisiblityFadeChanger)}: 表示アニメーション開始 (自動非表示:{IsAutoHideEnabled})");
                }
                else
                {
                    AssociatedObject.Opacity = 1.0;
                    Debug.WriteLine($"{nameof(VisiblityFadeChanger)}: 表示");
                }
            }
        }
Beispiel #2
0
 public void PreventAutoHide()
 {
     if (IsAutoHideEnabled && IsVisible)
     {
         AutoHideSubject.OnNext(0);
     }
 }
Beispiel #3
0
 void ResetAutoHideThrottling()
 {
     _AutoHideThrottlingDisposer?.Dispose();
     _AutoHideThrottlingDisposer = AutoHideSubject.Throttle(Delay)
                                   .Subscribe(_ =>
     {
         var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             if (IsAutoHideEnabled)
             {
                 Hide();
             }
         });
     });
 }
Beispiel #4
0
        protected override void OnAttached()
        {
            base.OnAttached();

            _CompositeDisposable?.Dispose();
            _CompositeDisposable = new CompositeDisposable();

            var associatedObject = AssociatedObject;

#pragma warning disable IDISP004 // Don't ignore created IDisposable.
            AssociatedObject.ObserveDependencyProperty(FrameworkElement.OpacityProperty)
            .Subscribe(_ =>
            {
                if (associatedObject.Opacity == 0)
                {
                    associatedObject.Visibility = Visibility.Collapsed;
                }
                else
                {
                    associatedObject.Visibility = Visibility.Visible;
                }
            })
            .AddTo(_CompositeDisposable);
#pragma warning restore IDISP004 // Don't ignore created IDisposable.

            _autoHideThrottlingDisposer?.Dispose();
            _autoHideThrottlingDisposer = AutoHideSubject.Throttle(Delay)
                                          .Subscribe(_ =>
            {
                var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    if (IsAutoHideEnabled)
                    {
                        Hide();
                    }
                });
            });


            AssociatedObject.PointerMoved += AssociatedObject_PointerMoved;
        }
Beispiel #5
0
        private void Show()
        {
            if (this.AssociatedObject == null)
            {
                return;
            }

            StopAnimation();

            if (IsAnimationEnabled)
            {
                var ct = CreateAnimationCancellationToken();
                _ = AnimationBuilder.Create().Opacity(1.0).StartAsync(this.AssociatedObject, ct);

                if (IsAutoHideEnabled)
                {
                    AutoHideSubject.OnNext(0);
                }
            }
            else
            {
                AssociatedObject.Opacity = 1.0;
            }
        }