PrintBooleanProperty 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示打印系统硬件或软件组件的 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
- 继承
示例
以下示例演示如何在安装属性与现有打印机不同的第二台打印机时使用此类,该打印机仅在位置、端口和共享状态上。
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) |
为指定的特性初始化 PrintBooleanProperty 类的一个新实例。 |
PrintBooleanProperty(String, Object) |
为使用指定值的指定属性初始化PrintBooleanProperty 类一个的新实例。 |
属性
IsDisposed |
获取或设置一个值,该值指示该对象是否已被释放。 (继承自 PrintProperty) |
IsInitialized |
获取或设置一个值,该值指示该对象是否已初始化。 (继承自 PrintProperty) |
Name |
在派生类中重写时,获取该对象表示的属性的名称。 (继承自 PrintProperty) |
Value |
获取或设置 PrintBooleanProperty 表示的属性的值。 |
方法
Dispose() |
释放正在由 PrintProperty 使用的所有资源。 (继承自 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) |
提供从指向 Boolean 的指针到 PrintBooleanProperty 的隐式转换。 |