Пример #1
0
        public App()
        {
            this.InitializeComponent();
            bool isDisableScale = AppTool.GetBoolSetting(Settings.DisableXboxScale);

            if (SystemInformation.DeviceFamily == "Windows.Xbox" && isDisableScale)
            {
                Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);
                Windows.UI.ViewManagement.ApplicationViewScaling.TrySetDisableLayoutScaling(true);
            }
            CustomXamlResourceLoader.Current = new CustomResourceLoader();
            this.Suspending    += OnSuspending;
            UnhandledException += OnUnhandleException;
            EnteredBackground  += App_EnteredBackground;
            LeavingBackground  += App_LeavingBackground;
            App.AppViewModel    = new AppViewModel();
            App.BiliViewModel   = new BiliViewModel();
            bool isThemeWithSystem = AppTool.GetBoolSetting(Settings.IsThemeWithSystem);

            _isTabletMode = AppTool.GetLocalSetting(Settings.DisplayMode, "") == "Tablet";
            if (!isThemeWithSystem)
            {
                string theme = AppTool.GetLocalSetting(Settings.Theme, "Light");
                RequestedTheme = theme == "Light" ? ApplicationTheme.Light : ApplicationTheme.Dark;
            }
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Window.Current.SetTitleBar(TitleContainer);
            if (e.NavigationMode == NavigationMode.Back || _isInit)
            {
                return;
            }
            bool isSideOpen = AppTool.GetBoolSetting(BiliBili_Lib.Enums.Settings.IsLastSidePanelOpen);

            AppSplitView.IsPaneOpen = isSideOpen;
            App.AppViewModel.CheckAppUpdate();
            var popup = new WaitingPopup("正在初始化");

            popup.ShowPopup();
            bool isCanRequest = await App.BiliViewModel._client.ValidateRequestAsync();

            if (isCanRequest)
            {
                try
                {
                    await App.BiliViewModel.GetRegionsAsync();

                    App.AppViewModel.FontInit();
                    Window.Current.Dispatcher.AcceleratorKeyActivated += App.AppViewModel.AccelertorKeyActivedHandle;
                    if (e.Parameter != null && e.Parameter is string argument && !string.IsNullOrEmpty(argument) && argument.Contains("action"))
                    {
                        App.AppViewModel.AppInitByActivated(argument);
                    }
                    else
                    {
                        PagePanel.NavigateToPage(Models.Enums.AppMenuItemType.Home);
                    }
                }
Пример #3
0
        private static void IsCompactOverlay_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var instance = d as VideoTransportControls;
            var v        = (bool)e.NewValue;

            if (!instance.IsInit)
            {
                return;
            }
            if (instance.IsFullWindow && v)
            {
                instance.IsFullWindow = false;
            }
            else if (instance.IsCinema && v)
            {
                instance.IsCinema = false;
            }
            if (instance.DanmakuControls != null)
            {
                bool isShow = AppTool.GetBoolSetting(BiliBili_Lib.Enums.Settings.IsShowDanmakuInCompactOverlay, false);
                if (!isShow && v)
                {
                    instance.DanmakuControls.Visibility = Visibility.Collapsed;
                }
                else
                {
                    instance.DanmakuControls.Visibility = Visibility.Visible;
                }
            }
            instance.CompactOverlayButtonClick?.Invoke(instance, v);
            instance.DanmakuControls.UpdateLayout();
        }
Пример #4
0
        /// <summary>
        /// Emoji表情初始化
        /// </summary>
        /// <param name="isRefresh">是否强制刷新</param>
        /// <returns></returns>
        public async Task InitEmoji(bool isRefresh = false)
        {
            bool isInit = AppTool.GetBoolSetting(Settings.IsInitEmoji, false);

            if (!isInit || isRefresh)
            {
                var emojis = await _client.GetTotalEmojiAsync();

                if (emojis != null && emojis.Count > 0)
                {
                    var emo = new List <EmojiItem>();
                    foreach (var item in emojis)
                    {
                        emo = emo.Concat(item.emojis).ToList();
                    }
                    _emojis = emo;
                    AppTool.WriteLocalSetting(Settings.IsInitEmoji, "True");
                    await IOTool.SetLocalDataAsync("emoji.json", JsonConvert.SerializeObject(_emojis));
                }
            }
            else
            {
                var emojis = await IOTool.GetLocalDataAsync <List <EmojiItem> >("emoji.json");

                _emojis = emojis;
            }
        }
Пример #5
0
 private void Reset()
 {
     DynamicCollection.Clear();
     TotalList.Clear();
     LoadingRing.IsActive = false;
     offset                       = "";
     _isOnlyVideo                 = AppTool.GetBoolSetting(BiliBili_Lib.Enums.Settings.IsDynamicOnlyVideo);
     OnlyVideoSwitch.IsOn         = _isOnlyVideo;
     DynamicHolderText.Visibility = Visibility.Collapsed;
     LoadingBar.Visibility        = Visibility.Collapsed;
 }
Пример #6
0
 private void Reset()
 {
     if (PageContainer.Visibility == Visibility.Collapsed)
     {
         PageContainer.Visibility = Visibility.Visible;
     }
     DynamicCollection.Clear();
     TotalList.Clear();
     LoadingRing.IsActive = false;
     offset                       = "";
     _scrollOffset                = 0;
     _isOnlyVideo                 = AppTool.GetBoolSetting(BiliBili_Lib.Enums.Settings.IsDynamicOnlyVideo);
     OnlyVideoSwitch.IsOn         = _isOnlyVideo;
     HolderText.Visibility        = Visibility.Collapsed;
     DynamicLoadingBar.Visibility = Visibility.Collapsed;
 }
 protected async override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e.Parameter != null)
     {
         if (e.Parameter is Tuple <VideoDetail, int> data)
         {
             await VideoPlayer.Init(data.Item1, data.Item2);
         }
         else if (e.Parameter is Tuple <BangumiDetail, Episode> bangu)
         {
             await VideoPlayer.Init(bangu.Item1, bangu.Item2);
         }
         bool isShowDanmakuBar = AppTool.GetBoolSetting(Settings.IsShowDanmakuBarInSeparate, false);
         VideoPlayer.DanmakuBarVisibility = isShowDanmakuBar ? Visibility.Visible : Visibility.Collapsed;
         VideoPlayer.ChangeDanmakuBarDisplayMode(false, isShowDanmakuBar);
         UIHelper.SetTitleBarColor();
     }
 }
Пример #8
0
        public void CheckPlayerOnBackgroundChanged()
        {
            bool isStopInBackground = AppTool.GetBoolSetting(Settings.IsStopInBackground, false);

            if (IsInBackground)
            {
                if (isStopInBackground && CurrentVideoPlayer != null)
                {
                    CurrentVideoPlayer.MTC.IsPlaying = false;
                }
            }
            else
            {
                if (isStopInBackground && CurrentVideoPlayer != null)
                {
                    CurrentVideoPlayer.MTC.IsPlaying = true;
                }
            }
        }
Пример #9
0
        public App()
        {
            this.InitializeComponent();

            CustomXamlResourceLoader.Current = new CustomResourceLoader();
            this.Suspending    += OnSuspending;
            UnhandledException += OnUnhandleException;
            EnteredBackground  += App_EnteredBackground;
            LeavingBackground  += App_LeavingBackground;
            App.AppViewModel    = new AppViewModel();
            App.BiliViewModel   = new BiliViewModel();
            bool isThemeWithSystem = AppTool.GetBoolSetting(Settings.IsThemeWithSystem);

            _isTabletMode = AppTool.GetLocalSetting(Settings.DisplayMode, "") == "Tablet";
            if (!isThemeWithSystem)
            {
                string theme = AppTool.GetLocalSetting(Settings.Theme, "Light");
                RequestedTheme = theme == "Light" ? ApplicationTheme.Light : ApplicationTheme.Dark;
            }
        }
Пример #10
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (_isInit || e.NavigationMode == NavigationMode.Back)
            {
                return;
            }

            #region 基础设置
            bool isThemeWithSystem = AppTool.GetBoolSetting(Settings.IsThemeWithSystem);
            ThemeWithSystemSwitch.IsOn = isThemeWithSystem;
            ThemeComboBox.Visibility   = isThemeWithSystem ? Visibility.Collapsed : Visibility.Visible;
            string theme = AppTool.GetLocalSetting(Settings.Theme, "Light");
            ThemeComboBox.SelectedIndex = theme == "Light" ? 0 : 1;
            string displayMode = AppTool.GetLocalSetting(Settings.DisplayMode, "Desktop");
            switch (displayMode)
            {
            case "Desktop":
                DisplayModeComboBox.SelectedIndex = 0;
                break;

            case "Tablet":
                DisplayModeComboBox.SelectedIndex = 1;
                break;

            default:
                break;
            }
            double pageBreakpoint = Convert.ToDouble(AppTool.GetLocalSetting(Settings.PagePanelDisplayBreakpoint, "1500"));
            PagePaneDisplayBreakpointBox.Value = pageBreakpoint;
            bool isEnableAnimation = AppTool.GetBoolSetting(Settings.EnableAnimation);
            EnableAnimationSwitch.IsOn = isEnableAnimation;
            StartupTask startupTask = await StartupTask.GetAsync("RichasyBiliBili");

            bool isEnableStartup = startupTask.State.ToString().Contains("Enable");
            EnableStartupSwitch.IsOn = isEnableStartup;
            double fontSize = Convert.ToDouble(AppTool.GetLocalSetting(Settings.BasicFontSize, "14"));
            FontSizeBox.Value = fontSize;
            DisableScaleInXboxSwitch.IsEnabled = SystemInformation.DeviceFamily == "Windows.Xbox";
            bool disableScale = AppTool.GetBoolSetting(Settings.DisableXboxScale);
            DisableScaleInXboxSwitch.IsOn = disableScale;
            #endregion

            #region 播放器设置
            bool isAutoPlay = AppTool.GetBoolSetting(Settings.IsAutoPlay);
            AutoPlaySwitch.IsOn = isAutoPlay;
            bool isAutoNextPart = AppTool.GetBoolSetting(Settings.IsAutoNextPart, false);
            AutoNextPartSwitch.IsOn = isAutoNextPart;
            bool isManualMTC = AppTool.GetBoolSetting(Settings.IsManualMediaTransportControls, false);
            ManualMTCSwitch.IsOn = isManualMTC;
            double playerSkipStep = Convert.ToDouble(AppTool.GetLocalSetting(Settings.PlayerSkipStep, "30"));
            PlayerSkipStepBox.Value = playerSkipStep;
            bool isFirst4K = AppTool.GetBoolSetting(Settings.IsFirst4K, false);
            First4KSwitch.IsOn = isFirst4K;
            bool isShowDanmakuBarInFullWindow = AppTool.GetBoolSetting(Settings.IsShowDanmakuBarInFullWindow);
            OpenDanmakuBarInFullWindowSwitch.IsOn = isShowDanmakuBarInFullWindow;
            bool isShowDanmakuBarInCinema = AppTool.GetBoolSetting(Settings.IsShowDanmakuBarInCinema);
            OpenDanmakuBarInCinemaSwitch.IsOn = isShowDanmakuBarInCinema;
            bool isShowDanmakuBarInCompact = AppTool.GetBoolSetting(Settings.IsShowDanmakuBarInCompactOverlay);
            OpenDanmakuBarInCompactSwitch.IsOn = isShowDanmakuBarInCompact;
            bool isShowDanmakuBarInSeparate = AppTool.GetBoolSetting(Settings.IsShowDanmakuBarInSeparate);
            OpenDanmakuBarInSeparateSwitch.IsOn = isShowDanmakuBarInSeparate;
            bool isShowDanmakuInCompact = AppTool.GetBoolSetting(Settings.IsShowDanmakuInCompactOverlay);
            OpenDanmakuInCompactSwitch.IsOn = isShowDanmakuInCompact;
            bool isStopInBackground = AppTool.GetBoolSetting(Settings.IsStopInBackground);
            StopPlayInBackgroundSwitch.IsOn = isStopInBackground;
            string playerMode = AppTool.GetLocalSetting(Settings.PlayerMode, "Default");
            switch (playerMode)
            {
            case "Default":
            default:
                PlayerModeComboBox.SelectedIndex = 0;
                break;

            case "Cinema":
                PlayerModeComboBox.SelectedIndex = 1;
                break;

            case "Full":
                PlayerModeComboBox.SelectedIndex = 2;
                break;
            }
            #endregion

            #region 通知设置
            bool isOpenDynamicToast = AppTool.GetBoolSetting(Settings.IsOpenNewDynamicNotification, false);
            NewDynamicToastSwitch.IsOn = isOpenDynamicToast;
            #endregion

            base.OnNavigatedTo(e);
            _isInit = true;
        }
Пример #11
0
        private void OnLaunchedOrActivated(IActivatedEventArgs e)
        {
            try
            {
                Frame rootFrame = Window.Current.Content as Frame;

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (rootFrame == null)
                {
                    SYEngine.Core.Initialize();
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame = new Frame();

                    rootFrame.NavigationFailed += OnNavigationFailed;

                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                }

                BackgroundTaskHelper.Register("ToastBackgroundTask", new ToastNotificationActionTrigger());
                if (e is LaunchActivatedEventArgs && (e as LaunchActivatedEventArgs).PrelaunchActivated == false)
                {
                    if (rootFrame.Content == null)
                    {
                        string display = AppTool.GetLocalSetting(Settings.DisplayMode, "");
                        if (string.IsNullOrEmpty(display))
                        {
                            rootFrame.Navigate(typeof(WelcomePage), (e as LaunchActivatedEventArgs).Arguments);
                        }
                        else
                        {
                            if (_isTabletMode)
                            {
                                rootFrame.Navigate(typeof(TabletMainPage), (e as LaunchActivatedEventArgs).Arguments);
                            }
                            else
                            {
                                rootFrame.Navigate(typeof(DesktopMainPage), (e as LaunchActivatedEventArgs).Arguments);
                            }
                        }
                    }
                    // Ensure the current window is active
                }
                else if (e.Kind == ActivationKind.StartupTask)
                {
                    if (rootFrame.Content == null)
                    {
                        if (_isTabletMode)
                        {
                            rootFrame.Navigate(typeof(TabletMainPage), null);
                        }
                        else
                        {
                            rootFrame.Navigate(typeof(DesktopMainPage), null);
                        }
                    }
                }
                else if (e is ToastNotificationActivatedEventArgs toastActivationArgs)
                {
                    if (rootFrame.Content == null)
                    {
                        if (_isTabletMode)
                        {
                            rootFrame.Navigate(typeof(TabletMainPage), toastActivationArgs.Argument);
                        }
                        else
                        {
                            rootFrame.Navigate(typeof(DesktopMainPage), toastActivationArgs.Argument);
                        }
                    }
                    else
                    {
                        AppViewModel.AppInitByActivated(toastActivationArgs.Argument);
                    }
                }
                else if (e is ProtocolActivatedEventArgs protocalArgs)
                {
                    string arg = protocalArgs.Uri.Query.Replace("?", "");
                    if (rootFrame.Content == null)
                    {
                        if (_isTabletMode)
                        {
                            rootFrame.Navigate(typeof(TabletMainPage), arg);
                        }
                        else
                        {
                            rootFrame.Navigate(typeof(DesktopMainPage), arg);
                        }
                    }
                    else
                    {
                        AppViewModel.AppInitByActivated(arg);
                    }
                }
                Window.Current.Activate();
                UIHelper.SetTitleBarColor();
                bool isDisableScale = AppTool.GetBoolSetting(Settings.DisableXboxScale);
                if (SystemInformation.DeviceFamily == "Windows.Xbox")
                {
                    var view = ApplicationView.GetForCurrentView();
                    view.SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
                    if (isDisableScale)
                    {
                        ApplicationViewScaling.TrySetDisableLayoutScaling(true);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("启动出错", ex);
            }
        }