我正在尝试修改文件读取应用程序,使其在工具栏图标中具有 Windows 7 绿色进度条。我似乎没有运气,想知道你必须做什么才能让它与 WinForms 一起工作?
这是我尝试过的简单版本:
using System;
using System.Windows.Forms;
using System.Windows.Shell; // add reference to "PresentationFramework" & "WindowsBase"
namespace Test
{
public partial class Form1 : Form
{
public TaskbarItemInfo TaskbarItemInfo { get; set; }
public Form1()
{
InitializeComponent();
this.TaskbarItemInfo = new TaskbarItemInfo();
}
private void button1_Click(Object sender, EventArgs e)
{
this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal;
for (int n = 0; n < 100; n++)
{
if (this.TaskbarItemInfo.CheckAccess() == true) // needs to be on creating thread
{
this.TaskbarItemInfo.ProgressValue = n / 100d;
}
System.Threading.Thread.Sleep(100);
}
this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
}
}
}
我猜我必须(以某种方式)将 TaskbarItemInfo 实例挂接到表单,或者挂接到“System.Windows.Window”?
谢谢,