Esempio n. 1
0
        public InfoReader() : base(PLUGIN_NAME, PLUGIN_AUTHOR)
        {
            if (!File.Exists("InfoReader.db"))
            {
                File.WriteAllBytes("InfoReader.db", Resource1.Database);
            }

            /*else
             * {
             *  byte[] dbBytes = File.ReadAllBytes("InfoReader.db");
             *  MD5 selfMd5 = MD5.Create(), fileMd5 = MD5.Create();
             *  selfMd5.ComputeHash(Resource1.Database);
             *  fileMd5.ComputeHash(dbBytes);
             *  MD5String selfMd5String = new MD5String(selfMd5), fileMd5String = new MD5String(fileMd5);
             *  if (selfMd5String != fileMd5String)
             *  {
             *      File.Delete("InfoReader.db");
             *      File.WriteAllBytes("InfoReader.db",Resource1.Database);
             *  }
             * }*/
            StringBuilder builder = new StringBuilder(32);

            GetPrivateProfileString("Sync.DefaultConfiguration", "Language", "zh-cn", builder, 32, "..\\config.ini");
            SyncLang     = builder.ToString();
            CurrentNi18N = NI18n.GetCurrentLanguage();
            CurrentNi18N.InitializeOperator();
            ScanCommand();
            if (File.Exists("RealTimePPDisplayer.dll"))
            {
                byte[] b = File.ReadAllBytes("RealTimePPDisplayer.dll");
                MD5    selfMd5 = MD5.Create(), fileMd5 = MD5.Create();
                selfMd5.ComputeHash(Resource1.ModifiedRealTimePPDisplayer);
                fileMd5.ComputeHash(b);
                if (MD5String.GetString(selfMd5) != MD5String.GetString(fileMd5))
                {
                    var dirInfo = Directory.CreateDirectory("..\\OrignalRealTimePPDisplayer\\");
                    IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_RTPPDREPLACED"));
                    if (File.Exists(Path.Combine(dirInfo.FullName, "RealTimePPDisplayer.dll")))
                    {
                        File.Delete(Path.Combine(dirInfo.FullName, "RealTimePPDisplayer.dll"));
                    }
                    File.Move("RealTimePPDisplayer.dll", Path.Combine(dirInfo.FullName, "RealTimePPDisplayer.dll"));
                    File.WriteAllBytes("RealTimePPDisplayer.dll", Resource1.ModifiedRealTimePPDisplayer);
                }
            }
            else
            {
                File.WriteAllBytes("RealTimePPDisplayer.dll", Resource1.ModifiedRealTimePPDisplayer);
            }

            /*if(!File.Exists("bass.dll"))
             *  File.WriteAllBytes("bass.dll",Resource1.bass);*/

            _outputInfoMap = MemoryMappedFile.CreateOrOpen("InfoReaderMmf", 128);
            EventBus.BindEvent <PluginEvents.InitPluginEvent>(Init);
            EventBus.BindEvent <PluginEvents.LoadCompleteEvent>(Loaded);
            EventBus.BindEvent <PluginEvents.InitCommandEvent>(CommandInit);
            PluginConfigurationManager manager = new Sync.Tools.PluginConfigurationManager(this);

            manager.AddItem(Setting);
        }