找传奇、传世资源到传世资源站!

C# 设置任务栏图标的进度(类似下载进度提示)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

from clipboardusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;//需要添加的命名空间using Microsoft.WindowsAPICodePack.Shell;using Microsoft.WindowsAPICodePack.Taskbar;namespace WindowsAPICodePackTest{ public partial class FormMain : Form { private TaskbarManager windowsTaskbar = TaskbarManager.Instance; public FormMain() { InitializeComponent(); } /// <summary> /// Load函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FormMain_Load(object sender, EventArgs e) { //初始化界面和进度条 cmbProgressStatus.Text = "Normal"; windowsTaskbar.SetProgressState(TaskbarProgressBarState.Normal, this.Handle); windowsTaskbar.SetProgressValue(0, 100, this.Handle); } /// <summary> /// 设置进度条进度 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSetProgress_Click(object sender, EventArgs e) { int progress = 0; int.TryParse(txtProgress.Text, out progress); progress = progress < 0 ? 0 : progress; progress = progress > 100 ? 100 : progress; //设置进度条进度 windowsTaskbar.SetProgressValue(progress, 100, this.Handle); } /// <summary> /// 设置进度条状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSetProgressStatus_Click(object sender, EventArgs e) { TaskbarProgressBarState progressState = TaskbarProgressBarState.Normal; switch (cmbProgressStatus.Text) { case "NoProgress": { progressState = TaskbarProgressBarState.NoProgress; } break; case "Indeterminate": { progressState = TaskbarProgressBarState.Indeterminate; } break; case "Normal": { progressState = TaskbarProgressBarState.Normal; } break; case "Error": { progressState = TaskbarProgressBarState.Error; } break; case "Paused": { progressState = TaskbarProgressBarState.Paused; } break; } windowsTaskbar.SetProgressState(progressState, this.Handle); } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复