LabelView/Codesoft 條碼打印范例

LabelView Sample:

private   void   Form1_Load(object   sender,   System.EventArgs   e)  
  {  
  LabelApp=new   LabelApplicationClass();  
  doc=(LabelView.LabelDocument)LabelApp.ActiveDocument();  
  doc.Open("c://worklog//label.lbl",true);  
  }  
   
  private   void   PrintLabel(string   result)  
  {  
  try  
  {  
   
  LabelView.LabelField   snLabel=(LabelView.LabelField)((LabelView.LabelFields)doc.LabelFields).Item("SN");  
  snLabel.Value=result;  
  doc.LabelSetup();  
  doc.PrintLabel(2,null,null,null,null,null,null);  
   
   
  }  
  catch(Exception   err)  
  {  
  MessageBox.Show(err.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);  
  }  
  }   
   
  private   void   Form1_Closing(object   sender,   System.ComponentModel.CancelEventArgs   e)  
  {  
  LabelApp.Quit();  
  LabelApp   =   null;  
  System.GC.Collect();   
  } 

=======================================

Zebra-ZPL Sample:
先用Bar-One做成Barcode文檔,再通過File-->Down formatter to print生成zpl文檔,通過編程對zpl文檔中特定數據進行替換,最後輸出到指定端口即可.
  ofstream   fout;                             //declare   file-stream   handle  
  fout.open("lpt1:",   ios::out);             //open   out   to   lpt1:  
  fout<<"^XA";                                //   start   ZPL   command  
 
fout<<"^FO11,19^A0N,17,16^FDYXX^FS";        //   define   the  
locate   of   the   printout   and   the   size   of   the   font  
is   17   x   16  
  fout<<"^FO45,19^A0N,17,16^FDXXXXX^FS";     
  fout<<"^FO95,19^A0N,17,16^FDAA^FS";  
  fout<<"^FO121,19^A0N,17,16^FDB^FS";  
 
fout<<"^FO11,40^A0N,13,12^FDMM/DD/YY^FS";     //   define   the  
locate   of   the   printout   and   the   size   of   the   font  
is   13   x   12  
  fout<<"^FO81,40^A0N,13,12^FDC^FS";  
  fout<<"^FO103,40^A0N,13,12^FDD^FS";  
  fout<<"^FO11,59^A0N,13,12^FDPF^FS";  
  fout<<"^FO45,60^A0N,13,12^FDKF^FS";  
  fout<<"^FO73,60^A0N,13,12^FDDD^FS";  
  fout<<"^FO95,61^A0N,13,12^FDI^FS";  
  fout<<"^BY1,3,15^FO11,80^BCN,,Y,N^FD0705610065^FS";    //   print   barcode   128   with   human   readable  
  fout<<"^PQ1";                                             //print   one   label  
  fout<<"^XZ";                       //sending   end   of   zpl   Print   one  
  fout.close();      

 

///Codesoft Delphi
Var
    BarApp,BarDoc:Variant;
Begin
  BarApp := CreateOleObject('lppx.Application');
  BarApp.Visible:=True;
  BarDoc:=BarApp.ActiveDocument;
  BarVars:=BarDoc.Variables;
  BarDoc.Open('T018S1.Lab');
  BarDoc.Variables.Item('Data1').Value:='ABCD';
  BarDoc.Variables.Item('Data2').Value:='111';
  BarDoc.Variables.Item('Data3').Value:='111ABCD';
  Bardoc.Printlabel(1);
  BarDoc.FormFeed;
  Bardoc.Close;
  BarApp.Quit;
End;

///Codesoft C#
using LabelManager2;
ApplicationClass lbl = new ApplicationClass();
try
{
    lbl.Documents.Open(@"D:/Temp/TEMP.Lab", false);
    Document doc = lbl.ActiveDocument;
    //foreach(...)
    //{
    doc.Variables.FormVariables.Item("Var0").Value = "12399999";
    //doc.Variables.FreeVariables
    //doc.Variables.Formulas
    //doc.Variables.TableLookups
    //doc.Variables.DatabaseVariables
    //doc.Variables.Dates
    //doc.Variables.Counters
    doc.PrintDocument(1);
    //}
    doc.Close(false);
}
catch (Exception ex)
{
    lbl.Quit();
}

SAMPLE CODESOFT 8 APPLICATIONS


 

Click a link below to download a sample ActiveX application:


 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
以下是一个 LabelView 的示例代码,可以在 Android 平台上使用: ```xml <com.example.myapp.LabelView android:id="@+id/label_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:labelBackgroundColor="@color/colorPrimary" app:labelTextColor="@android:color/white" app:labelPadding="8dp" app:labelCornerRadius="4dp" /> ``` 其中,`LabelView` 是自定义的 View 类,继承自 `TextView`,并添加了一些额外的属性,如 `labelBackgroundColor`、`labelTextColor`、`labelPadding` 和 `labelCornerRadius`。这些属性可以通过在 XML 中设置来改变 LabelView 的样式。 下面是 `LabelView` 类的代码: ```java public class LabelView extends AppCompatTextView { private int backgroundColor; private int textColor; private int padding; private int cornerRadius; public LabelView(Context context) { super(context); init(context, null); } public LabelView(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs); } public LabelView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context, attrs); } private void init(Context context, AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LabelView); backgroundColor = typedArray.getColor(R.styleable.LabelView_labelBackgroundColor, Color.TRANSPARENT); textColor = typedArray.getColor(R.styleable.LabelView_labelTextColor, Color.BLACK); padding = typedArray.getDimensionPixelSize(R.styleable.LabelView_labelPadding, 0); cornerRadius = typedArray.getDimensionPixelSize(R.styleable.LabelView_labelCornerRadius, 0); typedArray.recycle(); setBackgroundColor(backgroundColor); setTextColor(textColor); setPadding(padding, padding, padding, padding); if (cornerRadius > 0) { setBackground(createBackgroundDrawable()); } } private Drawable createBackgroundDrawable() { GradientDrawable drawable = new GradientDrawable(); drawable.setColor(backgroundColor); drawable.setCornerRadius(cornerRadius); return drawable; } public void setBackgroundColor(int backgroundColor) { this.backgroundColor = backgroundColor; if (cornerRadius > 0) { setBackground(createBackgroundDrawable()); } else { super.setBackgroundColor(backgroundColor); } } public void setLabelTextColor(int textColor) { this.textColor = textColor; setTextColor(textColor); } public void setLabelPadding(int padding) { this.padding = padding; setPadding(padding, padding, padding, padding); } public void setLabelCornerRadius(int cornerRadius) { this.cornerRadius = cornerRadius; if (cornerRadius > 0) { setBackground(createBackgroundDrawable()); } else { super.setBackgroundColor(backgroundColor); } } } ``` 在 `init()` 方法中,我们通过获取 XML 中设置的属性值来初始化 LabelView 的样式。如果设置了圆角半径 `cornerRadius`,则创建一个 `GradientDrawable` 并设置为 LabelView 的背景。否则,直接调用 `super.setBackgroundColor()` 方法来设置背景色。同时,我们还提供了一些公开方法,使得使用者可以在代码中动态地改变 LabelView 的样式。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值