第一范文网 - 专业文章范例文档资料分享平台

C#调用把BarTender模板

来源:用户分享 时间:2025/5/15 16:53:57 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

}

returnm_engine; } }

// Implement IDisposable public void Dispose() {

// The engine only needs to be stopped and disposed if it was // created. Use the field here, not the property. Otherwise, // you might create a new instance in the Dispose method! if (m_engine != null) {

// Stop the process and release Engine field resources. m_engine.Stop(); m_engine.Dispose(); } }

// Additional methods for specific work in your application. All additional

// methods should use the BtEngine property instead of the m_engine field. } In VB:

Public ClassEngineWrapper ImplementsIDisposable ' Engine Field

Privatem_engineAs Engine = Nothing

' This property will create and start the engine the first time it is ' called. Most methods in this class (and methods in child classes) ' should utilize this property instead of the m_engine field. Protected ReadOnly PropertyBtEngine() As Engine Get

' If the engine has not been created yet, create and start it. Ifm_engineIs Nothing Then m_engine = NewEngine(True) End If

Returnm_engine End Get End Property

' ImplementIDisposable

Public SubDispose() ImplementsIDisposable.Dispose

' The engine only needs to be stopped and disposed if it was ' created. Use the field here, not the property. Otherwise, ' you might create a new instance in the Dispose method! Ifm_engineIsNot Nothing Then

' Stop the process and release Engine field resources. m_engine.Stop() m_engine.Dispose() End If End Sub

' Additional methods for specific work in your application. All additional ' methods should use the BtEngine property instead of the m_engine field.

End Class

The class above provides lazy instantiation of an Engine object and a method for disposal of its resources. By using the BtEngine property for all work in its methods, this class will avoid creating and starting a BarTender process until it really needs one. This class offers a means of releasing its resources, its underlying Engine object, by implementing the IDisposable interface. If this class were used in a real application, it would include other methods that did work specific to the application. This code would be a reasonable base class for a hierarchy of classes that perform printing in a real application. In the case where instances of this class are intended to be used from multiple threads in an application, locking logic should be added to the BtEngine property to ensure the engine is only created once.

How To: Display the BarTender User Interface

By default, an Engine object's BarTender process runs BarTender in the background without being seen by a user. However, there may be times you will want to view and interact with BarTender抯 user interface. The following example shows how to view BarTender抯 users interface using the Engine.Window.Visible property. In C#:

using (EnginebtEngine = newEngine()) {

btEngine.Start();

btEngine.Window.Visible = true; // Application-specific code btEngine.Stop(); } In VB:

UsingbtEngineAs NewEngine() btEngine.Start()

btEngine.Window.Visible = True

' Application-specific code btEngine.Stop() End Using

In the above code, a new Engine is initialized and started. The BarTender application window is then shown by setting the Engine.Window'sVisible property to true. The method assumes some intervening work is done. Finally, the engine is stopped and automatically disposed when leaving the 'using' statement. If this code is run without any intervening work between the call to btEngine.Window.Visible and the btEngine.Stop method, the BarTender window will only flash open for a moment, then immediately close when the engine is stopped and the BarTender process is shutdown.

The Engine Class and Print Job Events

The Engine class provides many engine-wide events. Most of these, such as the JobQueued or JobSent, are used to monitor the status of a print job.

These same events are found in the LabelFormatDocument class, where they are specific to that label format. Unlike the events found in

LabelFormatDocument, Engine events provide a means to oversee print job events for all label formats opened by the engine.

For more information, refer to Working with Print Job Status Events. Printing Label Formats

A label format can be printed by calling the LabelFormatDocument'sPrint method. The Print method prints a job to a printer's spooler and returns a Result enumeration value. It can either return immediately after spooling the print job or wait to return until printing is complete. The LabelFormatDocument object contains several overloads for the Print method to assist in label printing.

? ? ? ?

Print()

Print(string printJobName)

Print(string printJobName, out Messages message)

Print(string printJobName, int waitForCompletionTimeout)

搜索更多关于: C#调用把BarTender模板 的文档
C#调用把BarTender模板.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c18gms1tqyv5dq8n1sig30fluh9boav00um5_3.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top