336
Chương 8: Đồ họa, đa phương tiện, và in ấn
jobInfo += Environment.NewLine;
jobInfo += "PagesPrinted: " +
job["PagesPrinted"].ToString();
jobInfo += Environment.NewLine;
jobInfo += "TotalPages: " + job["TotalPages"].ToString();
if (job["JobStatus"] != null) {
txtJobInfo.Text += Environment.NewLine;
txtJobInfo.Text += "JobStatus: " +
job["JobStatus"].ToString();
}
if (job["StartTime"] != null) {
jobInfo += Environment.NewLine;
jobInfo += "StartTime: " + job["StartTime"].ToString();
}
txtJobInfo.Text = jobInfo;
}
private void cmdPause_Click(object sender, System.EventArgs e) {
if (lstJobs.SelectedIndex == -1) return;
ManagementObject job = GetSelectedJob();
if (job == null) return;
// Tạm dừng tác vụ.
int returnValue = Int32.Parse(
job.InvokeMethod("Pause", null).ToString());
// Hiển thị thông tin về giá trị trả về.
if (returnValue == 0) {
MessageBox.Show("Successfully paused job.");
}else {
MessageBox.Show(
"Unrecognized return value when pausing job.");