Đồ hoạ, đa phương tiện ( Mutilmedia) và In ấn Đồ họa phần cuối
Số trang: 10
Loại file: pdf
Dung lượng: 166.81 KB
Lượt xem: 5
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
(Bỏ qua phần mã designer.) private void PrintQueueTest_Load(object sender, System.EventArgs e) { cmdRefresh_Click(null, null); } private void cmdRefresh_Click(object sender, System.EventArgs e)
Nội dung trích xuất từ tài liệu:
Đồ hoạ, đa phương tiện ( Mutilmedia) và In ấn Đồ họa phần cuốiusing System;using System.Windows.Forms;using System.Management;using System.Collections;public class PrintQueueTest : System.Windows.Forms.Form { private System.Windows.Forms.ListBox lstJobs; private System.Windows.Forms.Button cmdRefresh; private System.Windows.Forms.TextBox txtJobInfo; private System.Windows.Forms.Button cmdPause; private System.Windows.Forms.Button cmdResume; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; // (Bỏ qua phần mã designer.) private void PrintQueueTest_Load(object sender, System.EventArgs e) { cmdRefresh_Click(null, null); } private void cmdRefresh_Click(object sender, System.EventArgs e) { // Chọn tất cả các tác vụ in đang chờ. string query = SELECT * FROM Win32_PrintJob; ManagementObjectSearcher jobQuery = new ManagementObjectSearcher(query); ManagementObjectCollection jobs = jobQuery.Get(); // Thêm các tác vụ trong hàng đợi vào ListBox. lstJobs.Items.Clear(); txtJobInfo.Text = ; foreach (ManagementObject job in jobs) { lstJobs.Items.Add(job[JobID]); } } // Phương thức này thực hiện truy vấn WMI và trả về // tác vụ WMI cho item hiện đang được chọn trong ListBox.private ManagementObject GetSelectedJob() { try { // Chọn tác vụ in phù hợp. string query = SELECT * FROM Win32_PrintJob + WHERE JobID= + lstJobs.Text + ; ManagementObjectSearcher jobQuery = new ManagementObjectSearcher(query); ManagementObjectCollection jobs = jobQuery.Get(); IEnumerator enumerator = jobs.GetEnumerator(); enumerator.MoveNext(); return (ManagementObject)enumerator.Current; }catch (InvalidOperationException){ // Thuộc tính Current của enumerator không hợp lệ return null; }}private void lstJobs_SelectedIndexChanged(object sender, System.EventArgs e) { ManagementObject job = GetSelectedJob(); if (job == null) { txtJobInfo.Text = ; return; } // Hiển thị thông tin về tác vụ. string jobInfo = Document: + job[Document].ToString(); jobInfo += Environment.NewLine; jobInfo += DriverName: + job[DriverName].ToString(); jobInfo += Environment.NewLine; jobInfo += Status: + job[Status].ToString(); jobInfo += Environment.NewLine; jobInfo += Owner: + job[Owner].ToString(); 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.); }} private void cmdResume_Click(object sender, System.EventArgs e) { if (lstJobs.SelectedIndex == -1) return; ManagementObject job = GetSelectedJob(); if (job == null) return; if ((Int32.Parse(job[StatusMask].ToString()) & 1) == 1) { // Phục hồi tác vụ. int returnValue = Int32.Parse( job.InvokeMethod(Resume, null).ToString()); // Hiển thị thông tin về giá trị trả về. if (returnValue == 0) { MessageBox.Show(Successfully resumed job.); }else if (returnValue == 5) { MessageBox.Show(Access denied.); }else { MessageBox.Show( Unrecognized return value when resuming job.); } } }} The image part with relationship ID rId5 was not found in the file. Hình 8.14 Lấy thông tin từ hàng đợi inNhớ rằng các quyền Windows có thể ngăn bạn tạm dừng hoặc gỡ bỏ một tác vụ in do mộtngười dùng khác tạo ra. Thực ra, các quyền này còn có thể ngăn bạn lấy thông tin trạngthái và có thể gây ra ngoại lệ. Các phương thức WMI khác mà bạn có thể sử dụng trong một kịch bản in bao gồm AddPrinterConnection, SetDefaultPrinter, CancelAllJobs, và PrintTestPage, tất cả đều làm việc với lớp Win32_Printer. Để có thêm thông t ...
Nội dung trích xuất từ tài liệu:
Đồ hoạ, đa phương tiện ( Mutilmedia) và In ấn Đồ họa phần cuốiusing System;using System.Windows.Forms;using System.Management;using System.Collections;public class PrintQueueTest : System.Windows.Forms.Form { private System.Windows.Forms.ListBox lstJobs; private System.Windows.Forms.Button cmdRefresh; private System.Windows.Forms.TextBox txtJobInfo; private System.Windows.Forms.Button cmdPause; private System.Windows.Forms.Button cmdResume; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; // (Bỏ qua phần mã designer.) private void PrintQueueTest_Load(object sender, System.EventArgs e) { cmdRefresh_Click(null, null); } private void cmdRefresh_Click(object sender, System.EventArgs e) { // Chọn tất cả các tác vụ in đang chờ. string query = SELECT * FROM Win32_PrintJob; ManagementObjectSearcher jobQuery = new ManagementObjectSearcher(query); ManagementObjectCollection jobs = jobQuery.Get(); // Thêm các tác vụ trong hàng đợi vào ListBox. lstJobs.Items.Clear(); txtJobInfo.Text = ; foreach (ManagementObject job in jobs) { lstJobs.Items.Add(job[JobID]); } } // Phương thức này thực hiện truy vấn WMI và trả về // tác vụ WMI cho item hiện đang được chọn trong ListBox.private ManagementObject GetSelectedJob() { try { // Chọn tác vụ in phù hợp. string query = SELECT * FROM Win32_PrintJob + WHERE JobID= + lstJobs.Text + ; ManagementObjectSearcher jobQuery = new ManagementObjectSearcher(query); ManagementObjectCollection jobs = jobQuery.Get(); IEnumerator enumerator = jobs.GetEnumerator(); enumerator.MoveNext(); return (ManagementObject)enumerator.Current; }catch (InvalidOperationException){ // Thuộc tính Current của enumerator không hợp lệ return null; }}private void lstJobs_SelectedIndexChanged(object sender, System.EventArgs e) { ManagementObject job = GetSelectedJob(); if (job == null) { txtJobInfo.Text = ; return; } // Hiển thị thông tin về tác vụ. string jobInfo = Document: + job[Document].ToString(); jobInfo += Environment.NewLine; jobInfo += DriverName: + job[DriverName].ToString(); jobInfo += Environment.NewLine; jobInfo += Status: + job[Status].ToString(); jobInfo += Environment.NewLine; jobInfo += Owner: + job[Owner].ToString(); 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.); }} private void cmdResume_Click(object sender, System.EventArgs e) { if (lstJobs.SelectedIndex == -1) return; ManagementObject job = GetSelectedJob(); if (job == null) return; if ((Int32.Parse(job[StatusMask].ToString()) & 1) == 1) { // Phục hồi tác vụ. int returnValue = Int32.Parse( job.InvokeMethod(Resume, null).ToString()); // Hiển thị thông tin về giá trị trả về. if (returnValue == 0) { MessageBox.Show(Successfully resumed job.); }else if (returnValue == 5) { MessageBox.Show(Access denied.); }else { MessageBox.Show( Unrecognized return value when resuming job.); } } }} The image part with relationship ID rId5 was not found in the file. Hình 8.14 Lấy thông tin từ hàng đợi inNhớ rằng các quyền Windows có thể ngăn bạn tạm dừng hoặc gỡ bỏ một tác vụ in do mộtngười dùng khác tạo ra. Thực ra, các quyền này còn có thể ngăn bạn lấy thông tin trạngthái và có thể gây ra ngoại lệ. Các phương thức WMI khác mà bạn có thể sử dụng trong một kịch bản in bao gồm AddPrinterConnection, SetDefaultPrinter, CancelAllJobs, và PrintTestPage, tất cả đều làm việc với lớp Win32_Printer. Để có thêm thông t ...
Tìm kiếm theo từ khóa liên quan:
công nghệ thông tin kĩ thuật lập trình ngôn ngữ lập trình ngôn ngữ C# C# Đồ hoạ đa phương tiện ( Mutilmedia) và In ấn Đồ họa phần cuốiGợi ý tài liệu liên quan:
-
52 trang 430 1 0
-
Top 10 mẹo 'đơn giản nhưng hữu ích' trong nhiếp ảnh
11 trang 316 0 0 -
74 trang 301 0 0
-
96 trang 293 0 0
-
Báo cáo thực tập thực tế: Nghiên cứu và xây dựng website bằng Wordpress
24 trang 289 0 0 -
Đồ án tốt nghiệp: Xây dựng ứng dụng di động android quản lý khách hàng cắt tóc
81 trang 281 0 0 -
Giáo trình Lập trình hướng đối tượng: Phần 2
154 trang 276 0 0 -
EBay - Internet và câu chuyện thần kỳ: Phần 1
143 trang 275 0 0 -
Tài liệu dạy học môn Tin học trong chương trình đào tạo trình độ cao đẳng
348 trang 269 1 0 -
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 266 0 0