云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C#调用把BarTender模板

C#调用把BarTender模板

  • 62 次阅读
  • 3 次下载
  • 2025/7/13 17:10:09

The Engine class represents a BarTender process and provides the backbone for programming with the BarTender Print SDK. All programs written with the BarTender Print SDK will rely on the Engine class to provide BarTender print functionality.

The BarTender Print Engine

The BarTender process (bartend.exe) provides standard BarTender

functionality, such as opening label formats, changing label settings, and printing. The BarTender background process is controlled using an instance of the Engine class.

The Role of the Engine Class

The Engine class contains many methods, properties, and events to assist in printing and controlling the BarTender Print Engine.

Features of the Engine Class

The Engine class allows users to:

? ? ? ?

Start, stop, and restart a BarTender background process. Open, access, and save label formats. Use Engine-level events to monitor printing. Manage the BarTender Application window.

How To: Start and Stop an Engine

An engine must be created and started in order to launch a BarTender process and commence printing. The Engine class provides the Engine.Stop method to explicitly shut down the BarTender Print Engine. If the engine is not stopped, a bartend.exe process may be left running in the background. After calling the Engine.Stop method, it is best practice to call the Engine.Dispose method. The Dispose method ensures all non-memory resources are properly released for the class; this includes shutting down the BarTender process if Engine.Stop was not successfully called. The following is the minimal code necessary to create, start, stop, and dispose an Engine object:

In C#:

// Calling constructor with 'true' automatically starts engine. using (EnginebtEngine = new Engine(true)) {

// Do something with the engine. // Stop the BarTender process. btEngine.Stop(); } In VB:

' Calling constructor with 'true' automatically starts engine. UsingbtEngineAs NewEngine(True) ' Do something with the engine. ' Stop the BarTender process. btEngine.Stop() End Using

In the above example, an engine is created and started implicitly by passing 'true' as an argument to the constructor. The engine is then stopped by calling the Engine.Stop method. This terminates the background bartend.exe process. Finally, Engine.Dispose is called automatically when execution leaves the 'using' statement, releasing all Engine resources.

It is also possible to start the engine explicitly after it has been created using the default Engine constructor and the Engine.Start method. By default, Engine.Stop will close all open formats without saving, but an overloaded version is provided that allows manual control. The following example shows alternative code for starting and stopping an engine and saving changes: In C#:

using (EnginebtEngine = newEngine())

{

// Application specific code // Explicitly start the engine btEngine.Start();

// Application-specific code

// Assuming the application wants to save changes, //it can be easily done at Stop time. btEngine.Stop(SaveOptions.SaveChanges); } In VB:

UsingbtEngineAs NewEngine(True) ' Application specific code ' Explicitly start the engine btEngine.Start()

' Application-specific code

' Assuming the application wants to save changes, ' it can be easily done at Stop time. btEngine.Stop(SaveOptions.SaveChanges) End Using

In the above example, a new Engine is created, but not started until later. Some application activity is assumed to execute, then the Stop method is called. In this case, changes to labels done while using the engine are saved back to file. The SaveOptions enumeration specifies the operation concerning open label formats to perform during exit of BarTender. In the above examples and many other examples in this document, the Engine.Dispose method is called implicitly by a 'using' statement. While it is not always appropriate to utilize 'using', it is a convenient way to ensure Dispose is called even if the block is exited during an exception.

How To: Use Engine as a Field in a Class

The above examples, and most examples in this document, present use of an Engine instance in a single method. This approach is not practical for most real applications. Starting and stopping Engine objects, and by extension BarTender processes, should be done as rarely as possible for optimal performance. Ideally, Engine instances should be started once and only stopped at the end of the application to minimize the overhead of managing processes. The most straightforward object-oriented approach is make an Engine object a field in a class and allow the encapsulating class to determine the Engine object's lifetime.

The following is the minimal suggested code for making an Engine object a field in a class: In C#:

public classEngineWrapper : IDisposable {

// Engine Field

privateEnginem_engine = null;

// 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. protectedEngineBtEngine { get {

// If the engine has not been created yet, create and start it. if (m_engine == null) {

m_engine = newEngine(true);

搜索更多关于: C#调用把BarTender模板 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

The Engine class represents a BarTender process and provides the backbone for programming with the BarTender Print SDK. All programs written with the BarTender Print SDK will rely on the Engine class to provide BarTender print functionality. The BarTender Print Engine The BarTender process (bartend.exe) provides standard BarTender functionality, such as opening label forma

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com