Example #1
0
 /// <summary>
 /// Sets the progress state of the specified window's
 /// taskbar button.
 /// </summary>
 /// <param name="hwnd">The window handle.</param>
 /// <param name="state">The progress state.</param>
 public static void SetProgressState(IntPtr hwnd, ProgressState state)
 {
     if (Windows7OrGreater)
     {
         Taskbar.SetProgressState(hwnd, state);
     }
 }
Example #2
0
        void RunTask(ListViewItem item)
        {
            if (Downloader.Count < AppConfig.Settings.MaxDownloaders)
            {
                var downloader = new Downloader();
                downloader.ProgressChanged    += downloader_ProgressChanged;
                downloader.RunWorkerCompleted += downloader_RunWorkerCompleted;
                downloader.Tag      = item;
                downloader.FileName = item.SubItems[ITEM_NAME].Text;
                downloader.SavePath = FBD.SelectedPath;
                downloader.RunWorkerAsync(item.Name);
                Taskbar.SetProgressState(TaskbarState.Normal);

                item.ImageIndex = 1;
                item.Tag        = downloader;

                Util.PreventSleep();
            }
        }
        private void PlayerStateChanged(object sender, PlayerStateEventArgs e)
        {
            switch (e.NewState)
            {
            case PlayerState.Closed:
                Taskbar.SetProgressState(TaskbarProgressBarState.NoProgress);
                m_UpdateTimer.Stop();
                s_PlayPauseButton.Icon    = s_PlayIcon;
                s_PlayPauseButton.Tooltip = TEXT_PLAY;
                Taskbar.SetOverlayIcon(m_MpdnFormHandle, null, "");
                break;

            case PlayerState.Stopped:
                Taskbar.SetProgressState(TaskbarProgressBarState.NoProgress);
                m_UpdateTimer.Start();
                s_PlayPauseButton.Icon    = s_PlayIcon;
                s_PlayPauseButton.Tooltip = TEXT_PLAY;
                Taskbar.SetOverlayIcon(m_MpdnFormHandle, null, "");
                break;

            case PlayerState.Playing:
                Taskbar.SetProgressState(TaskbarProgressBarState.Normal);
                m_UpdateTimer.Start();
                s_PlayPauseButton.Icon    = s_PauseIcon;
                s_PlayPauseButton.Tooltip = TEXT_PAUSE;
                Taskbar.SetOverlayIcon(m_MpdnFormHandle, s_PlayOverlayIcon, "Playing");
                break;

            case PlayerState.Paused:
                Taskbar.SetProgressState(TaskbarProgressBarState.Paused);
                m_UpdateTimer.Start();
                s_PlayPauseButton.Icon    = s_PlayIcon;
                s_PlayPauseButton.Tooltip = TEXT_PLAY;
                Taskbar.SetOverlayIcon(m_MpdnFormHandle, s_PauseOverlayIcon, "Paused");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 private void MediaLoaded(object sender, EventArgs eventArgs)
 {
     Taskbar.SetProgressState(TaskbarProgressBarState.Paused);
     m_UpdateTimer.Start();
 }
Example #5
0
        void downloader_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (!Program.IsClosing)
            {
                var downloader = sender as Downloader;

                if (e.Error != null)
                {
                    Log(Resources.Error + e.Error.Message, sender);
                }
                else if (e.Cancelled)
                {
                    Log(Resources.DownloadCancelled, sender);
                }
                else if (e.Result is String)
                {
                    string s = e.Result as string;
                    if (s.StartsWith("http", StringComparison.Ordinal))
                    {
                        Log("=> " + s, sender);
                        if (AppConfig.Settings.ExternalMethod == 0)
                        {
                            Clipboard.SetText(s);                               // Copy URL
                        }
                        else
                        {
                            try {
                                Process.Start(AppConfig.Settings.ExternalDownloader, s);                                  // Run Program ...
                            } catch (Exception ex) {
                                Log(Resources.Error + ex.Message);
                            }
                        }
                    }
                }
                else
                {
                    Log(Resources.DownloadCompleted, sender);
                    if (!Visible)
                    {
                        Tray.ShowBalloonTip(3000, Resources.DownloadCompleted,
                                            (downloader.Tag as ListViewItem).SubItems[ITEM_NAME].Text, ToolTipIcon.Info);
                    }
                    //Util.FlashWindow(Handle, 3);
                }

                TaskList.Items.Remove(downloader.Tag as ListViewItem);
                downloader.Dispose();

                if (TaskList.Items.Count > 0)
                {
                    RunTasks();
                }
                else // all tasks completed
                {
                    if (Visible)
                    {
                        Util.FlashWindow(Handle, 0);
                    }
                    else
                    {
                        Tray.ShowBalloonTip(5000, Resources.DownloadCompleted, Text, ToolTipIcon.Info);
                    }
                    Taskbar.SetProgressState(TaskbarState.NoProgress);
                    if (miShutdown.Checked && !e.Cancelled)
                    {
                        Process.Start("shutdown.exe", "-r -f");
                    }
                    Util.ResotreSleep();
                }
            }
        }