Exemplo n.º 1
0
        private void OnceSpecializedContentIsReady()
        {
            Debug.WriteLine("OnceSpecializedContentIsReady!");
            if (_dataStatusElement != null && _dataStatusElement.LoadStatus == LoadStatus.Failed)
            {
                Debug.WriteLine("FAILED that is...");
                LoadingText = "FAILED!!!!!!";

                bool mayHaveHadDataAlready = false;
                ISendLoadComplete islc     = _dataStatusElement as ISendLoadComplete;
                if (islc != null)
                {
                    if (islc.IsLoadComplete)
                    {
                        mayHaveHadDataAlready = true;
                        // There "was" data and now there's been an error...
                    }
                }

                if (!mayHaveHadDataAlready)
                {
                    RestoreLoadingGrid();
                }

                // NOTE: Never will call FinallyShowContent.
                return;
            }

            DelayedDispatcherTimer.BeginInvoke(AdditionalLoadTime, FinallyShowContent);
        }
Exemplo n.º 2
0
        private void CheckForUnderlyingReadyState()
        {
//#if DEBUG_LOADING_PIVOT_ITEM
            //Debug.WriteLine("LPI: Still not ready.");
//#endif
            if (DateTime.Now > _okToShowAfter)
            {
                // Check the children here for the interface.

                Dispatcher.BeginInvoke(TryTransitionToContent);
            }
            else
            {
                DelayedDispatcherTimer.BeginInvoke(AdditionalLoadTime, TryTransitionToContent);
            }
        }
Exemplo n.º 3
0
//        private void WaitForSpecializedContent()
//        {
////#if DEBUG_LOADING_PIVOT_ITEM
//            //Debug.WriteLine("     ... but the data isn't ready yet.");
////#endif
//            if (!_contentPresenterUnloaded)
//            {
//                if (_advancedWaitingElement.IsLoadComplete)
//                {
//                    DelayedDispatcherTimer.BeginInvoke(AdditionalLoadTime, FinallyShowContent);
//                }
//                else
//                {
//                    DelayedDispatcherTimer.BeginInvoke(SmartLoadingDelayingTime, WaitForSpecializedContent);
//                }
//            }
//        }

        private void TryTransitionToContent()
        {
            if (_contentPresenterUnloaded)
            {
                return;
            }

//#if DEBUG_LOADING_PIVOT_ITEM
            //Debug.WriteLine("LPI: DataContext of {0} is set to {1}", Header.ToString(), DataContext.ToString());
//#endif

            // Visuals first to grab any control.
            var descendantsOnce = _contentPresenter.GetVisualDescendants().ToList();

            _pauseAndResumeChild = descendantsOnce.OfType <ISupportPauseResume>().FirstOrDefault();
            //_advancedWaitingElement = descendantsOnce.OfType<ISendLoadComplete>().FirstOrDefault();
            _dataStatusElement = descendantsOnce.OfType <ISendLoadStatus>().FirstOrDefault();

            // If the bindings never get applied due to visibility converters.
            //var uie = _advancedWaitingElement as UIElement;
            var uie = _dataStatusElement as UIElement;

            if (uie != null && uie.Visibility == Visibility.Collapsed)
            {
                _dataStatusElement = null;
                //_advancedWaitingElement = null;
            }

            if (_dataStatusElement /*_advancedWaitingElement */ == null)
            {
                // Pause and resume is not support for these two.
                var fe =
                    descendantsOnce.OfType <ItemsControl>().Where(it => it.ItemsSource is ISendLoadStatus).
                    FirstOrDefault();
                if (fe != null)
                {
                    _dataStatusElement = (ISendLoadStatus)fe.ItemsSource;
                    //_advancedWaitingElement = (ISendLoadComplete) fe.ItemsSource;
                }

                if (_dataStatusElement /*_advancedWaitingElement */ == null)
                {
                    var de =
                        descendantsOnce.OfType <FrameworkElement>().Where(ff => ff.DataContext is ISendLoadStatus)
                        .FirstOrDefault();
                    if (de != null)
                    {
                        _dataStatusElement = de.DataContext as ISendLoadStatus;
//                        _advancedWaitingElement = de.DataContext as ISendLoadComplete;
                    }
                }
            }

            if (_dataStatusElement /*_advancedWaitingElement */ != null)
            {
#if DEBUG_LOADING_PIVOT_ITEM
                Debug.WriteLine("LPI: Custom item base {0} supports load notifications. Excellent.", _dataStatusElement.GetType().ToString());
#endif
//                if (_advancedWaitingElement.IsLoadComplete)
                if (_dataStatusElement.LoadStatus == LoadStatus.Loaded || _dataStatusElement.LoadStatus == LoadStatus.Failed)
                {
                    OnceSpecializedContentIsReady();
                }
                else
                {
                    _dataStatusElement.LoadStatusChanged += OnAdvancedWaitingElementLoadComplete;
                    //_advancedWaitingElement.LoadComplete += OnAdvancedWaitingElementLoadComplete;
                    //return;
                }

                // don't let it appear by accident...
                return;
            }

            Debug.Assert(!_contentPresenterUnloaded);

            DelayedDispatcherTimer.BeginInvoke(AdditionalLoadTime, FinallyShowContent);
        }
 private void OnceSpecializedContentIsReady()
 {
     DelayedDispatcherTimer.BeginInvoke(AdditionalLoadTime, FinallyShowContent);
 }