共用方式為


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)

初始化 PrintBooleanProperty 類別的新執行個體,使其具有指定屬性。

PrintBooleanProperty(String, Object)

初始化 PrintBooleanProperty 類別的新執行個體,使其具有正在使用指定值的指定屬性。

屬性

IsDisposed

取得或設定一個值,指出是否已經處置物件。

(繼承來源 PrintProperty)
IsInitialized

取得或設定值,這個值表示物件是否已經初始化。

(繼承來源 PrintProperty)
Name

在衍生類別 (Derived Class) 中覆寫時,會取得物件所表示屬性的名稱。

(繼承來源 PrintProperty)
Value

取得或設定 PrintBooleanProperty 表示的屬性值。

方法

Dispose()

釋放 PrintProperty 正在使用的所有資源。

(繼承來源 PrintProperty)
Dispose(Boolean)

釋放 PrintProperty 正在使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 PrintProperty)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
InternalDispose(Boolean)

釋放 PrintProperty 正在使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 PrintProperty)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnDeserialization(Object)

在衍生類別中覆寫時,如果還原序列化 (Deserialization) 完成,則實作 ISerializable 介面,並引發還原序列化事件。

(繼承來源 PrintProperty)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

運算子

Implicit(PrintBooleanProperty to Boolean)

提供由指標的 BooleanPrintBooleanProperty 的隱含轉換。

適用於