分享 tsc 条码打印机 打印控件 调用方法 , c# silverlight

下载 TSCLIB.dll

http://download.csdn.net/detail/peiyu_peiyu/4789714  或 网上搜索 TSCLIB.dll

复制到 windows\system  文件夹下

c#

public class tcsBasePrint
    {

        //[DllImport("TSCLib.dll")]
        //public static extern int sendcommand(string command);//open connect port  

        //[DllImport("TSCLib.dll")]
        //public  static extern int openport(string port);//open connect port   
        //[DllImport("TSCLib.dll")]
        //public static extern int closeport();//close connect port
        //[DllImport("TSCLib.dll")]
        ///*
        // width:列印宽度,单位mm
        // height:列印长度,单位mm
        // speed:列印速度            4.0   代表每秒4英寸速度
        // density:列印浓度          0-15 越大表示浓度越高
        // sensor:设定感测器类别     0     表示垂直感测器,1 表示黑标感测器
        // vertical:设定间距高度
        // pchar:设定偏移间距        0     参数一般设为0
        // */
        //public static extern int setup(string width, string height, string speed, string density, string sensor, string vertical, string pchar);

        //[DllImport("TSCLib.dll")]
        //public static extern int clearbuffer();//clear buffer
        //[DllImport("TSCLib.dll")]
        ///*
        // x:字串型別,條碼X 方向起始點,以點(point)表示。(200 DPI,1 點=1/8 mm, 300 DPI,1 點=1/12 mm)
        // y:条码Y方向起始点
        // codeType:条码类型(128,39,93等)
        // height:代表条码的高度,高度以点来表示
        // readable:设定是否列印条码码文
        // rotation:设定条码的旋转角度
        // narrow:设定条码窄的比例因子
        // wide:设定条码宽的比例因子
        // code:条码内容
        // pchar:设定偏移间距        0     参数一般设为0
        // */
        ///*
        // narrow : wide
        //        1:1
        // narrow : wide
        //        1:2
        // narrow : wide
        //        1:3
        // narrow : wide
        //        2:5
        // narrow : wide
        //        3:7  
        // */
        //public static extern int barcode(string x, string y, string codeType, string height, string readable, string rotation, string narrow, string wide, string code, string pchar);

        //[DllImport("TSCLib.dll")]
        ///*
        // x:文字X方向起始点
        // y:文字Y方向起始点
        // fontName:文字类型
        // rotation:文字旋转角度
        // xmul:设定文字X方向的放大倍率
        // ymul:设定文字Y方向的放大倍率
        // content:列印文字的内容
        // */
        //public static extern int printerfont(string x, string y, string fontName, string rotation, string xmul, string ymul, string content);

        //[DllImport("TSCLib.dll")]
        ///*
        // x:文字X方向起始点
        // y:文字Y方向起始点
        // fontHeight:字体高度
        // rotation:文字旋转角度
        // fontStyle:字体外形
        // fontUnderline:底线
        // faceName:字体名称
        // content:列印内容
        // */
        //public static extern int windowsfont(int x, int y, int fontHeight, int rotation, int fontStyle, int fontUnderline, string faceName, string content);

        //[DllImport("TSCLib.dll")]
        ///*
        //打印设置
        // a为式数
        // b为份数
        //*/
        //public static extern int printlabel(string a, string b);

        //[DllImport("TSCLib.dll")]
        ///*
        // 设定打印后回卷
        // */
        //public static extern int formfeed();

        //[DllImport("TSCLib.dll")]
        ///*
        //  设定打印不后回卷
        //*/
        //public static extern int nobackfeed();

        [DllImport("TSCLIB.dll")]
        public static extern int about();

        [DllImport("TSCLIB.dll", EntryPoint = "openport")]
        public static extern int openport(string printername);

        [DllImport("TSCLIB.dll", EntryPoint = "barcode")]
        public static extern int barcode(string x, string y, string type, string height, string readable, string rotation, string narrow, string wide, string code);

        [DllImport("TSCLIB.dll", EntryPoint = "clearbuffer")]
        public static extern int clearbuffer();

        [DllImport("TSCLIB.dll", EntryPoint = "closeport")]
        public static extern int closeport();

        [DllImport("TSCLIB.dll", EntryPoint = "downloadpcx")]
        public static extern int downloadpcx(string filename, string image_name);

        [DllImport("TSCLIB.dll", EntryPoint = "formfeed")]
        public static extern int formfeed();

        [DllImport("TSCLIB.dll", EntryPoint = "nobackfeed")]
        public static extern int nobackfeed();

        [DllImport("TSCLIB.dll", EntryPoint = "printerfont")]
        public static extern int printerfont(string x, string y, string fonttype, string rotation, string xmul, string ymul, string text);

        [DllImport("TSCLIB.dll", EntryPoint = "printlabel")]
        public static extern int printlabel(string set, string copy);

        [DllImport("TSCLIB.dll", EntryPoint = "sendcommand")]
        public static extern int sendcommand(string printercommand);

        [DllImport("TSCLIB.dll", EntryPoint = "setup")]
        public static extern int setup(string width, string height, string speed, string density, string sensor, string vertical, string offset);

        [DllImport("TSCLIB.dll", EntryPoint = "windowsfont")]
        public static extern int windowsfont(int x, int y, int fontheight, int rotation, int fontstyle, int fontunderline, string szFaceName, string content);

    }

调用:

return printobj.tcsBasePrint.about();

printobj.tcsBasePrint.openport(prot);   // // prot 打印机名称 从 控制面板  ”设备和打印机“ 拷贝即可
            printobj.tcsBasePrint.clearbuffer();
        
                    printobj.tcsBasePrint.windowsfont(x, y, 20,"0", 2, 0, "微软雅黑", strt1);//X Y 坐标  strt1 字符串
                 
                    switch (barcodetype.ToLower())
                    {
                        case "128":
                        case "39":
                            printobj.tcsBasePrint.barcode(x.ToString(), y.ToString(), barcodetype, "20", "1", "0", "2", "1", strt1);
                           
                            break;
                       case "qr":
                            printobj.tcsBasePrint.sendcommand("QRCODE " + x.ToString() + "," + y.ToString() + ",M,7,A,0,\"" + strt1 + "\"");
      break;
                        case "pdf417":
                            printobj.tcsBasePrint.sendcommand("PDF417 " + x.ToString() + "," + y.ToString() + ",300,200," + (modelhead.i03.Value + 180).ToString() + ",\"" + strt1 + "\"");

                            break;
                    }
                   // System.Threading.Thread.Sleep(10);

                    continue;
                }
               
            }
          
            printobj.tcsBasePrint.printlabel("1", "1");
            printobj.tcsBasePrint.closeport();

c# silverlight的更多相关文章

  1. Silverlight 后台设置 button 纯色背景

    silverlight Button直接设置其background为某一颜色往往达不到效果.因为其内置模板把按钮背景弄成一个渐变画刷.所以想要纯色的背景就修改其模板. 在后台修改模板的代码如下: St ...

  2. 添加Silverlight应用到HTML

    Silverlight是跨浏览器,跨客户平台的浏览器插件,可以应用在Windows,Linux,Mac等平台.作为浏览器插件,Silverlight可以像Flash一样,很方便的嵌套在HTML页面中, ...

  3. Silverlight 手鼓达人-仿太鼓达人 开源

    Silverlight 手鼓达人-仿太鼓达人 介绍  手鼓达人是本人2012年中silverlight最火的一段时间开发的,本来目的只是想研究一下silverlight做游戏和做应用有何不同,但是后面 ...

  4. silverlight使用小计(先做记录后续整理)

    1.Grid: a.通过获取指定行的高度和指定列的宽度来获取指定单元格的宽高 b.几种宽高默认值: 宽高(Width/Heigth):1* 最大宽高(MaxWidth/MaxHeigth):正无穷大 ...

  5. SilverLight抛出 System.InvalidOperationException: 超出了2083 的最大URI

    在SilverLight中对于抛出 System.InvalidOperationException: 超出了 2083 的最大 URI 长度 的异常 处理 其实很简单 在 EntityFramewo ...

  6. 【Silverlight】打开Silverlight程序报错,"未找到导入的项目......请确认<Import>声明中的路径正确,且磁盘上存在该文件"

    在打开Silverlight程序时,报错(如图所示),程序使用的是Visual Studio 2013和最新的Silverlight版本(Silverlight5). 然后我在网上找了下说:Silve ...

  7. Silverlight 使用DataContractJsonSerializer序列化与反序列化 Json

    环境说明:Silverlight 5.1,.Net Framework  ​4.0 1.添加引用System.ServiceModel.Web.dll. 因为 System.Runtime.Seria ...

  8. Silverlight及WPF中实现自定义BusyIndicator

    在开发Silverlight或者WPF项目时,当我们调用Web服务来加载一些数据时,由于数据量比较大需要较长的时间,需要用户等待,为了给用户友好的提示和避免用户在加载数据过程中进行重复操作,我们通常使 ...

  9. Silverlight和WPF中DataContractJsonSerializer对时间的处理差异

    原创文章转载请注明出处:@协思, http://zeeman.cnblogs.com Silverlight脱胎于WPF,他们的行为不完全并不完全相同,DataContractJsonSerializ ...

  10. [SL] Silverlight + WCF Demo项目

    I:项目描述:利用 Silverlight+WCF 技术,模拟资源管理器(如图1)功能,通过地址栏输入本地文件夹路径,然后将解析出来的该目录下所有文件(夹)存储到数据库中,然后再加载到界面上显示出来: ...

随机推荐

  1. html5语义化标签总结二

    HTML 5的革新之一:语义化标签二文本元素标签.分组元素标签. HTML 5的革新——语义化标签(一)中介绍了一些HTML5新加的一些节元素,一张页面中结构元素构成网页大体,但是也需要其他内容来填充 ...

  2. webView缩放

    self.webview.scalesPageToFit = YES; 可以让webView内容用缩放手势放大或缩小

  3. strace 分析 跟踪 进程错误

    strace是什么? 按照strace官网的描述, strace是一个可用于诊断.调试和教学的Linux用户空间跟踪器.我们用它来监控用户空间进程和内核的交互,比如系统调用.信号传递.进程状态变更等. ...

  4. c语言基础编程

    作业: 1.二进制,八进制,十进制之间的相互转换 2.测试转义字符 3.测试强制类型转换 4.测试赋值运算符  = += -= *= /= %= <<= >>= ^= |= & ...

  5. Linux下hosts、host.conf、resolv.conf

    /etc/resolv.conf 该文件是DNS域名解析的配置文件,它的格式很简单,每行以一个关键字开头,后接配置参数. resolv.conf的关键字主要有四个,分别是: nameserver   ...

  6. [Unity UGUI]UGUI提供多种不同的解决方案

    现代游戏和应用程序经常需要支持各种不同的屏幕分辨率,特别是UI布局需要能够适应.UI系统在统一中包括各种工具来实现此目的,可以以多种方式组合在一起. 在这个小节我们将使用一个简单的案例研究和观察和比较 ...

  7. 为HTTP分类作序

    作者:zccst 曾经,认为对HTTP已经非常熟悉了,觉得不需要学习什么,知道2014年春天,让我感觉到自己是如此的无知. 举例: 1,对HTTP头部信息知道多少?每一个字段分别都可以取哪些值,每一个 ...

  8. MySQL索引背后的之使用策略及优化(高性能索引策略)

    为了讨论索引策略,需要一个数据量不算小的数据库作为示例.本文选用MySQL官方文档中提供的示例数据库之一:employees.这个数据库关系复杂度适中,且数据量较大.下图是这个数据库的E-R关系图(引 ...

  9. JNI错误总结(转)

    源:JNI错误总结 最近公司里要用JNI技术,用java去调用已经写好的本地DLL库.之前自己也没接触过相关技术,其中花了大部分时间在调试改错上面,网上对于错误的解决方案也不多,现在项目接近完工,自己 ...

  10. iOS纯代码手动适配 分类: ios技术 2015-05-04 17:14 239人阅读 评论(0) 收藏

    首先说下让自己的程序支持iPhone6和6+,第一种使用官方提供的launch screen.xib,这个直接看官方文档即可,这里不再多述:第二种方法是和之前iPhone5的类似,比较简单,为iPho ...