Csharp/C Sharp/GUI Windows Form/PrinterSettings — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 15:31, 26 мая 2010

InstalledPrinters

 
using System;
using System.Drawing.Printing;
class MainClass {
    static void Main(string[] args) {
        foreach (string printerName in PrinterSettings.InstalledPrinters) {
            Console.WriteLine("Printer: {0}", printerName);
        }
    }
}


PrinterName, IsValid printer

 
using System;
using System.Drawing.Printing;
class MainClass {
    static void Main(string[] args) {
        foreach (string printerName in PrinterSettings.InstalledPrinters) {
            Console.WriteLine("Printer: {0}", printerName);
            PrinterSettings printer = new PrinterSettings();
            printer.PrinterName = printerName;
            Console.WriteLine(printer.IsValid);
        }
    }
}


PrinterResolutions

 

using System;
using System.Drawing.Printing;
class MainClass {
    static void Main(string[] args) {
        foreach (string printerName in PrinterSettings.InstalledPrinters) {
            Console.WriteLine("Printer: {0}", printerName);
            PrinterSettings printer = new PrinterSettings();
            printer.PrinterName = printerName;
            if (printer.IsValid) {
                Console.WriteLine("Supported Resolutions:");
                foreach (PrinterResolution resolution in printer.PrinterResolutions) {
                    Console.WriteLine("  {0}", resolution);
                }
            }
        }
    }
}


PrinterSettings.Kind

 
using System;
using System.Drawing.Printing;
class MainClass {
    static void Main(string[] args) {
        foreach (string printerName in PrinterSettings.InstalledPrinters) {
            Console.WriteLine("Printer: {0}", printerName);
            PrinterSettings printer = new PrinterSettings();
            printer.PrinterName = printerName;
            if (printer.IsValid) {
                Console.WriteLine("Supported Paper Sizes:");
                foreach (PaperSize size in printer.PaperSizes) {
                    if (Enum.IsDefined(size.Kind.GetType(), size.Kind)) {
                        Console.WriteLine("  {0}", size);
                    }
                }
            }
        }
    }
}