Exemplo n.º 1
0
        private async void NewDynamicToastSwitch_Toggled(object sender, RoutedEventArgs e)
        {
            if (!_isInit)
            {
                return;
            }
            if (NewDynamicToastSwitch.IsOn)
            {
                bool isSuccess = await App.AppViewModel.RegisterBackgroundTask(StaticString.NOTIFICATION_NEWDYNAMIC);

                if (isSuccess)
                {
                    AppTool.WriteLocalSetting(Settings.IsOpenNewDynamicNotification, "True");
                }
                else
                {
                    AppTool.WriteLocalSetting(Settings.IsOpenNewDynamicNotification, "False");
                    NewDynamicToastSwitch.IsOn = false;
                }
            }
            else
            {
                App.AppViewModel.UnRegisterBackgroundTask(StaticString.NOTIFICATION_NEWDYNAMIC);
            }
        }
Exemplo n.º 2
0
 private async void OnlyVideoSwitch_Toggled(object sender, RoutedEventArgs e)
 {
     if (!_isInit)
     {
         return;
     }
     _isOnlyVideo = (sender as ToggleSwitch).IsOn;
     AppTool.WriteLocalSetting(BiliBili_Lib.Enums.Settings.IsDynamicOnlyVideo, _isOnlyVideo.ToString());
     if (_isOnlyVideo)
     {
         for (int i = DynamicCollection.Count - 1; i >= 0; i--)
         {
             if (DynamicCollection[i].desc.type != 8 && DynamicCollection[i].desc.type != 512)
             {
                 DynamicCollection.RemoveAt(i);
             }
         }
         //判断过滤后的动态是否能让滚动条显示,不能则再请求一次
         if (DynamicCollection.Count < 10)
         {
             await LoadDynamic();
         }
     }
     else
     {
         DynamicCollectionInit();
     }
 }
Exemplo n.º 3
0
 private void TokenChanged(object sender, TokenPackage e)
 {
     AppTool.WriteLocalSetting(Settings.AccessToken, e.AccessToken);
     AppTool.WriteLocalSetting(Settings.RefreshToken, e.RefreshToken);
     AppTool.WriteLocalSetting(Settings.TokenExpiry, e.Expiry.ToString());
     AppTool.WriteLocalSetting(Settings.UserId, "");
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 5
0
 private void First4KSwitch_Toggled(object sender, RoutedEventArgs e)
 {
     if (!_isInit)
     {
         return;
     }
     AppTool.WriteLocalSetting(Settings.IsFirst4K, First4KSwitch.IsOn.ToString());
 }
Exemplo n.º 6
0
 private void StopPlayInBackgroundSwitch_Toggled(object sender, RoutedEventArgs e)
 {
     if (!_isInit)
     {
         return;
     }
     AppTool.WriteLocalSetting(Settings.IsStopInBackground, StopPlayInBackgroundSwitch.IsOn.ToString());
 }
Exemplo n.º 7
0
 private void FontSizeBox_ValueChanged(object sender, double e)
 {
     if (!_isInit)
     {
         return;
     }
     AppTool.WriteLocalSetting(Settings.BasicFontSize, e.ToString());
 }
Exemplo n.º 8
0
 private void EnableAnimationSwitch_Toggled(object sender, RoutedEventArgs e)
 {
     if (!_isInit)
     {
         return;
     }
     AppTool.WriteLocalSetting(Settings.EnableAnimation, EnableAnimationSwitch.IsOn.ToString());
 }
Exemplo n.º 9
0
 private void OpenDanmakuInCompactSwitch_Toggled(object sender, RoutedEventArgs e)
 {
     if (!_isInit)
     {
         return;
     }
     AppTool.WriteLocalSetting(Settings.IsShowDanmakuInCompactOverlay, OpenDanmakuInCompactSwitch.IsOn.ToString());
 }
Exemplo n.º 10
0
 private void AutoNextPartSwitch_Toggled(object sender, RoutedEventArgs e)
 {
     if (!_isInit)
     {
         return;
     }
     AppTool.WriteLocalSetting(Settings.IsAutoNextPart, AutoNextPartSwitch.IsOn.ToString());
 }
Exemplo n.º 11
0
 private void OpenDanmakuBarInSeparateSwitch_Toggled(object sender, RoutedEventArgs e)
 {
     if (!_isInit)
     {
         return;
     }
     AppTool.WriteLocalSetting(Settings.IsShowDanmakuBarInSeparate, OpenDanmakuBarInSeparateSwitch.IsOn.ToString());
 }
Exemplo n.º 12
0
 private void PagePaneDisplayBreakpointBox_ValueChanged(object sender, double e)
 {
     if (!_isInit)
     {
         return;
     }
     AppTool.WriteLocalSetting(Settings.PagePanelDisplayBreakpoint, e.ToString());
 }
Exemplo n.º 13
0
 private void PlayerSkipStepBox_ValueChanged(object sender, double e)
 {
     if (!_isInit)
     {
         return;
     }
     AppTool.WriteLocalSetting(Settings.PlayerSkipStep, e.ToString());
 }
Exemplo n.º 14
0
 private void ManualMTCSwitch_Toggled(object sender, RoutedEventArgs e)
 {
     if (!_isInit)
     {
         return;
     }
     AppTool.WriteLocalSetting(Settings.IsManualMediaTransportControls, ManualMTCSwitch.IsOn.ToString());
 }
Exemplo n.º 15
0
 private async void DisableScaleInXboxSwitch_Toggled(object sender, RoutedEventArgs e)
 {
     if (!_isInit)
     {
         return;
     }
     AppTool.WriteLocalSetting(Settings.DisableXboxScale, DisableScaleInXboxSwitch.IsOn.ToString());
     await ShowRestartDialog();
 }
Exemplo n.º 16
0
        private void PlayerModeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!_isInit)
            {
                return;
            }
            var    item = PlayerModeComboBox.SelectedItem as ComboBoxItem;
            string tag  = item.Tag.ToString();

            AppTool.WriteLocalSetting(Settings.PlayerMode, tag);
        }
Exemplo n.º 17
0
        private async void DisplayModeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!_isInit)
            {
                return;
            }
            var item = DisplayModeComboBox.SelectedItem as ComboBoxItem;

            AppTool.WriteLocalSetting(Settings.DisplayMode, item.Tag.ToString());
            await ShowRestartDialog();
        }
Exemplo n.º 18
0
        private async void ThemeWithSystemSwitch_Toggled(object sender, RoutedEventArgs e)
        {
            if (!_isInit)
            {
                return;
            }
            bool ison = ThemeWithSystemSwitch.IsOn;

            AppTool.WriteLocalSetting(Settings.IsThemeWithSystem, ison.ToString());
            ThemeComboBox.Visibility = ison ? Visibility.Collapsed : Visibility.Visible;
            await ShowRestartDialog();
        }
Exemplo n.º 19
0
        private async void ThemeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!_isInit)
            {
                return;
            }
            var    item     = (ThemeComboBox.SelectedItem as ComboBoxItem).Tag.ToString();
            string oldTheme = AppTool.GetLocalSetting(Settings.Theme, "Light");

            if (oldTheme != item)
            {
                AppTool.WriteLocalSetting(Settings.Theme, item);
                await ShowRestartDialog();
            }
        }
Exemplo n.º 20
0
        private async void FontComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!_isInit)
            {
                return;
            }
            var    item    = FontComboBox.SelectedItem as SystemFont;
            string oldFont = AppTool.GetLocalSetting(Settings.FontFamily, "微软雅黑");

            if (item.Name != oldFont)
            {
                AppTool.WriteLocalSetting(Settings.FontFamily, item.Name);
                await ShowRestartDialog();
            }
        }
Exemplo n.º 21
0
        private void GridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var   item      = e.ClickedItem as Grid;
            Frame rootFrame = Window.Current.Content as Frame;

            if (item.Tag.ToString() == "Desktop")
            {
                AppTool.WriteLocalSetting(BiliBili_Lib.Enums.Settings.DisplayMode, "Desktop");
                App._isTabletMode = false;
                rootFrame.Navigate(typeof(DesktopMainPage), new DrillInNavigationTransitionInfo());
            }
            else
            {
                AppTool.WriteLocalSetting(BiliBili_Lib.Enums.Settings.DisplayMode, "Tablet");
                App._isTabletMode = true;
                rootFrame.Navigate(typeof(TabletMainPage), new DrillInNavigationTransitionInfo());
            }
        }
Exemplo n.º 22
0
        public async void CheckAppUpdate()
        {
            string localVersion = AppTool.GetLocalSetting(Settings.LocalVersion, "");
            string nowVersion   = string.Format("{0}.{1}.{2}.{3}", Package.Current.Id.Version.Major, Package.Current.Id.Version.Minor, Package.Current.Id.Version.Build, Package.Current.Id.Version.Revision);

            if (localVersion != nowVersion)
            {
                var updateFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Others/Update.txt"));

                string updateInfo = await FileIO.ReadTextAsync(updateFile);

                if (_updatePopup == null)
                {
                    _updatePopup = new UpdatePopup(updateInfo);
                }
                _updatePopup.ShowPopup();
                AppTool.WriteLocalSetting(Settings.LocalVersion, nowVersion);
            }
        }
        /// <summary>
        /// 获取新动态
        /// </summary>
        /// <returns>动态响应</returns>
        public async Task <NewDynamicResponse> GetNewDynamicAsync(string lastSeemId = "0")
        {
            var param = new Dictionary <string, string>();

            param.Add("cold_start", "1");
            param.Add("qn", "32");
            param.Add("rsp_type", "2");
            param.Add("type_list", "268435455");
            param.Add("uid", BiliTool.mid);
            if (!string.IsNullOrEmpty(lastSeemId) && lastSeemId != "0")
            {
                param.Add("update_num_dy_id", lastSeemId);
            }
            string url  = BiliTool.UrlContact(Api.DYNAMIC_NEW, param, true, useiPhone: true);
            var    data = await BiliTool.ConvertEntityFromWebAsync <NewDynamicResponse>(url);

            if (data != null && data.cards != null)
            {
                data.cards.RemoveAll(p => p == null || p.card == null || p.card.Length < 10 || p.desc.status != 1);
                AppTool.WriteLocalSetting(BiliBili_Core.Enums.Settings.LastSeemDynamicId, data.max_dynamic_id);
            }
            return(data);
        }
 private void CloseButton_Click(object sender, RoutedEventArgs e)
 {
     AppTool.WriteLocalSetting(Settings.LocalVersion, version);
     HidePopup();
 }
Exemplo n.º 25
0
 private void PaneButton_Click(object sender, RoutedEventArgs e)
 {
     IsWide = !IsWide;
     AppTool.WriteLocalSetting(BiliBili_Lib.Enums.Settings.IsLastSidePanelOpen, IsWide.ToString());
 }