示例#1
0
        public Configure(PlaylistSync playlistSync, Settings settings)
        {
            InitializeComponent();

            log = Logger.Instance;
            log.OnLogUpdated = new EventHandler(log_OnLogUpdated);

            _settings     = settings;
            _playlistSync = playlistSync;

            // Register event handlers
            _playlistSync.GMusic.OnLoginComplete     = new EventHandler(GMusic_OnLoginComplete);
            _playlistSync.GMusic.OnFetchDataComplete = new EventHandler(GMusic_OnFetchDataComplete);
            _playlistSync.GMusic.OnSyncComplete      = new EventHandler(GMusic_OnSyncComplete);
            _playlistSync.MBSync.OnSyncComplete      = new EventHandler(MBSync_OnSyncComplete);

            if (_playlistSync.GMusic.SyncRunning)
            {
                updateSyncStatus("Background sync running");
            }

            if (_settings.Email != null)
            {
                // decode it from base64
                byte[] email = Convert.FromBase64String(_settings.Email);
                emailTextBox.Text = Encoding.UTF8.GetString(email);
            }

            if (_settings.Password != null)
            {
                byte[] passwd = Convert.FromBase64String(_settings.Password);
                passwordTextBox.Text = Encoding.UTF8.GetString(passwd);
            }

            rememberCheckbox.Checked = _settings.SaveCredentials;

            // autoSyncCheckbox.Checked = _settings.SyncOnStartup;

            populateLocalPlaylists();

            // tagToolsPlugin.mbForm.AddOwnedForm(this);
        }
        public PluginInfo Initialise(IntPtr apiInterfacePtr)
        {
            mbApiInterface = new MusicBeeApiInterface();
            mbApiInterface.Initialise(apiInterfacePtr);
            about.PluginInfoVersion = PluginInfoVersion;
            about.Name                     = "Google Music Sync";
            about.Description              = "Sync your playlists to Google Play Music.";
            about.Author                   = "Leo Rampen";
            about.TargetApplication        = "None"; // 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.General;
            about.VersionMajor             = 1;      // your plugin version
            about.VersionMinor             = 7;
            about.Revision                 = 1;
            about.MinInterfaceVersion      = MinInterfaceVersion;
            about.MinApiRevision           = MinApiRevision;
            about.ReceiveNotifications     = (ReceiveNotificationFlags.PlayerEvents | ReceiveNotificationFlags.TagEvents);
            about.ConfigurationPanelHeight = 0;   // not implemented yet: 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


            // Comment this out to disable logging
            // Logger.Instance.LogFile = System.IO.Path.Combine(mbApiInterface.Setting_GetPersistentStoragePath(), "gMusicPlaylistSync.log.txt");

            createMenu();

            Logger.Instance.DebugLog("Getting settings");
            // Process taken from tag tools
            //Lets try to read defaults for controls from settings file
            string configFilePath = System.IO.Path.Combine(mbApiInterface.Setting_GetPersistentStoragePath(), "gMusicPlaylistSync.Settings.xml");

            _settings = Settings.ReadSettings(configFilePath);

            Logger.Instance.DebugLog("Creating PlaylistSync object");

            _playlistSync = new PlaylistSync(_settings, mbApiInterface);

            return(about);
        }