Ejemplo n.º 1
0
        internal static void Save()
        {
            IniFile ini = new IniFile(configpath);

            ini.Write("请勿编辑此文件", "Don't Edit This File", "请勿编辑此文件");

            ini.Write("songVol", songVol.ToString());
            ini.Write("needLyric", needLyric.ToString());
            ini.Write("maxSongCount", maxSongCount.ToString());
            ini.Write("outputUpdateTime", outputUpdateTime.ToString());
            ini.Write("OutputType", OutputType.ToString());
            ini.Write("CanMultiSong", CanMultiSong.ToString());
            ini.Write("AdminOnly", AdminOnly.ToString());
            ini.Write("MaxPlaySecond", MaxPlaySecond.ToString());
            ini.Write("VoteNext", VoteNext.ToString());
            ini.Write("LogStayTime", LogStayTime.ToString());
            ini.Write("ControlOtherPlayer", ControlOtherPlayer.ToString());
            ini.Write("OneLyric", OneLyric.ToString());
            ini.Write("DanmakuControl", DanmakuControl.ToString());
            ini.Write("OutputEmptyList", OutputEmptyList);
            ini.Write("OutputOtherNamePrefix", OutputOtherNamePrefix);

            ini.Write("moduleA", R_ModuleNameA); // 保存当前选择的搜索模块的名字
            ini.Write("moduleB", R_ModuleNameB);

            OPT_Save();
            BLK_Save();
        }
Ejemplo n.º 2
0
        internal static void Load()
        {
            IniFile ini = new IniFile(configpath);

            int aint;

            songVol      = (int.TryParse(ini.Read("songVol"), out aint) ? aint : DefaultConfig.songVol);
            maxSongCount = (int.TryParse(ini.Read("maxSongCount"), out aint) ? aint : DefaultConfig.maxSongCount);
            // outputUpdateTime = (int.TryParse(ini.Read("outputUpdateTime"), out aint) ? aint : DefaultConfig.outputUpdateTime);
            outputUpdateTime = DefaultConfig.outputUpdateTime;
            MaxPlaySecond    = (int.TryParse(ini.Read("MaxPlaySecond"), out aint) ? aint : DefaultConfig.MaxPlaySecond);
            VoteNext         = (int.TryParse(ini.Read("VoteNext"), out aint) ? aint : DefaultConfig.VoteNext);
            LogStayTime      = (int.TryParse(ini.Read("LogStayTime"), out aint) ? aint : DefaultConfig.LogStayTime);
            OutputType       = (int.TryParse(ini.Read("OutputType"), out aint) ? aint : DefaultConfig.OutputType);

            bool abool;

            // needLyric = (bool.TryParse(ini.Read("needLyric"), out abool) ? abool : DefaultConfig.needLyric);
            needLyric          = true;
            CanMultiSong       = (bool.TryParse(ini.Read("CanMultiSong"), out abool) ? abool : DefaultConfig.CanMultiSong);
            AdminOnly          = (bool.TryParse(ini.Read("AdminOnly"), out abool) ? abool : DefaultConfig.AdminOnly);
            ControlOtherPlayer = (bool.TryParse(ini.Read("ControlOtherPlayer"), out abool) ? abool : DefaultConfig.ControlOtherPlayer);
            DanmakuControl     = (bool.TryParse(ini.Read("DanmakuControl"), out abool) ? abool : DefaultConfig.DanmakuControl);
            OneLyric           = (bool.TryParse(ini.Read("OneLyric"), out abool) ? abool : DefaultConfig.OneLyric);

            OutputEmptyList       = ini.KeyExists("OutputEmptyList") ? ini.Read("OutputEmptyList") : DefaultConfig.OutputEmptyList;
            OutputOtherNamePrefix = ini.KeyExists("OutputOtherNamePrefix") ? ini.Read("OutputOtherNamePrefix") : DefaultConfig.OutputOtherNamePrefix;

            OPT_Load();

            PluginMain.self.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =>
            {
                Center.Mainw.Check_Lyric.IsChecked                = needLyric;
                Center.Mainw.Vol.Value                            = songVol;
                Center.Mainw.Setting_MaxSongCount.Text            = maxSongCount.ToString();
                Center.Mainw.Setting_CanMultiSong.IsChecked       = CanMultiSong;
                Center.Mainw.Setting_AdminOnly.IsChecked          = AdminOnly;
                Center.Mainw.Setting_MaxPlaySecond.Text           = MaxPlaySecond.ToString();
                Center.Mainw.Setting_VoteNext.Text                = VoteNext.ToString();
                Center.Mainw.Setting_LogStayTime.Text             = LogStayTime.ToString();
                Center.Mainw.Setting_ControlOtherPlayer.IsChecked = ControlOtherPlayer;
                Center.Mainw.Setting_DanmakuControl.IsChecked     = DanmakuControl;
                Center.Mainw.Setting_OneLyric.IsChecked           = OneLyric;
                Center.Mainw.Setting_OutputEmptyList.Text         = OutputEmptyList;
                Center.Mainw.Setting_OutputOtherNamePrefix.Text   = OutputOtherNamePrefix;
                Center.Mainw.Combo_OutputType.SelectedIndex       = OutputType;

                BLK_Load();

                if (Center.SearchModules.Count > 0)
                {
                    string moduleA = ini.Read("moduleA");
                    string moduleB = ini.Read("moduleB");

                    if (!string.IsNullOrEmpty(moduleA))
                    {
                        foreach (SongsSearchModule s in Center.SearchModules)
                        {
                            if (s.ModuleName == moduleA)
                            {
                                Center.Mainw.Combo_SearchModuleA.SelectedItem = s; break;
                            }
                        }
                    }
                    if (Center.Mainw.Combo_SearchModuleA.SelectedItem == null)
                    {
                        Center.Mainw.Combo_SearchModuleA.SelectedItem = Center.SearchModules[0];
                    }

                    if (!string.IsNullOrEmpty(moduleB))
                    {
                        foreach (SongsSearchModule s in Center.SearchModules)
                        {
                            if (s.ModuleName == moduleB)
                            {
                                Center.Mainw.Combo_SearchModuleB.SelectedItem = s; break;
                            }
                        }
                    }
                }
            }));
        }