Example #1
0
 /// <summary>
 /// Invoked when a property of the settings manager changes.
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The event data</param>
 private void SettingsManager_PropertyChanged(object sender, PropertyChangedWithValuesEventArgs e)
 {
     switch (e.PropertyName)
     {
         case "CurrentVisualizer":
             RefreshMeta();
             break;
     }
 }
		/// <summary>
		/// Invoked when a property of the settings manager changes
		/// </summary>
		/// <param name="sender">The sender of the event</param>
		/// <param name="e">The event data</param>
		private static void SettingsManager_PropertyChanged(object sender, PropertyChangedWithValuesEventArgs e)
		{
			switch (e.PropertyName)
			{
				case "Sources":
					ScanSources();
					break;
			}
		}
Example #3
0
        /// <summary>
        /// Invoked when a property changes in the service manager.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private void ServiceManager_PropertyChanged(object sender, PropertyChangedWithValuesEventArgs e)
        {
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
            {
                switch (e.PropertyName)
                {
                    case "DeviceName":
                        DeviceName.Edited -= DeviceName_Edited;
                        DeviceName.Text = e.NewValue as string;
                        DeviceNameLoading.Visibility = Visibility.Collapsed;
                        DeviceName.Visibility = Visibility.Visible;
                        DeviceName.Edited += DeviceName_Edited;
                        break;

                    case "UserName":
                        UserName.Text = e.NewValue as string;
                        UserNameLoading.Visibility = Visibility.Collapsed;
                        UserName.Visibility = Visibility.Visible;
                        break;

                    case "Linked":
                        U.L(LogLevel.Debug, "CONTROL", "Detected change in service link state");
                        RefreshServiceGUI();
                        linkingCloud = false;
                        break;

                    case "Links":
                        U.L(LogLevel.Debug, "CONTROL", "Detected change in links to third parties");
                        RefreshLinks();
                        break;

                    case "Synchronize":
                        RefreshSyncGUI();
                        break;

                    case "Connected":
                        Connected.Visibility = ServiceManager.Connected ? Visibility.Visible : Visibility.Collapsed;
                        Disconnected.Visibility = ServiceManager.Connected ? Visibility.Collapsed : Visibility.Visible;
                        break;
                }
            }));
        }
Example #4
0
        /// <summary>
        /// Invoked when a property of the settings manager is changed
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private static void SettingsManager_PropertyChanged(object sender, PropertyChangedWithValuesEventArgs e)
        {
            switch (e.PropertyName)
            {
                case "Seek":
                    if (ignoreSeekChange) break;
                    if (Double.IsNaN(SettingsManager.Seek)) return;

                    if ((double)e.NewValue - (double)e.OldValue > 0) trackWasSkipped = true;

                    if (YouTubeManager.IsYouTube(SettingsManager.CurrentTrack))
                    {
                        if (YouTubeManager.HasFlash)
                        {
                            bool playing = SettingsManager.MediaState == MediaState.Playing;
                            double pos = (SettingsManager.Seek / 10.0) * Length;
                            InvokeScript("seekTo", new object[] { pos }); // this will change media state to playing
                            if (!playing) InvokeScript("pause");
                        }
                    }
                    else
                    {
                        if (stream == 0) return;
                        double per = SettingsManager.Seek / 10.0;
                        long pos = (long)(per * Bass.BASS_ChannelGetLength(stream));
                        Bass.BASS_ChannelSetPosition(stream, pos);
                    }
                    break;

                case "Volume":
                    if (YouTubeManager.IsYouTube(SettingsManager.CurrentTrack))
                    {
                        if (YouTubeManager.HasFlash)
                            InvokeScript("setVolume", new object[] { SettingsManager.Volume });
                    }
                    else
                    {
                        if (stream == 0) return;
                        Bass.BASS_ChannelSetAttribute(stream, BASSAttribute.BASS_ATTRIB_VOL, (float)SettingsManager.Volume / 100);
                    }
                    break;

                case "CurrentTrack":
                    TrackData t = (TrackData)e.OldValue;
                    if (t != null)
                    {
                        TrackData sourceTrack = GetSourceTrack(t);
                        sourceTrack.IsActive = false;
                    }

                    t = SettingsManager.CurrentTrack;
                    if (t != null)
                    {
                        TrackData sourceTrack = GetSourceTrack(t);
                        sourceTrack.IsActive = true;
                    }
                    break;

                case "HistoryIndex":
                    TrackData oldTrack = null;
                    TrackData newTrack = null;

                    int oldIndex = (int)e.OldValue - 1;
                    int newIndex = (int)e.NewValue - 1;

                    if (oldIndex >= SettingsManager.HistoryTracks.Count)
                        oldIndex = SettingsManager.HistoryTracks.Count - 1;
                    else if (oldIndex == SettingsManager.HistoryTracks.Count - 1 &&
                        newIndex == SettingsManager.HistoryTracks.Count)
                        oldIndex = SettingsManager.HistoryTracks.Count - 2;

                    if (newIndex >= SettingsManager.HistoryTracks.Count)
                        newIndex = SettingsManager.HistoryTracks.Count - 1;

                    if (SettingsManager.HistoryTracks.Count > oldIndex &&
                        oldIndex >= 0)
                        oldTrack = SettingsManager.HistoryTracks[oldIndex];

                    if (SettingsManager.HistoryTracks.Count > newIndex &&
                        newIndex >= 0)
                        newTrack = SettingsManager.HistoryTracks[newIndex];

                    if (oldTrack != null)
                        oldTrack.IsActive = false;

                    if (newTrack != null)
                        newTrack.IsActive = true;
                    break;

                case "MediaState":
                    switch (SettingsManager.MediaState)
                    {
                        case MediaState.Paused:
                        case MediaState.Stopped:
                            // keep the ticker on if a youtube track is loaded (need it to see buffer size changes)
                            if (GetType(SettingsManager.CurrentTrack) != TrackType.YouTube)
                                StopTicker();
                            break;

                        case MediaState.Playing:
                            // don't waste CPU cycles with ticker if streaming radio
                            if (GetType(SettingsManager.CurrentTrack) != TrackType.WebRadio)
                                StartTicker();
                            break;

                        case MediaState.Ended:
                            if (SettingsManager.PauseWhenSongEnds)
                            {
                                Pause();
                                SettingsManager.Seek = 0;
                                Next(false, false);
                            }
                            else
                                Next(false, true);
                            break;
                    }
                    break;

                case "CurrentEqualizerProfile":
                    UpdateFXParameters();
                    break;
            }
        }
Example #5
0
 /// <summary>
 /// Invoked when a property of the settings manager changes
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The event data</param>
 private void SettingsManager_PropertyChanged(object sender, PropertyChangedWithValuesEventArgs e)
 {
     switch (e.PropertyName)
     {
         case "YouTubeListConfig":
             Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
             {
                 Config = SettingsManager.YouTubeListConfig;
                 SettingsManager.YouTubeListConfig.PropertyChanged += new PropertyChangedEventHandler(Config_PropertyChanged);
             }));
             break;
     }
 }
Example #6
0
        /// <summary>
        /// Invoked when a property of the SettingsMananger is changed.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private static void SettingsManager_PropertyChanged(object sender, PropertyChangedWithValuesEventArgs e)
        {
            switch (e.PropertyName)
            {
                case "Plugins":
                    SettingsManager.Plugins.CollectionChanged += new NotifyCollectionChangedEventHandler(Plugins_CollectionChanged);
                    break;

                case "CurrentVisualizer":
                    ActivateVisualizer(SettingsManager.CurrentVisualizer);
                    break;
            }
        }
Example #7
0
 /// <summary>
 /// Invoked when a property of the settings manager changes
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The event data</param>
 private static void SettingsManager_PropertyChanged(object sender, PropertyChangedWithValuesEventArgs e)
 {
     switch (e.PropertyName)
     {
         case "UpgradePolicy":
             if (SettingsManager.UpgradePolicy == UpgradePolicy.Manual)
                 Stop();
             else
             {
                 Start();
                 Probe(null);
             }
             break;
     }
 }