Esempio n. 1
0
        /// <summary>
        /// Invoked when the media manager switches from one track to another
        /// </summary>
        /// <param name="e">The event data</param>
        private void MediaManager_TrackSwitched(TrackSwitchedEventArgs e)
        {
            if (trackSwitchDelay != null)
                trackSwitchDelay.Stop();
            trackSwitchDelay = new DispatcherTimer();
            trackSwitchDelay.Interval = new TimeSpan(0, 0, 1);
            trackSwitchDelay.Tick += delegate(object s, EventArgs ea) { MediaManager_TrackSwitchedDelayed(e); };
            trackSwitchDelay.IsEnabled = true;

            // follow track
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
            {
                ViewDetails tl = GetCurrentTrackList();
                if (tl == null) return;

                ListViewItem lvi = tl.ItemContainerGenerator.ContainerFromItem(e.OldTrack) as ListViewItem;
                if (lvi != null)
                {
                    Point trackLoc = lvi.TranslatePoint(new Point(0, 0), tl);
                    double trackListHeight = tl.ActualHeight;
                    double trackHeight = lvi.ActualHeight;

                    if (trackLoc.Y + trackHeight > 0 || trackLoc.Y <= trackListHeight)
                        tl.ScrollIntoView(MediaManager.GetSourceTrack(e.NewTrack));
                }
            }));
        }
Esempio n. 2
0
        /// <summary>
        /// Invoked after a short delay when a track is switched to.
        /// </summary>
        /// <param name="e">The event data</param>
        private void MediaManager_TrackSwitchedDelayed(TrackSwitchedEventArgs e)
        {
            if (trackSwitchDelay != null)
                trackSwitchDelay.Stop();

            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
            {
                if (trayIcon != null) ((TrayToolTip)trayIcon.TrayToolTip).SetTrack(e.NewTrack);

                if (SettingsManager.ShowOSD)
                {
                    TrayNotification notification = new TrayNotification(e.NewTrack, this);
                    if (trayIcon != null)
                        trayIcon.ShowCustomBalloon(notification, System.Windows.Controls.Primitives.PopupAnimation.Fade, 4000);
                }

                JumpTask jumpTask = new JumpTask()
                {
                    Title = e.NewTrack.Artist + " - " + e.NewTrack.Title,
                    Arguments = e.NewTrack.Path,
                    Description = e.NewTrack.Artist + " - " + e.NewTrack.Title,
                    IconResourcePath = "C:\\Windows\\System32\\imageres.dll",
                    IconResourceIndex = 190,
                    ApplicationPath = Assembly.GetEntryAssembly().CodeBase,
                };

                System.Windows.Shell.JumpList.AddToRecentCategory(jumpTask);
            }));
        }
Esempio n. 3
0
        /// <summary>
        /// Invoked when the media manager switches from one track to another
        /// </summary>
        /// <param name="e">The event data</param>
        private void MediaManager_TrackSwitched(TrackSwitchedEventArgs e)
        {
            trackSwitchDelay.Change(1000, Timeout.Infinite);

            // follow track
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
            {
                ViewDetails tl = GetCurrentTrackList();
                if (tl == null) return;

                ListViewItem lvi = tl.ItemContainerGenerator.ContainerFromItem(e.OldTrack) as ListViewItem;
                if (lvi != null)
                {
                    Point trackLoc = lvi.TranslatePoint(new Point(0, 0), tl);
                    double trackListHeight = tl.ActualHeight;
                    double trackHeight = lvi.ActualHeight;

                    if (trackLoc.Y + trackHeight > 0 || trackLoc.Y <= trackListHeight)
                        tl.ScrollIntoView(MediaManager.GetSourceTrack(e.NewTrack));
                }
            }));
        }