4.8. StarPrintPortJobMonitor

プリンタードライバのジョブを監視します。

重要

本クラスは、プリンタドライバ経由で印刷を行う場合に使用できます。

  • コンストラクタ

    名称

    説明

    StarPrintPortJobMonitor

    StarPrintPortJobMonitorオブジェクトを生成します。

  • プロパティ

    名称

    説明

    PortName

    StarPrintPortJobMonitorコンストラクタで指定したポート名を取得します。

    JobCount

    プリンタポートに紐ついているプリンタキューのジョブ数を取得します。

    PrintQueues

    プリンタポートに紐ついているPrintQueueオブジェクトを取得します。

  • メソッド

    名称

    説明

    Start

    プリンタポートに紐ついているプリンタキューのジョブ監視を開始します。

    Stop

    プリンタポートに紐ついているプリンタキューのジョブ監視を停止します。

  • イベント

    名称

    説明

    PrintQueueJobIsAdded

    プリンタポートに紐ついているプリンタキューにジョブが追加されたときに発生します。

    PrintQueueJobIsRemoved

    プリンタポートに紐ついているプリンタキューのジョブが減ったときに発生します。

    PrintQueueAllJobsAreCompleted

    プリンタポートに紐ついているプリンタキューから全てのジョブが無くなったときに発生します。

4.8.1. StarPrintPortJobMonitor

StarPrintPortJobMonitorオブジェクトを生成します。

  • 宣言

    public StarPrintPortJobMonitor(string portName)
    
  • 引数

    名称

    説明

    portName

    プリンタキューのプリンタポート名
    GetPort メソッドのportNameパラメータと同じです。

    string

  • 戻り値

    説明

    StarPrintPortJobMonitorオブジェクト

    StarPrintPortJobMonitor

  • 実装例

    private void SetStarPrintPortJobMonitor()
    {
        starPrintPortJobMonitor = new StarPrintPortJobMonitor("BT:COM1");
    
        starPrintPortJobMonitor.PrintQueueJobIsAdded += OnPrintQueueJobIsAdded;
        starPrintPortJobMonitor.PrintQueueJobIsRemoved += OnPrintQueueJobIsRemoved;
        starPrintPortJobMonitor.PrintQueueAllJobsAreCompleted += OnPrintQueueAllJobsAreCompleted;
    
        int PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    
        starPrintPortJobMonitor.Start();
    }
    

    PrinterDriverWithCheckStatusSamplePage.xaml.cs / PrinterDriverWithBarcodeReaderSamplePage.xaml.cs / PrinterDriverWithDisplaySamplePage.xaml.csを参照ください。

4.8.2. PortName

StarPrintPortJobMonitorコンストラクタで指定したポート名を取得します。

  • 宣言

    public string PortName { get; }
    

4.8.3. JobCount

プリンタポートに紐ついているプリンタキューのジョブ数を取得します。

  • 宣言

    public int JobCount { get; }
    

4.8.4. PrintQueues

プリンタポートに紐ついているPrintQueueオブジェクトを取得します。

  • 宣言

    public PrintQueue[] PrintQueues{ get; }
    

4.8.5. Start

プリンタポートに紐ついているプリンタキューのジョブ監視を開始します。

  • 宣言

    public bool Start()
    
  • 引数

    なし

  • 戻り値

    説明

    true ... 監視開始成功
    false ... 監視開始失敗

    bool

  • 実装例

    private void SetStarPrintPortJobMonitor()
    {
        starPrintPortJobMonitor = new StarPrintPortJobMonitor("BT:COM1");
    
        starPrintPortJobMonitor.PrintQueueJobIsAdded += OnPrintQueueJobIsAdded;
        starPrintPortJobMonitor.PrintQueueJobIsRemoved += OnPrintQueueJobIsRemoved;
        starPrintPortJobMonitor.PrintQueueAllJobsAreCompleted += OnPrintQueueAllJobsAreCompleted;
    
        int PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    
        starPrintPortJobMonitor.Start();
    }
    

    PrinterDriverWithCheckStatusSamplePage.xaml.cs / PrinterDriverWithBarcodeReaderSamplePage.xaml.cs / PrinterDriverWithDisplaySamplePage.xaml.csを参照ください。

4.8.6. Stop

プリンタポートに紐ついているプリンタキューのジョブ監視を停止します。

  • 宣言

    public bool Stop()
    
  • 引数

    なし

  • 戻り値

    説明

    true ... 監視停止成功
    false ... 監視停止失敗

    bool

  • 実装例

    private void Page_Unloaded(object sender, RoutedEventArgs e)
    {
        starPrintPortJobMonitor.Stop();
    }
    

    PrinterDriverWithCheckStatusSamplePage.xaml.cs / PrinterDriverWithBarcodeReaderSamplePage.xaml.cs / PrinterDriverWithDisplaySamplePage.xaml.csを参照ください。

4.8.7. PrintQueueJobIsAdded

プリンタポートに紐ついているプリンタキューにジョブが追加されたときに発生します。

  • 宣言

    public event EventHandler PrintQueueJobIsAdded
    
  • 実装例

    private void SetStarPrintPortJobMonitor()
    {
        starPrintPortJobMonitor = new StarPrintPortJobMonitor("BT:COM1");
    
        starPrintPortJobMonitor.PrintQueueJobIsAdded += OnPrintQueueJobIsAdded;
        starPrintPortJobMonitor.PrintQueueJobIsRemoved += OnPrintQueueJobIsRemoved;
        starPrintPortJobMonitor.PrintQueueAllJobsAreCompleted += OnPrintQueueAllJobsAreCompleted;
    
        int PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    
        starPrintPortJobMonitor.Start();
    }
    
    private void OnPrintQueueJobIsAdded(object sender, object e)
    {
        PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    }
    

    PrinterDriverWithCheckStatusSamplePage.xaml.cs / PrinterDriverWithBarcodeReaderSamplePage.xaml.cs / PrinterDriverWithDisplaySamplePage.xaml.csを参照ください。

4.8.8. PrintQueueJobIsRemoved

プリンタポートに紐ついているプリンタキューのジョブが減ったときに発生します。

  • 宣言

    public event EventHandler PrintQueueJobIsRemoved
    
  • 実装例

    private void SetStarPrintPortJobMonitor()
    {
        starPrintPortJobMonitor = new StarPrintPortJobMonitor("BT:COM1");
    
        starPrintPortJobMonitor.PrintQueueJobIsAdded += OnPrintQueueJobIsAdded;
        starPrintPortJobMonitor.PrintQueueJobIsRemoved += OnPrintQueueJobIsRemoved;
        starPrintPortJobMonitor.PrintQueueAllJobsAreCompleted += OnPrintQueueAllJobsAreCompleted;
    
        int PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    
        starPrintPortJobMonitor.Start();
    }
    
    private void OnPrintQueueJobIsRemoved(object sender, object e)
    {
        PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    }
    

    PrinterDriverWithCheckStatusSamplePage.xaml.cs / PrinterDriverWithBarcodeReaderSamplePage.xaml.cs / PrinterDriverWithDisplaySamplePage.xaml.csを参照ください。

4.8.9. PrintQueueAllJobsAreCompleted

プリンタポートに紐ついているプリンタキューから全てのジョブが無くなったときに発生します。

  • 宣言

    public event EventHandler PrintQueueAllJobsAreCompleted
    
  • 実装例

    private void SetStarPrintPortJobMonitor()
    {
        starPrintPortJobMonitor = new StarPrintPortJobMonitor("BT:COM1");
    
        starPrintPortJobMonitor.PrintQueueJobIsAdded += OnPrintQueueJobIsAdded;
        starPrintPortJobMonitor.PrintQueueJobIsRemoved += OnPrintQueueJobIsRemoved;
        starPrintPortJobMonitor.PrintQueueAllJobsAreCompleted += OnPrintQueueAllJobsAreCompleted;
    
        int PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
    
        starPrintPortJobMonitor.Start();
    }
    
    private void OnPrintQueueAllJobsAreCompleted(object sender, object e)
    {
        PrinterQueueJobCount = starPrintPortJobMonitor.JobCount;
        IPort port = Factory.I.GetPort("BT:COM1", "", 10000);
    }
    

    PrinterDriverWithCheckStatusSamplePage.xaml.cs / PrinterDriverWithBarcodeReaderSamplePage.xaml.cs / PrinterDriverWithDisplaySamplePage.xaml.csを参照ください。