コード例 #1
0
 private async void LogRedirectToggleButton_OnChecked(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!await LoginCenterAPIWarpper.DoAuth(PluginMain))
         {
             LogRedirectToggleButton.IsChecked = false;
         }
     }
     catch (Exception)
     {
         LogRedirectToggleButton.IsChecked = false;
     }
 }
コード例 #2
0
        /// <summary>
        /// 应用设置
        /// </summary>
        /// <param name="config"></param>
        private void ApplyConfig(Config config)
        {
            Player.PlayerType             = config.PlayerType;
            Player.DirectSoundDevice      = config.DirectSoundDevice;
            Player.WaveoutEventDevice     = config.WaveoutEventDevice;
            Player.Volume                 = config.Volume;
            Player.IsUserPrior            = config.IsUserPrior;
            Player.IsPlaylistEnabled      = config.IsPlaylistEnabled;
            SearchModules.PrimaryModule   = SearchModules.Modules.FirstOrDefault(x => x.UniqueId == config.PrimaryModuleId) ?? SearchModules.NullModule;
            SearchModules.SecondaryModule = SearchModules.Modules.FirstOrDefault(x => x.UniqueId == config.SecondaryModuleId) ?? SearchModules.NullModule;
            DanmuHandler.MaxTotalSongNum  = config.MaxTotalSongNum;
            DanmuHandler.MaxPersonSongNum = config.MaxPersonSongNum;
            Writer.ScribanTemplate        = config.ScribanTemplate;
            IsLogRedirectDanmaku          = config.IsLogRedirectDanmaku;
            LogDanmakuLengthLimit         = config.LogDanmakuLengthLimit;

            LogRedirectToggleButton.IsEnabled = LoginCenterAPIWarpper.CheckLoginCenter();
            if (LogRedirectToggleButton.IsEnabled && IsLogRedirectDanmaku)
            {
                Task.Run(async() =>
                {
                    await Task.Delay(2000); // 其实不应该这么写的,不太合理
                    IsLogRedirectDanmaku = await LoginCenterAPIWarpper.DoAuth(PluginMain);
                });
            }
            else
            {
                IsLogRedirectDanmaku = false;
            }

            Playlist.Clear();
            foreach (var item in config.Playlist)
            {
                item.Module = SearchModules.Modules.FirstOrDefault(x => x.UniqueId == item.ModuleId);
                if (item.Module != null)
                {
                    Playlist.Add(item);
                }
            }

            Blacklist.Clear();
            foreach (var item in config.Blacklist)
            {
                Blacklist.Add(item);
            }
        }