views:

392

answers:

3

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

+3  A: 

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.

confusedGeek
A: 

Thanks for the tip Neil.

I can get the Taskbar to show progress when navigating or a file is copied in the Common File Dialog, i just can't get it to catch the download progress.

I've tried IFileOperation, which according to some blogs i've read should pick it up automatically, also i've tried IProgressOperation with no success.

I've posted on the Windows API Website, but as i'm using VS 2010 Net 4.0 Shell now handles the TaskBar except the Tabbed Thumbnails which is handled by the Microsoft API Pack.

Appreciate any help, if i find a solution i will post the info.

Thanks.

Dev
It isn't clear here whether you are asking how to get the progress information from the WebBrowser control or how to put it in the taskbar. Please let us know which you are looking for. And if you have some existing code that works for navigating or file copying, please post it so we have some idea what you are doing.
Ray Burns
A: 

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:

PopulateJumpList();

        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

Dev