Ejemplo n.º 1
0
        public override void OnNavigatedTo(INavigationParameters parameters)
        {
            if (RefreshCommand.CanExecute(null))
            {
                RefreshCommand.Execute(null);
            }


            Observable.FromEventPattern <WatchHistoryRemovedEventArgs>(
                h => _watchHistoryManager.WatchHistoryRemoved += h,
                h => _watchHistoryManager.WatchHistoryRemoved -= h
                )
            .Subscribe(e =>
            {
                var args        = e.EventArgs;
                var removedItem = Histories.FirstOrDefault(x => x.VideoId == args.VideoId);
                if (removedItem != null)
                {
                    Histories.Remove(removedItem);
                }
            })
            .AddTo(_CompositeDisposable);

            Observable.FromEventPattern(
                h => _watchHistoryManager.WatchHistoryAllRemoved += h,
                h => _watchHistoryManager.WatchHistoryAllRemoved -= h
                )
            .Subscribe(_ =>
            {
                Histories.Clear();
            })
            .AddTo(_CompositeDisposable);

            base.OnNavigatedTo(parameters);
        }
        /// <summary>
        /// Method called at the end of manipulation to clean up everything
        /// </summary>
        private void OnManipulationCompleted()
        {
            CompositionTarget.Rendering          -= CompositionTarget_Rendering;
            _refreshIndicatorTransform.TranslateY = -_refreshIndicatorBorder.ActualHeight;
            if (_contentTransform != null)
            {
                _contentTransform.TranslateY = 0;
            }

            if (_refreshActivated)
            {
                RefreshRequested?.Invoke(this, new EventArgs());
                if (RefreshCommand != null && RefreshCommand.CanExecute(null))
                {
                    RefreshCommand.Execute(null);
                }
            }

            _lastOffset            = 0;
            _pullDistance          = 0;
            _refreshActivated      = false;
            _lastRefreshActivation = default(DateTime);

            PullProgressChanged?.Invoke(this, new RefreshProgressEventArgs {
                PullProgress = 0
            });
        }
Ejemplo n.º 3
0
 private void KeyDownHandler(object sender, KeyEventArgs args)
 {
     if (args.Key == Key.F5 && (RefreshCommand?.CanExecute(null) ?? true))
     {
         RefreshCommand?.Execute(null);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Event handler for when the user has stoped scrolling
        /// </summary>
        private void Scroller_DirectManipulationCompleted(object sender, object e)
        {
            CompositionTarget.Rendering         -= CompositionTarget_Rendering;
            RefreshIndicatorTransform.TranslateY = -RefreshIndicatorBorder.ActualHeight;
            ContentTransform.TranslateY          = 0;

            if (refreshActivated)
            {
                if (RefreshRequested != null)
                {
                    RefreshRequested(this, new EventArgs());
                }
                if (RefreshCommand != null && RefreshCommand.CanExecute(null))
                {
                    RefreshCommand.Execute(null);
                }
            }

            refreshActivated      = false;
            lastRefreshActivation = default(DateTime);

            if (RefreshIndicatorContent == null)
            {
                DefaultIndicatorContent.Text = "↓ 下拉刷新";
            }

            if (PullProgressChanged != null)
            {
                PullProgressChanged(this, new RefreshProgressEventArgs()
                {
                    PullProgress = 0
                });
            }
        }
Ejemplo n.º 5
0
        public void CanRefresh()
        {
            var command = new RefreshCommand(_view);

            command.Execute(null);

            command.CanExecute(null).ShouldBe(true);
            _view.ShouldHaveBeenCalled(v => v.UpdateScreen());
        }
Ejemplo n.º 6
0
        /// <summary>
        ///   Refresh <see cref="Plugins" /> with the latest list of available plugins from the online API repository and NuGet
        ///   repositories. Cached result might be returned if they <paramref name="forceRefresh" /> is set to false.
        /// </summary>
        public Task RefreshPluginsAsync(bool forceRefresh)
        {
            if (RefreshCommand.CanExecute(forceRefresh))
            {
                return(RefreshCommand.ExecuteAsync(forceRefresh));
            }

            return(Task.CompletedTask);
        }
        public override void OnNavigatedTo(INavigationParameters parameters)
        {
            if (RefreshCommand.CanExecute())
            {
                RefreshCommand.Execute();
            }

            base.OnNavigatedTo(parameters);
        }
Ejemplo n.º 8
0
        public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            if (RefreshCommand.CanExecute())
            {
                RefreshCommand.Execute();
            }

            base.OnNavigatedTo(e, viewModelState);
        }
Ejemplo n.º 9
0
 private void RefreshContainer_RefreshRequested(object sender, Microsoft.UI.Xaml.Controls.RefreshRequestedEventArgs args)
 {
     using (var deferral = args.GetDeferral())
     {
         RefreshRequested?.Invoke(this, EventArgs.Empty);
         if (RefreshCommand != null && RefreshCommand.CanExecute(null))
         {
             RefreshCommand.Execute(null);
         }
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Set correct visual state and invoke refresh event and command
        /// </summary>
        private void InvokeRefresh()
        {
            isReadyToRefresh = false;
            VisualStateManager.GoToState(this, VisualStateNormal, true);

            if (RefreshContent != null)
            {
                RefreshContent(this, EventArgs.Empty);
            }

            if (RefreshCommand != null && RefreshCommand.CanExecute(null) == true)
            {
                RefreshCommand.Execute(null);
            }
        }
        /// <summary>
        /// Method called at the end of manipulation to clean up everything
        /// </summary>
        private void OnManipulationCompleted()
        {
            CompositionTarget.Rendering          -= CompositionTarget_Rendering;
            _refreshIndicatorTransform.TranslateY = -_refreshIndicatorBorder.ActualHeight;
            if (_contentTransform != null)
            {
                _contentTransform.TranslateY = 0;

                if (_headerTransform != null)
                {
                    _headerTransform.TranslateY = 0;
                }

                if (_footerTransform != null)
                {
                    _footerTransform.TranslateY = 0;
                }
            }

            if (_refreshActivated)
            {
                RefreshRequested?.Invoke(this, EventArgs.Empty);
                if (RefreshCommand != null && RefreshCommand.CanExecute(null))
                {
                    RefreshCommand.Execute(null);
                }
            }
            else if (_refreshIntentCanceled)
            {
                RefreshIntentCanceled?.Invoke(this, EventArgs.Empty);
                if (RefreshIntentCanceledCommand != null && RefreshIntentCanceledCommand.CanExecute(null))
                {
                    RefreshIntentCanceledCommand.Execute(null);
                }
            }

            _lastOffset              = 0;
            _pullDistance            = 0;
            _refreshActivated        = false;
            _refreshIntentCanceled   = false;
            _lastRefreshActivation   = default(DateTime);
            _isManipulatingWithMouse = false;

            PullProgressChanged?.Invoke(this, new RefreshProgressEventArgs {
                PullProgress = 0
            });
            _pullAndReleaseIndicatorContent.Content = null;
        }
Ejemplo n.º 12
0
        private async void InvokeRefresh()
        {
            IsReadyToRefresh = false;
            VisualStateManager.GoToState(this, "Normal", true);
            if (!isBusy)
            {
                isBusy = true;
                if (RefreshContent != null)
                {
                    RefreshContent(this, EventArgs.Empty);
                }

                if (RefreshCommand != null && RefreshCommand.CanExecute(default(object)))
                {
                    await RefreshCommand.Execute(default(object));
                }
                isBusy = false;
            }
        }
        private async Task DoCancellableRefreshTaskAsync(CancellationToken token)
        {
            try
            {
                if (_pendingRefreshTask != null)
                {
                    await _pendingRefreshTask;
                }
            }
            catch (OperationCanceledException)
            {
            }

            token.ThrowIfCancellationRequested();

            if (RefreshCommand != null && RefreshCommand.CanExecute(token, true))
            {
                await RefreshCommand.ExecuteAsync(token);
            }
        }
Ejemplo n.º 14
0
        private void InvokeRefresh()
        {
            isReadyToRefresh = false;
            VisualStateManager.GoToState(this, VisualStateNormal, true);

            if (RefreshContent != null)
            {
                RefreshContent(this, EventArgs.Empty);
            }

            var paramter = GetCommandParameter(this);

            if (RefreshCommand != null && RefreshCommand.CanExecute(paramter))
            {
                RefreshCommand.Execute(paramter);
            }

            //SettingsStore.AddOrUpdateValue<string>(AppCommonConst.LAST_UPDATE_TIME, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            RefreshTime = "最后更新:" + SettingsStore.GetValueOrDefault <string>(AppCommonConst.LAST_UPDATE_TIME, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
        }
Ejemplo n.º 15
0
 void OnCommandCanExecuteChanged(object sender, EventArgs eventArgs)
 {
     RefreshAllowed = RefreshCommand.CanExecute(null);
 }