Getting Started with ZMotif Card Printer Development – ZMotif SDK+ – C#


Doc ID:    WH54
Version:    3.0
Published date:    01/24/2011
Updated:    10/20/2011
 

Content

Overview

This document describes the end to end process of designing, packaging, deploying and running a C# application using the Zebra ZMotif™ SDK+. The video contents demonstrate creating the user interface, adding code in C# .NET to the project, running the project and printing a card. The video is following by an online version of the guide used during the video. The videos were recorded in a native resolution of 1440 x 868 but have been scaled down to fit on-screen. Click the full screen button in the playback toolbar to display fullscreen. The video also contains a narrated audio track describing the activity on-screen and any further relevant points.

The sample code used in this guide is from the "Getting started with ZMotif Card Printer Development support sample code" (SA249) which is available for download to all registered members of the Zebra ISV Program here on the Zebra Support Portal. For information on joining the ISV Program contact a Program manager in your area. Details here.

Target Audience

The information delivered in this document assumes the reader has reasonable technical competence covering Microsoft Visual Studio, core programming concepts and rationales.

Feedback

We value all feedback. Please add your comments/suggestions to the article in the Zebra Support Portal.

Video Information
Audio available
English
Subtitles unavailable

The vidoes are presented in mp4 format. Click here to download the videos for offline review

 

 

Prerequisites

The following items are required to create the ZMotif™ SDK+ application:

ZMotif™ SDK+

The following components are required and included in the ZMotif™ SDK+ package: ZMotif Printer SDK, ZMotif Graphics SDK, and ZGT (Zebra General Tool). To download ZMotif™ SDK+, click here. Click the “Click here for the EULA” link located at the top right section of the page. The “Installing the ZMotif™ SDK+” section of this document contains instructions on how to install the SDKs.

ZXP Series 8 Printer

In order to run the ZMotif™ SDK+ application created in this document, a Zebra ZXP Series 8™ retransfer printer must be accessible from the computer.

 

Installing the ZMotif™ SDK+

The ZMotif™ SDK+ must be installed to your system before the sample application can be developed. The following steps explain how to install the ZMotif™ SDK+.

 

Install the ZMotifPrinterSDK

  1. Navigate to the ZMotifPrinterSDK’s directory (ZMotifPrinterSDK_<version>) within the ZMotif™ SDK+’s installation package.
  2. Launch setup.exe located in the ZMotifPrinterSDK’s directory
  3. Complete the ZMotifPrinterSDK installation by advancing through the installation wizard using the installer’s defaults.

 

Install the ZMotifGraphicsSDK

  1. Navigate to the ZMotifGraphicsSDK’s directory (ZMotifGraphicsSDK_<version>) within the ZMotif™ SDK+’s installation package.
  2. Launch setup.exe located in the ZMotifGraphicsSDK’s directory.
  3. Complete the ZMotifGraphicsSDK installation by advancing through the installation wizard using the installer’s defaults.

 

Creating an Application using the ZMotif™ SDK+

The following steps will guide you through the creation of an application that will utilize the ZMotif™ SDK+. The application will feed in a PVC card from the Input Hopper, print text and graphics to the card, than send the card to the Output Hopper.

  1. Launch Microsoft Visual Studio 2008.
    Go to Start -> All Programs -> Microsoft Visual Studio 2008 -> Microsoft Visual Studio 2008.
  2. Create a C# Windows Form project.
    a.Click on File -> New -> Project.



    b.You will be prompted with a New Project window. In “Project types” pane, expand Visual C# and select Windows Forms Application.

    c.Enter “ZMotifGettingStarted” in the Name text field and chose a location for your project. Click OK.


    d.Your project will automatically open in the IDE. The Form Designer is opened by default.

    e.The ZMotif™ SDK+ only works with 32-bit applications. If you are running on a 64-bit system you must change the project’s built type to x86.
    1. Right-click the ZMotifGettingStarted project in the Solution Explorer and select Properties.

       
    2. The ZMotifGettingStarted project’s properties window will be displayed. Select Build on the left
    3. Set the Platform target to x86 and Save. Close the properties window to return to the Form Designer.


  3. Design the Form Layout
    1. Rename the form in the Solution Explorer by right-clicking Form1.cs and selecting Rename.
      1. Enter “frmMain.cs” and hit Enter.
      2. Click Yes when prompted to rename all references of “Form1”.

         
    2. Right-click anywhere on the form in the Form Designer and select Properties. This will bring up the Properties table in the bottom right panel.


       
    3. Replace “Form1” with “ZMotif Application” for the value of the Text property. This changes the text on the title bar of the form.

       
    4. For the value of the Size property, replace “300, 300” with “350, 300”.


    5. In the Properties window, select the lightning bolt icon to show the Form’s events. Set the Load event to “frmMain_Load”.

       
    6. We will use a combo box for selecting a printer.
      1. Expand the Toolbox on the left.
      2. Expand Common Controls and drag a ComboBox into the top left portion of the form.
      3. Right-click the combo box and select Properties.
      4. Set the value of the “(Name)” property to “cboPrinterSelection”.

         
    7. We will use a text box to enter text that will appear on the card.
      1. Drag a TextBox from the Toolbox and place it directly under the combo box on the form

         
      2. Right-click the TextBox and select Properties. Set the value of its “(Name)” property to “txtCardTextFront”.

         
    8. Now we will add Labels to the ComboBox and TextBox.
      1. Drag a Label from the Toolbox and place it to the right of the ComboBox.
      2. Right-click the label and select Properties. Set the value of the Text property to “Printer:”.
      3. Drag another Label from the Toolbox and place it to the right of the TextBox.
      4. Right-click the label and select Properties. Set the value of the Text property to “Card Text:”.
         
    9. We will use another label to output the status messages.
      1. Drag another Label from the Toolbox and place it directly under the Card Text Label.
      2. Right-click the label and select Properties. Clear the value of the Text property so that is blank.
      3. Set the value of the “(Name)” property to “lblPrintStatus”.

         
    10. The last control we need is a Button to print the card.
      1. Drag a Button from the Toolbox and place it in the bottom right portion of the form.
      2. Right-click the Button and select Properties.
      3. Change the value of the Text property to “Print”.
      4. Change the value of the “(Name)” property to “btnPrint”.
      5. Click the lightning bolt icon to show the Button’s events.
      6. Set the Button’s click event to “btnPrint_Click”.

         
  4. Add the Code
    1. Before we write any code, we need to include References to the ZMotif™ SDK+’s assemblies.
      1. First, we will add a reference to ZMotifGraphics.dll. In the Solution Explorer, right-click “References” and select “Add Reference…”

         
      2. Select the “Browse” tab and navigate to the location where the ZMotifGraphicsSDK was installed. (The default is “C:\Program Files\Zebra Technologies\ZMotifGraphicsSDK\bin”)
      3. In the “bin” directory, select “ZMotifGrahpics.dll” and click OK.

         
      4. Now we will add a reference to ZMotifPrinter.dll. Once again, right-click “References” and select “Add Reference…”.
      5. Select the “Browse” tab and navigate to the location where the ZMotifPrinterSDK was installed. (The default is “C:\Program Files\Zebra Technologies\ZMotifPrinterSDK\<version>\bin”)
      6. In the “<version>\bin” directory, select “ZMotifPrinter.dll” and click OK.
      7. Lastly, we will add a reference to Neodynamic.SDK.Barcode.dll. This DLL is required by the ZMotif™ SDK+’s assemblies.
      8. In the Solution Explorer, right-click “References” and select “Add Reference…”.
      9. Select the “Browse” tab and navigate to the location where the ZGT (Zebra General Tool) was installed. (The default is “C:\Program Files\Zebra Technologies\ZGT”)
      10. Select “Neodynamic.SDK.Barcode.dll” and click OK.
      11. There should now be three new assemblies (ZMotifGraphics, ZMOTIFPRINTERLib, Neodynamic.SDK.Barcode) under References in the Solution Explorer
    2. Now we will begin adding the code. Right-click anywhere in the Form Designer and select View Code. This will open frmMain.cs.
    3. Replace the existing code in frmMain.cs with the code from the "frmMain.cs" file from the sample code. This code has a few main functions:


      Note: The source code in this whitepaper is extracted from the "Getting started with ZMotif Card Printer Development support sample code" SA249 which is available for download to all registered members of the Zebra ISV Program here. For information on joining the ISV Program, contact a Program Manager in your area. Details here.

      1. Populates the printer selection combo box with available printers.
      2. Connects to the printer before printing and disconnects from the printer after printing.
      3. Draws shapes and text to the graphics buffer and begins printing when the Print button is clicked.

     

  5. Running the Application
    1. Start the application by pressing F5.
    2. Select your ZMotif device from the printer selection combo box.

       
    3. Enter “Hello World!” into the Card Text text field.

       
    4. Click the Print button. When the print begins, you will see the message “Printing Card”.

       
    5. The resulting card should have shapes and text printed on the front and back, as shown below.

      Front: Back

     

  6. Deploying the Application
    1. Set the project’s build mode to Release by choosing Release from the dropdown near the top.
       
    2. If you are running on a 64-bit system, you must once again change the build type to x86, as this set separately for Debug and Release build modes.
      1. You may refer back to section 2 step e if you do not remember how to do this.
      2. Be sure your build mode is set to Release before changing the build type.
    3. Select Build -> Build Solution from the top menu.

       
    4. Open Windows Explorer and navigate to your ZMotifGettingStarted Visual Studio project. Your application is located at “~\ZMotifGettingStarted \bin\Release\ZMotifGettingStarted.exe”.
    5. If a custom ZMotif device application will be run on machines that do not have the ZMotif™ SDK+ installed, it needs access to any ZMotif assemblies that it uses in its code. The ZMotifGettingStarted uses “ZMotifGraphics.dll” (ZMotifGraphicsSDK) and “Interop.ZMOTIFPRINTERLib.dll” (ZMotifPrinterSDK).

 

All links and information correct at time of writing
Created for the Zebra Global ISV Program by Zebra Development Services

Attachment

ZMotifSDK_CSharp_GettingStarted_WH.pdf
1.6MB • 5 minute(s) @ 56k, < 1 minute @ broadband



Rate this item

Find Answers

Find Answers

Zebra Partner Sign In

Registered Zebra Partners can sign in to view additional content

Did you forget your password?
Click here for assistance.