Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 7 Taskbar progress

Quick question, I've developed a Forum specific C# WPF WebBrowser, for Windows 7.

I have completed so far for the Taskbar:

Tabbed thumbnails

Jumplists

Icon Overlay

Now as the WebBrowser uses the IE engine when a download is started the progress dialog is displayed, what i want is for the progress to be reflected in the Taskbar Button of my application.

Is this acheivable? Thanks

like image 596
Dev Avatar asked Nov 18 '09 19:11

Dev


2 Answers

I believe this is something that Scott Hanselman covered in one of his weekly source code blogs.

Not sure if that was what you were looking for or not.

like image 111
Ken Henderson Avatar answered Oct 14 '22 00:10

Ken Henderson


I know how to put it in the Taskbar, i just need to catch the download progress so i can show the progress in the taskbar. Heres a snippet of how i get it to show navigation, the file copy is displayed without the need for code, shell is picking that up automatically.

  #region Background Worker

    void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        this.TaskbarItemInfo.ProgressValue = (double)e.ProgressPercentage / 100;

    }

    void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        if (e.Cancelled == true)
        {
            this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Paused;
        }
        else if (e.Error != null)
        {
            this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Error;
        }
        else
        {
            this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
        }
    }

    void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
        for (int i = 1; i <= 100; i++)
        {
            Thread.Sleep(100);

            this.backgroundWorker1.ReportProgress(i,i.ToString());
        }
            }
        }
    }

    #endregion

All thats needed for the Navigation is:

 private void Browser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
    {
        if (backgroundWorker1.IsBusy == false)
        {
            backgroundWorker1.RunWorkerAsync();

            TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal;
        }

        if (tabControl1.TabPages.Count > 10 && tabControl1.SelectedTab != null)
            UpdatePreviewBitmap(tabControl1.SelectedTab);

And taken from the Window Load Event:

        this.backgroundWorker1.WorkerReportsProgress = true;
        this.backgroundWorker1.WorkerSupportsCancellation = true;
        this.backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
        this.backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
        this.backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);

        //
        TabbedThumbnail preview = new TabbedThumbnail(this.Handle, tabPage.Handle);
        //
        preview.TabbedThumbnailActivated += new EventHandler<TabbedThumbnailEventArgs>(preview_TabbedThumbnailActivated);
        preview.TabbedThumbnailClosed += new EventHandler<TabbedThumbnailEventArgs>(preview_TabbedThumbnailClosed);
        preview.TabbedThumbnailMaximized += new EventHandler<TabbedThumbnailEventArgs>(preview_TabbedThumbnailMaximized);
        preview.TabbedThumbnailMinimized += new EventHandler<TabbedThumbnailEventArgs>(preview_TabbedThumbnailMinimized);
        //
        TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(preview);
        //
        tabControl1.SelectedTab = tabPage;
        TaskbarManager.Instance.TabbedThumbnail.SetActiveTab(tabControl1.SelectedTab);
        //

        scrollEventAdded = false;

Hope this makes sense. Thanks

like image 25
Dev Avatar answered Oct 14 '22 02:10

Dev