PrintBooleanProperty 类

定义

表示 Boolean 打印系统硬件或软件组件的属性(及其值)。

public ref class PrintBooleanProperty sealed : System::Printing::IndexedProperties::PrintProperty
public sealed class PrintBooleanProperty : System.Printing.IndexedProperties.PrintProperty
type PrintBooleanProperty = class
    inherit PrintProperty
Public NotInheritable Class PrintBooleanProperty
Inherits PrintProperty
继承
PrintBooleanProperty

示例

以下示例演示如何在安装第二台打印机时使用此类,该打印机的属性仅在位置、端口和共享状态中与现有打印机不同。

LocalPrintServer myLocalPrintServer = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);
PrintQueue sourcePrintQueue = myLocalPrintServer.DefaultPrintQueue;
PrintPropertyDictionary myPrintProperties = sourcePrintQueue.PropertiesCollection;

// Share the new printer using Remove/Add methods
PrintBooleanProperty shared = new PrintBooleanProperty("IsShared", true);
myPrintProperties.Remove("IsShared");
myPrintProperties.Add("IsShared", shared);

// Give the new printer its share name using SetProperty method
PrintStringProperty theShareName = new PrintStringProperty("ShareName", "\"Son of " + sourcePrintQueue.Name +"\"");
myPrintProperties.SetProperty("ShareName", theShareName);

// Specify the physical location of the new printer using Remove/Add methods
PrintStringProperty theLocation = new PrintStringProperty("Location", "the supply room");
myPrintProperties.Remove("Location");
myPrintProperties.Add("Location", theLocation);

// Specify the port for the new printer
String[] port = new String[] { "COM1:" };

// Install the new printer on the local print server
PrintQueue clonedPrinter = myLocalPrintServer.InstallPrintQueue("My clone of " + sourcePrintQueue.Name, "Xerox WCP 35 PS", port, "WinPrint", myPrintProperties);
myLocalPrintServer.Commit();

// Report outcome
Console.WriteLine("{0} in {1} has been installed and shared as {2}", clonedPrinter.Name, clonedPrinter.Location, clonedPrinter.ShareName);
Console.WriteLine("Press Return to continue ...");
Console.ReadLine();
Dim myLocalPrintServer As New LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer)
Dim sourcePrintQueue As PrintQueue = myLocalPrintServer.DefaultPrintQueue
Dim myPrintProperties As PrintPropertyDictionary = sourcePrintQueue.PropertiesCollection

' Share the new printer using Remove/Add methods
Dim [shared] As New PrintBooleanProperty("IsShared", True)
myPrintProperties.Remove("IsShared")
myPrintProperties.Add("IsShared", [shared])

' Give the new printer its share name using SetProperty method
Dim theShareName As New PrintStringProperty("ShareName", """Son of " & sourcePrintQueue.Name & """")
myPrintProperties.SetProperty("ShareName", theShareName)

' Specify the physical location of the new printer using Remove/Add methods
Dim theLocation As New PrintStringProperty("Location", "the supply room")
myPrintProperties.Remove("Location")
myPrintProperties.Add("Location", theLocation)

' Specify the port for the new printer
Dim port() As String = { "COM1:" }


' Install the new printer on the local print server
Dim clonedPrinter As PrintQueue = myLocalPrintServer.InstallPrintQueue("My clone of " & sourcePrintQueue.Name, "Xerox WCP 35 PS", port, "WinPrint", myPrintProperties)
myLocalPrintServer.Commit()

' Report outcome
Console.WriteLine("{0} in {1} has been installed and shared as {2}", clonedPrinter.Name, clonedPrinter.Location, clonedPrinter.ShareName)
Console.WriteLine("Press Return to continue ...")
Console.ReadLine()

构造函数

名称 说明
PrintBooleanProperty(String, Object)

为使用指定值的指定属性初始化类的新实例 PrintBooleanProperty

PrintBooleanProperty(String)

初始化指定属性的 PrintBooleanProperty 类的新实例。

属性

名称 说明
IsDisposed

获取或设置一个值,该值指示对象是否已释放。

(继承自 PrintProperty)
IsInitialized

获取或设置一个值,该值指示对象是否已初始化。

(继承自 PrintProperty)
Name

在派生类中重写时,获取对象所表示的属性的名称。

(继承自 PrintProperty)
Value

获取或设置表示的属性 PrintBooleanProperty 的值。

方法

名称 说明
Dispose()

释放由 <a0/a0> 使用的所有资源。

(继承自 PrintProperty)
Dispose(Boolean)

释放由 PrintProperty 托管资源使用的非托管资源,并选择性地释放托管资源。

(继承自 PrintProperty)
Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
InternalDispose(Boolean)

释放由 PrintProperty 托管资源使用的非托管资源,并选择性地释放托管资源。

(继承自 PrintProperty)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
OnDeserialization(Object)

在派生类中重写时,实现 ISerializable 接口并在反序列化完成时引发反序列化事件。

(继承自 PrintProperty)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

运营商

名称 说明
Implicit(PrintBooleanProperty to Boolean)

提供从指针到 a Boolean . 的 PrintBooleanProperty隐式转换。

适用于