C#中的打印机管理器 [英] Printer manager in C#

查看:89
本文介绍了C#中的打印机管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3台打印机,而且,我想要打印很多文件,所以,我想知道,我怎么能制作一个简单的系统来管理这台打印机,我知道这个基础,但是,我想知道知道,我如何打印机打印并继续验证,以便在另一台打印机上打印更多文件...所以,基本上我的意思是:



< pre lang =c#> private void printer()
{
< span class =code-keyword> int number = 0 ;
GetPrintStatus gps = new GetPrintStatus();
for int i = 0 ; i < 5 ; i ++)
{
如果(数字> 4
number = 0 ;
gps.SetPrinter = string .Format( HP - {0},数字);
switch (gps.ToString())
{
case HP - 0
if (gps.Status!= status.Enable)
gps.print( 1.pdf );
break ;

case HP - 1
if (gps.Status!= status.Enable)
gps.print( 1.pdf);
break ;

case HP - 2
if (gps.Status!= status.Enable)
gps.print( 1.pdf);
break ;

case HP - 3
if (gps.Status!= status.Enable)
gps.print( 1.pdf);
break ;

case HP - 4
if (gps.Status!= status.Enable)
gps.print( 1.pdf);
break ;
}
}





好​​的,但是,代码转到:gps.print ,代码停在那里,然后,当打印机返回正常时继续....但是,我怎么做,代码继续?

解决方案

请参阅我的评论问题。



我真的认为你有更严重的问题。在已经是字符串的对象上调用 ToString 。用完全相同的数据重复完全相同的代码5次。 (从未听说过抽象?方法?方法参数?不要重复自己的原则?)你的奇怪认为你总是有5台打印机,而不是2台,而不是6台,以及你准备好为5台打印机专门编写代码......



这没有任何意义,但即使有某种意义......如果我有一些问题,我会忘记打印。为什么要浪费时间?



-SA


I have 3 printers, and, I whant to print a lot of files, so, I whant to know, how I can make a little and simple system to manage this printers, the base I know, but, I whant to know, How I can make the printer print and continue with verification to put more files to print in another printer... so, basicly what I mean is:

private void printer()
{
    int number = 0;
    GetPrintStatus gps = new GetPrintStatus();
    for (int i = 0; i < 5; i++)
    {
        if (number > 4)
            number = 0;
        gps.SetPrinter = string.Format("HP - {0}", number);
        switch (gps.ToString())
        {
            case "HP - 0":
                if (gps.Status != status.Enable)
                    gps.print("1.pdf");
                break;

            case "HP - 1":
                if (gps.Status != status.Enable)
                    gps.print("1.pdf");
                break;

            case "HP - 2":
                if (gps.Status != status.Enable)
                    gps.print("1.pdf");
                break;

            case "HP - 3":
                if (gps.Status != status.Enable)
                    gps.print("1.pdf");
                break;

            case "HP - 4":
                if (gps.Status != status.Enable)
                    gps.print("1.pdf");
                break;
        }
    }



OK, But, when the code go to: gps.print, to code stop there, and, continue when the printer return ok.... but, how I can do, to code continue ?

解决方案

Please see my comment to the question.

I really think you have more serious problems. Calling ToString on the object which is already a string. Repeating totally identical code with almost identical data 5 times. (Never heard of abstractions? Method? Method parameters? Don''t Repeat Yourself principle?) Your strange believe that you will always have 5 printers, not 2, not 6, as well as your readiness to write code specifically for 5 printers…

It makes no sense, but even if there was some sense… If I had some of your problems, I would forget about printing at all. Why wasting time?

—SA


这篇关于C#中的打印机管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆