private async void MakeCommandBarVisibleForAWhile()
        {
            int visibleTime = (int)((double)SettingStorage.GetValue("CommandBarShowTimespan") * 1000.0);

            if (visibleTime <= 0)
            {
                return;
            }
            CommandBar1.Visibility = Visibility.Visible;

            //CommandBar1.Foreground = new SolidColorBrush(Application.Current.RequestedTheme == ApplicationTheme.Dark ? RequestedThemeProperty.: Colors.Black);//ad-hoc fix me
            CommandBar1.Foreground = (Brush)App.Current.Resources.ThemeDictionaries["AppBarItemForegroundThemeBrush"];
            MakeCommandBarVisibleForAWhile_DelayCount++;
            await Task.Delay(visibleTime);

            MakeCommandBarVisibleForAWhile_DelayCount--;
            if (MakeCommandBarVisibleForAWhile_DelayCount == 0)
            {
                if (CommandBar1.FocusState != FocusState.Unfocused || CommandBar1.IsOpen)
                {
                    MakeCommandBarVisibleForAWhile();
                }
                else
                {
                    CommandBar1.Foreground = new SolidColorBrush(Colors.Transparent);
                }
            }
        }
Exemplo n.º 2
0
        private static async Task SaveDataRoamingAsync(BookInfo[] items)
        {
            if (!(bool)SettingStorage.GetValue("SyncBookmarks"))
            {
                return;
            }

            await fileRoamingSemaphore.WaitAsync();

            try
            {
                var f = await DataFolderRoaming.CreateFileAsync(fileName, Windows.Storage.CreationCollisionOption.ReplaceExisting);

                using (var s = (await f.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite)).AsStream())
                {
                    var serializer = new System.Xml.Serialization.XmlSerializer(typeof(BookInfo[]));
                    serializer.Serialize(s, items);
                }
            }
            catch
            {
                // ignored
            }
            finally
            {
                fileRoamingSemaphore.Release();
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter == null)
            {
            }
            else if (e.Parameter is Windows.ApplicationModel.Activation.IActivatedEventArgs)
            {
                var args = (Windows.ApplicationModel.Activation.IActivatedEventArgs)e.Parameter;
                if (args.Kind == Windows.ApplicationModel.Activation.ActivationKind.File)
                {
                    foreach (var item in ((Windows.ApplicationModel.Activation.FileActivatedEventArgs)args).Files)
                    {
                        if (item is Windows.Storage.IStorageFile)
                        {
                            Open((Windows.Storage.IStorageFile)item);
                            break;
                        }
                    }
                }
            }
            else if (e.Parameter is Books.IBookFixed)
            {
                Open((Books.IBookFixed)e.Parameter);
            }
            else if (e.Parameter is Windows.Storage.IStorageFile)
            {
                Open((Windows.Storage.IStorageFile)e.Parameter);
            }
            else if (e.Parameter is BookAndParentNavigationParamater)
            {
                var param = (BookAndParentNavigationParamater)e.Parameter;
                Open(param.BookViewerModel);
                SetBookShelfModel(param.BookShelfModel);
                if (Binding != null)
                {
                    Binding.Title = param.Title;
                }
            }

            var currentView = Windows.UI.Core.SystemNavigationManager.GetForCurrentView();

            currentView.AppViewBackButtonVisibility = Frame?.CanGoBack == true ? Windows.UI.Core.AppViewBackButtonVisibility.Visible : Windows.UI.Core.AppViewBackButtonVisibility.Collapsed;
            currentView.BackRequested += CurrentView_BackRequested;

            if ((bool)SettingStorage.GetValue("DefaultFullScreen"))
            {
                var v = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
                v.TryEnterFullScreenMode();
            }
        }
        private async void MakeStackPanelZoomVisibleForAWhile()
        {
            int visibleTime = (int)((double)SettingStorage.GetValue("ZoomButtonShowTimespan") * 1000.0);

            if (visibleTime <= 0)
            {
                return;
            }
            StackPanelZoom.Visibility = Visibility.Visible;
            MakeStackPanelZoomVisibleForAWhile_DelayCount++;
            await Task.Delay(visibleTime);

            MakeStackPanelZoomVisibleForAWhile_DelayCount--;
            if (MakeStackPanelZoomVisibleForAWhile_DelayCount == 0)
            {
                StackPanelZoom.Visibility = Visibility.Collapsed;
            }
        }
        public BookFixed2Viewer()
        {
            this.InitializeComponent();

            OriginalTitle = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().Title;

            Application.Current.Suspending += CurrentApplication_Suspending;

            if (!(bool)SettingStorage.GetValue("ShowRightmostAndLeftmost"))
            {
                this.AppBarButtonLeftmost.Visibility  = Visibility.Collapsed;
                this.AppBarButtonRightmost.Visibility = Visibility.Collapsed;
            }

            var brSet = (double)SettingStorage.GetValue("BackgroundBrightness");
            var br    = (byte)((Application.Current.RequestedTheme == ApplicationTheme.Dark ? 1 - brSet : brSet) / 100.0 *
                               255.0);

            this.Background = new SolidColorBrush(new Windows.UI.Color()
            {
                A = 255, B = br, G = br, R = br
            });

            ((BookViewModel)this.DataContext).PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(BookFixed2ViewModels.BookViewModel.Title))
                {
                    SetTitle(Binding?.Title);
                }
            };

            flipView.UseTouchAnimationsForAllNavigation = (bool)SettingStorage.GetValue("ScrollAnimation");

            if (Binding != null)
            {
                Binding.PropertyChanged += (s, e) =>
                {
                    if (e.PropertyName == nameof(BookViewModel.Loading))
                    {
                        flipView.Focus(FocusState.Programmatic);
                    }
                };
            }
        }
Exemplo n.º 6
0
        internal static async Task <BookInfo[]> LoadAsync()
        {
            var infoRoaming = (bool)SettingStorage.GetValue("SyncBookmarks") ? (await LoadAsyncOne(await GetDataFileRoamingAsync(), fileRoamingSemaphore) ?? new BookInfo[0]).ToList() : new List <BookInfo>();
            var infoLocal   = (await LoadAsyncOne(await GetDataFileLocalAsync(), fileLocalSemaphore) ?? new BookInfo[0]).ToList();

            foreach (var item in infoLocal)
            {
                var rindex = infoRoaming.FindIndex((s) => s.ID == item.ID);
                if (rindex == -1)
                {
                    infoRoaming.Add(item);
                }
                else if (infoRoaming[rindex].ReadTimeLast < item.ReadTimeLast)
                {
                    infoRoaming.RemoveAt(rindex);
                    infoRoaming.Add(item);
                }
            }
            return(infoRoaming.ToArray());
        }
Exemplo n.º 7
0
        public BookShelfControl()
        {
            this.InitializeComponent();

            SetBookShelfItemSize((double)SettingStorage.GetValue("TileWidth"), (double)SettingStorage.GetValue("TileHeight"));
        }