Esempio n. 1
0
        private void ShowLoadingExperience()
        {
            _hasShownLoadingScreen = true;
            if (_progressBar != null)
            {
                /*var binding = new Binding("IsLoading");
                 * binding.Source = GlobalLoading.Instance;
                 * binding.Converter = new InvertConverter();
                 * _progressBar.SetBinding(ProgressBar.IsIndeterminateProperty, binding);*/
                _progressBar.IsIndeterminate = true;
            }
            if (_loadingGrid != null)
            {
                // Not sure what this nice phone-similar effect costs yet...
                TransformYAnimator ta = null;
                TransformYAnimator.EnsureAnimator(_loadingGrid, ref ta);
                if (ta != null)
                {
                    ta.GoTo(50, new Duration(TimeSpan.Zero));
                    ta.GoTo(0, TransitionDuration, new QuarticEase());
                }

                MyOpacityAnimator oa = null;
                MyOpacityAnimator.EnsureAnimator(_loadingGrid, ref oa);
                if (oa != null)
                {
                    oa.GoTo(1, TransitionDuration);
                }
                else
                {
                    _loadingGrid.Opacity = 1;
                }
            }
        }
Esempio n. 2
0
        public override void OnApplyTemplate()
        {
            if (_ya != null)
            {
                _ya = null;
            }

            if (_pivotItem == null)
            {
                DependencyObject d = Parent;
                while (d != null && !(d is PivotItem))
                {
                    d = VisualTreeHelper.GetParent(d);
                }
                _pivotItem = d as PivotItem;
            }

            if (_pivotItem != null && _pivot == null)
            {
                DependencyObject d = _pivotItem;
                while (d != null && !(d is Pivot))
                {
                    d = VisualTreeHelper.GetParent(d);
                }
                _pivot = d as Pivot;
                if (_pivot != null)
                {
                    _pivot.UnloadingPivotItem += OnUnloadingPivotItem;
                    //_pivot.SelectionChanged += OnPivotSelectionChanged;
                }
            }

            base.OnApplyTemplate();

            _image = GetTemplateChild("_image") as Image;
            _grid  = GetTemplateChild("_grid") as Grid;

            TransformYAnimator.EnsureAnimator(_grid, ref _ya);
            Debug.Assert(_ya != null);

            if (_image != null && ImageSource != null)
            {
                UpdateImageSource();
            }

            UpdatePosition(false);
        }
Esempio n. 3
0
        public override void OnApplyTemplate()
        {
            if (_scrollViewer != null && IsPullToRefreshEnabled)
            {
                _scrollViewer.ManipulationStarted -= OnManipulationStarted;
            }
            if (_top != null)
            {
                _top.MouseLeftButtonDown -= OnJumpToTop;
            }
            if (_bottom != null)
            {
                _bottom.MouseLeftButtonDown -= OnJumpToBottom;
            }

            _ta = null;
            base.OnApplyTemplate();

            if (IsPullToRefreshEnabled)
            {
                SizeChanged += OnSizeChanged;
            }

            _scrollViewer = MoreVisualTreeExtensions.FindFirstChildOfType <ScrollViewer>(this);
            if (null == _scrollViewer)
            {
                return;
                // Must be at design time.
                //throw new NotSupportedException("Control Template must include a ScrollViewer.");
            }

            Dispatcher.BeginInvoke(() =>
            {
                _top    = VisualTreeExtensions.GetVisualDescendants(_scrollViewer).OfType <Rectangle>().Where(b => b.Name == TopJumpName).FirstOrDefault();
                _bottom = VisualTreeExtensions.GetVisualDescendants(_scrollViewer).OfType <Rectangle>().Where(b => b.Name == BottomJumpName).FirstOrDefault();

                if (_top != null)
                {
                    _top.MouseLeftButtonUp += OnJumpToTop;
                }
                if (_bottom != null)
                {
                    _bottom.MouseLeftButtonUp += OnJumpToBottom;
                }
            });

            _header = GetTemplateChild("Header") as ContentPresenter;
            if (_header != null)
            {
                TransformYAnimator.EnsureAnimator(_header, ref _ta);
            }

            if (IsPullToRefreshEnabled)
            {
                _scrollViewer.ManipulationStarted += OnManipulationStarted;
            }

            Dispatcher.BeginInvoke(() =>
            {
                int i         = 0;
                UIElement uie = Parent as UIElement;
                while (i < 8 && uie != null && _piv == null)
                {
                    uie  = VisualTreeHelper.GetParent(uie) as UIElement;
                    _piv = uie as LoadingPivotItem;
                }

                var implroot = VisualTreeHelper.GetChild(_scrollViewer, 0) as FrameworkElement;
                if (implroot != null)
                {
                    VisualStateGroup group = FindVisualState(implroot, "ScrollStates");
                    if (group != null)
                    {
                        group.CurrentStateChanging += OnScrollingStateChanging;
                        // should probably disconnect too
                    }
                }

                this.InvokeOnLayoutUpdated(Bump);
            });
        }