Esempio n. 1
0
 private void StackPanel_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     if (_targetScrollPositionAfterResize >= 0)
     {
         ContentScrollViewer.ChangeView(0, _targetScrollPositionAfterResize, 1);
         _targetScrollPositionAfterResize = -1;
     }
 }
 bool ScrollToPage(int page, bool disableAnimation)
 {
     if (ContentScrollViewer.HorizontalScrollMode != ScrollMode.Disabled)
     {
         return(ContentScrollViewer.ChangeView(ContentColumns.Margin.Left + page * ContentColumns.ColumnWidth + 0.1, null, null, disableAnimation));
     }
     else
     {
         return(ContentScrollViewer.ChangeView(null, ContentColumns.Margin.Top + page * ContentColumns.ColumnHeight + 0.1, null, disableAnimation));
     }
 }
        /// <summary>
        /// Gets the NavigationHelper used to aid in navigation and process lifetime management.
        /// </summary>


        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            Debug.WriteLine("LoadState");

#if WINDOWS_PHONE_APP
            IndexPanel.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            //this.BottomAppBar = PageBottomCommandBar;
            //this.BottomAppBar.Visibility = Visibility.Visible;
            var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
            await statusBar.HideAsync();
#endif
            //Relayout_ContentColumn(ContentRegion.RenderSize);
            if (e.PageState == null)
            {
                var nav = navigationId = NovelPositionIdentifier.Parse((string)e.NavigationParameter);

                if (nav.SeriesId != null && (nav.VolumeNo == -1 || nav.ChapterNo == -1))
                {
                    IsIndexPanelOpen = true;
                }
                else
                {
                    IsIndexPanelOpen = false;
                }

                await viewModel.LoadDataAsync(nav);
            }
            else
            {
                IsIndexPanelOpen = false;
                if (e.PageState.ContainsKey("LoadingBreak"))
                {
                    var nav = navigationId = NovelPositionIdentifier.Parse((string)e.PageState["LoadingBreak"]);
                    await viewModel.LoadDataAsync(nav);
                }
                else
                {
                    var volumeNo  = (int)e.PageState["VolumeNo"];
                    var chapterNo = (int)e.PageState["ChapterNo"];
                    var seriesId  = (int)e.PageState["SeriesId"];
                    var lineNo    = (int)e.PageState["LineNo"];
                    await viewModel.LoadDataAsync(seriesId, volumeNo, chapterNo, lineNo);
                }
#if WINDOWS_APP
                var horizontalOffset = (double)e.PageState["HorizontalOffset"];
                var verticalOffset   = (double)e.PageState["VerticalOffset"];
                ContentScrollViewer.ChangeView(horizontalOffset, verticalOffset, null, true);
#endif
                //SyncIndexSelectedItem();
            }
            ViewModel.NotifyPropertyChanged("IsPinned");
            ViewModel.NotifyPropertyChanged("IsFavored");
        }
        /// <summary>
        /// Gets the NavigationHelper used to aid in navigation and process lifetime management.
        /// </summary>


        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            Debug.WriteLine("LoadState");
            VisualStateManager.GoToState(this, IndexClosedState, false);

#if WINDOWS_PHONE_APP
            //IndexPanel.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            //this.BottomAppBar = PageBottomCommandBar;
            //this.BottomAppBar.Visibility = Visibility.Visible;
            TranslationType = 0;
            LayoutRootFadeinStory.Begin();
            await UpdateSizeOrientationDependentResourcesAsync();
#elif WINDOWS_APP || WINDOWS_UWP
            if (this.Frame.CanGoBack)
            {
                OpenInNewViewButton.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
            else
            {
                OpenInNewViewButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }

            Window.Current.SetTitleBar(TitlePanelBackground);
#endif
            if (this.RequestedTheme != AppGlobal.Settings.BackgroundTheme)
            {
                this.RequestedTheme = AppGlobal.Settings.BackgroundTheme;
            }
            //Relayout_ContentColumn(ContentRegion.RenderSize);
            if (e.PageState != null && e.PageState.Count > 0)
            {
                IsIndexPanelOpen = false;
                if (e.PageState.ContainsKey("LoadingBreak"))
                {
                    navigationId = NovelPositionIdentifier.Parse((string)e.PageState["LoadingBreak"]);
                    await viewModel.LoadDataAsync(navigationId);
                }
                else
                {
                    var fullScreen = (bool)e.PageState["IsFullScreen"];
                    if (fullScreen)
                    {
                        VisualStateManager.GoToState(this, "HideTitleBarState", false);
                        ViewModel.IsFullScreen = true;
                    }
                    else
                    {
                        VisualStateManager.GoToState(this, "ShowTitleBarState", false);
                        ViewModel.IsFullScreen = false;
                    }

                    var volumeNo  = (int)e.PageState["VolumeNo"];
                    var chapterNo = (int)e.PageState["ChapterNo"];
                    var seriesId  = (int)e.PageState["SeriesId"];
                    var lineNo    = (int)e.PageState["LineNo"];
                    await viewModel.LoadDataAsync(seriesId, volumeNo, chapterNo, lineNo);
                }
#if WINDOWS_APP
                var horizontalOffset = (double)e.PageState["HorizontalOffset"];
                var verticalOffset   = (double)e.PageState["VerticalOffset"];
                ContentScrollViewer.ChangeView(horizontalOffset, verticalOffset, null, true);
#endif
                //SyncIndexSelectedItem();
            }
            else
            {
                VisualStateManager.GoToState(this, "ShowTitleBarState", false);
                ViewModel.IsFullScreen = false;

                navigationId = NovelPositionIdentifier.Parse((string)e.NavigationParameter);

                if (navigationId.SeriesId != null && (navigationId.VolumeNo == -1 || navigationId.ChapterNo == -1))
                {
                    IsIndexPanelOpen = true;
                }
                else
                {
                    IsIndexPanelOpen = false;
                }

                await viewModel.LoadDataAsync(navigationId);
            }
            ViewModel.NotifyPropertyChanged("IsPinned");
            SyncPinButtonView();
            ViewModel.NotifyPropertyChanged("IsFavored");
        }