FieldSoftware
Home

-----------------------------

.NetCF: C#-VB.Net
 Software Developers


PrinterCE.NetCF SDK
   General Info
   Download & Install
   Purchase & Pricing
   Upgrade from PrinterCE

Getting Started with:
 
C#   -   VB.Net

  Code Examples

Documentation
  PrinterCE for .Net CF
  AsciiCE for .Net CF
  BarcodeCE for .Net CF

eVC (C/C++/MFC), eVB:
  PrinterCE SDK

-----------------------------

Software Developers
  PrinterCE SDK
  PrinterCE.NetCF SDK
  PocketHTMLprint SDK

Special Topics
  Supported Printers
  Bluetooth Printing
  Network Printing

Printing Utilities
  PrintPocketCE
  PIEprint
  PocketPixPrint
  PocketShot
 
PocketClipPrint

Arcade Games
  SockOut
  MazeCraze

Contact Info

PrinterCE.NetCF Example:
Line Fun

Demonstrates the power of line drawing capabilities as well as ability to draw ellipses and "fill" them with color.

See full size printed output

 
PrinterCE prce = null;
try
{
  prce = new PrinterCE(); //Create instance of PrinterCE class
  prce.SelectPrinter(true);
  double wd,ht,x1,y1,x2,y2;
  wd = prce.PrPgWidth;
  //Center vertically & horizontally
  prce.JustifyHoriz = PrinterCE.JUSTIFY_HORIZ.CENTER;
  prce.JustifyVert = PrinterCE.JUSTIFY_VERT.CENTER;
  //Set font stuff
  prce.FontName = "Courier New";
  prce.FontSize = 36;
  prce.FontItalic = true;
  prce.ForeColor = Color.DarkMagenta;
  //ScaleMode defaults to TWIPS - (1440 twips per inch)
  prce.DrawText("Demo: Line Fun", wd / 2, 720);
  //Rectangle area - width of page by 2 inches
  x1 = 0;
  x2 = wd;
  y1 = 1440;
  ht = 2 * 1440;
  y2 = y1 + ht;
  prce.ForeColor = Color.Black;
  prce.DrawWidth = 72; // 72 twips = 1/5 of an inch
  prce.DrawRect(x1, y1, x2, y2);
  prce.DrawWidth = 10;
  double deltax,deltay, offsetx, offsety;
  deltax = wd / 25;
  deltay = ht / 25;
  offsetx = 0;
  offsety = y2;
  for (int lp=0;lp<=24;lp++)
  {
    offsetx = offsetx + deltax;
    prce.DrawLine(x1 + offsetx, y1, x1, offsety);
    prce.DrawLine(x2 - offsetx, y1, x2, offsety);
    offsety = offsety - deltay;
  }
  //Put an ellipse filled with a color inside our rectangle
  prce.DrawWidth = 20;
  prce.FillStyle = 0;
  prce.FillColor = Color.Pink;
  //calc new y1 & y2
  y1 = y1 + 720;
  y2 = y2 - 120;
  x1 = wd / 2;
  prce.DrawEllipse(x1 - wd / 3, y1, x1 + wd / 3, y2);
  //Put some text in the middle
  prce.ForeColor = Color.DarkBlue;
  prce.FontSize = 32;
  prce.FontName = "Arial";
  prce.DrawText("What's Up?", x1, y1 + (y2 - y1) / 2);
  prce.EndDoc(); //Done with this page - print it
}
catch (PrinterCEException exc)
{
  if (prce!=null)
  {
    prce.ShutDown(); //Done - free PrinterCE resources
    // NOTE: Only call ShutDown if PrinterCE instance is about to be destroyed.
  }
  prce=null;
  MessageBox.Show("PrinterCE Exception","Exception");
}
finally
{
  if (prce!=null)
  {
    prce.ShutDown(); //Done - free PrinterCE resources
    // NOTE: Only call ShutDown if PrinterCE instance
    //  is about to be destroyed.

  }
  prce=null;
}