Пример #1
0
        public void ReceiveNotification(string sourceFileUrl, NotificationType type)
        {
            // perform some action depending on the notification type
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (type)
            {
            case NotificationType.PluginStartup:
                // while (!Debugger.IsAttached) Thread.Sleep(1);
                try
                {
                    try
                    {
                        _settings = JsonConvert.DeserializeObject <SettingsObj>(File.ReadAllText(SettingsPath));
                    }
                    catch (Exception)
                    {
                        _settings = new SettingsObj
                        {
                            BorderColor  = Color.Black,
                            Color1       = Color.GhostWhite,
                            Color2       = Color.LightGray,
                            FontActual   = new Font(FontFamily.GenericSansSerif, 34.0f, FontStyle.Regular, GraphicsUnit.Point),
                            GradientType = 1
                        };
                    }

                    StartupMenuItem();
                    StartupForm();

                    if (_timer != null && _timer.Enabled)
                    {
                        _timer.Enabled = false;
                    }
                    _timer = new Timer(UpdateIntervalMs)
                    {
                        AutoReset = false
                    };
                    _timer.Elapsed += TimerTick;
                    _timer.Start();
                }
                catch (Exception e)
                {
                    _mbApiInterface.MB_Trace(e.ToString());
                }
                break;
            }
        }
Пример #2
0
        public PluginInfo Initialise(IntPtr apiInterfacePtr)
        {
            var versions = Assembly.GetExecutingAssembly().GetName().Version.ToString().Split('.');

            _mbApiInterface = new MusicBeeApiInterface();
            _mbApiInterface.Initialise(apiInterfacePtr);
            _about.PluginInfoVersion = PluginInfoVersion;
            _about.Name                     = "Netease Lyrics";
            _about.Description              = "A plugin to retrieve lyrics from Netease Cloud Music.(从网易云音乐获取歌词的插件。)";
            _about.Author                   = "Charlie Jiang";
            _about.TargetApplication        = "";                       // current only applies to artwork, lyrics or instant messenger name that appears in the provider drop down selector or target Instant Messenger
            _about.Type                     = PluginType.LyricsRetrieval;
            _about.VersionMajor             = short.Parse(versions[0]); // your plugin version
            _about.VersionMinor             = short.Parse(versions[1]);
            _about.Revision                 = short.Parse(versions[2]);
            _about.MinInterfaceVersion      = MinInterfaceVersion;
            _about.MinApiRevision           = MinApiRevision;
            _about.ReceiveNotifications     = ReceiveNotificationFlags.DownloadEvents;
            _about.ConfigurationPanelHeight = 50;   // height in pixels that musicbee should reserve in a panel for config settings. When set, a handle to an empty panel will be passed to the Configure function

            string noTranslatePath = Path.Combine(_mbApiInterface.Setting_GetPersistentStoragePath(), NoTranslateFilename);
            string configPath      = Path.Combine(_mbApiInterface.Setting_GetPersistentStoragePath(), ConfigFilename);

            if (File.Exists(configPath))
            {
                try
                {
                    _config = JsonConvert.DeserializeObject <NeteaseConfig>(File.ReadAllText(configPath, Encoding.UTF8));
                }
                catch (Exception ex)
                {
                    _mbApiInterface.MB_Trace("[NeteaseMusic] Failed to load config" + ex);
                }
            }
            if (File.Exists(noTranslatePath))
            {
                File.Delete(noTranslatePath);
                _config.format = NeteaseConfig.OutputFormat.Original;
                SaveSettingsInternal();
            }

            return(_about);
        }