├── .gitattributes
├── ThermalPrinterWrapper
├── packages.config
├── EscPos
│ ├── EscPosInitialize.cs
│ ├── EscPosCommand.cs
│ ├── EscPosLineFeed.cs
│ ├── EscPosLineFeedToLabelMark.cs
│ ├── EscPosSetDefaultLineSpacing.cs
│ ├── EscPosLineFeedNLines.cs
│ ├── EscPosSetCharacterSpacing.cs
│ ├── EscPosSetNDotLineSpacing.cs
│ ├── EscPosLineFeedNDotLines.cs
│ ├── EscPosSetBarcodeLeftMargin.cs
│ ├── EscPosSetConnection.cs
│ ├── EscPosSetLeftMargin.cs
│ ├── EscPosSetBarcodeHeight.cs
│ ├── EscPosSetCustomCharset.cs
│ ├── EscPosSetQrCodeSize.cs
│ ├── EscPosQrCode.cs
│ ├── EscPosSetBarcodeLineWidth.cs
│ ├── EscPosKickCashdrawer.cs
│ ├── EscPosSetLineAlignment.cs
│ ├── EscPosSetBarcodeHriPosition.cs
│ ├── EscPosSetTextStyle.cs
│ ├── EscPosPlainString.cs
│ └── EscPosBarcode.cs
├── Printer.cs
├── Properties
│ └── AssemblyInfo.cs
├── SerialPrinter.cs
├── ThermalPrinterWrapper.csproj
├── UsbPrinter.cs
└── BluetoothPrinter.cs
├── ThermalPrinterWrapper.sln
├── LICENSE
└── .gitignore
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosInitialize.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:打印机初始化
10 | ///
11 | public class EscPosInitialize : EscPosCommand
12 | {
13 | public override byte[] GetBytes()
14 | {
15 | return new byte[] { ESC, 0x40 };
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | public abstract class EscPosCommand
9 | {
10 | public const byte ESC = 0x1B;
11 |
12 | public const byte GS = 0x1D;
13 |
14 | public readonly Encoding GBK = Encoding.GetEncoding(936);
15 |
16 | public abstract byte[] GetBytes();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosLineFeed.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:打印行缓冲器里的内容并向前走纸一行,当行缓冲器为空时只向前走纸一行。
10 | ///
11 | public class EscPosLineFeed : EscPosCommand
12 | {
13 | public override byte[] GetBytes()
14 | {
15 | return new byte[] { 0x0A };
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosLineFeedToLabelMark.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:打印缓冲区里的数据,如果有黑标功能,打印后进纸到下一个黑标位置。
10 | ///
11 | public class EscPosLineFeedToLabelMark : EscPosCommand
12 | {
13 | public override byte[] GetBytes()
14 | {
15 | return new byte[] { 0x0C };
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetDefaultLineSpacing.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:设置行间距为 1/6 英寸(4 毫米,32 点)
10 | ///
11 | public class EscPosSetDefaultLineSpacing : EscPosCommand
12 | {
13 | public override byte[] GetBytes()
14 | {
15 | return new byte[] { ESC, 0x32 };
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosLineFeedNLines.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:打印行缓冲区里的内容,并向前走纸 n 行。
10 | ///
11 | public class EscPosLineFeedNLines : EscPosCommand
12 | {
13 | public byte N { get; set; }
14 |
15 | public override byte[] GetBytes()
16 | {
17 | return new byte[] { ESC, 0x64, this.N };
18 | }
19 |
20 | ///
21 | ///
22 | ///
23 | /// 走纸行数(0-255)
24 | public EscPosLineFeedNLines(byte n)
25 | {
26 | this.N = n;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetCharacterSpacing.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:设置字符间距
10 | ///
11 | public class EscPosSetCharacterSpacing : EscPosCommand
12 | {
13 | public byte N { get; set; }
14 |
15 | public override byte[] GetBytes()
16 | {
17 | return new byte[] { ESC, 0x20, this.N };
18 | }
19 |
20 | ///
21 | ///
22 | ///
23 | /// 字符间距(0-255)
24 | public EscPosSetCharacterSpacing(byte n)
25 | {
26 | this.N = n;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetNDotLineSpacing.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:设置行间距为 n 点行
10 | ///
11 | public class EscPosSetNDotLineSpacing : EscPosCommand
12 | {
13 | public byte N { get; set; }
14 |
15 | public override byte[] GetBytes()
16 | {
17 | return new byte[] { ESC, 0x33, this.N };
18 | }
19 |
20 | ///
21 | ///
22 | ///
23 | /// 行间距点行数(0-255)
24 | public EscPosSetNDotLineSpacing(byte n)
25 | {
26 | this.N = n;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosLineFeedNDotLines.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:打印行缓冲区里的内容,并向前走纸 n 点行。
10 | ///
11 | public class EscPosLineFeedNDotLines : EscPosCommand
12 | {
13 | public byte N { get; set; }
14 |
15 | public override byte[] GetBytes()
16 | {
17 | return new byte[] { ESC, 0x4A, this.N };
18 | }
19 |
20 | ///
21 | ///
22 | ///
23 | /// 走纸点行数(0-255)
24 | public EscPosLineFeedNDotLines(byte n)
25 | {
26 | this.N = n;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetBarcodeLeftMargin.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:设置条形码打印的左边距
10 | ///
11 | public class EscPosSetBarcodeLeftMargin : EscPosCommand
12 | {
13 | public byte N { get; set; }
14 |
15 | public override byte[] GetBytes()
16 | {
17 | return new byte[] { GS, 0x78, this.N };
18 | }
19 |
20 | ///
21 | ///
22 | ///
23 | /// 左边距单位(0-255)
24 | public EscPosSetBarcodeLeftMargin(byte n)
25 | {
26 | this.N = n;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetConnection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:连线打印机
10 | ///
11 | public class EscPosSetConnection : EscPosCommand
12 | {
13 | public bool Connect { get; set; }
14 |
15 | public override byte[] GetBytes()
16 | {
17 | return new byte[] { ESC, 0x3D, Convert.ToByte(Connect) };
18 | }
19 |
20 | ///
21 | ///
22 | ///
23 | /// 打印机是否连线
24 | public EscPosSetConnection(bool connect)
25 | {
26 | this.Connect = connect;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetLeftMargin.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:设置左边空白点数, 单位 0.125mm
10 | ///
11 | public class EscPosSetLeftMargin : EscPosCommand
12 | {
13 | public ushort N { get; set; }
14 |
15 | public override byte[] GetBytes()
16 | {
17 | return new byte[] { ESC, 0x33, (byte)(this.N & 0xFF), (byte)(this.N >> 8) };
18 | }
19 |
20 | ///
21 | ///
22 | ///
23 | /// 左边距单位(0-65535)
24 | public EscPosSetLeftMargin(ushort n)
25 | {
26 | this.N = n;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetBarcodeHeight.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:设置条形码高度
10 | ///
11 | public class EscPosSetBarcodeHeight : EscPosCommand
12 | {
13 | public byte N { get; set; }
14 |
15 | public override byte[] GetBytes()
16 | {
17 | return new byte[] { GS, 0x68, this.N };
18 | }
19 |
20 | ///
21 | ///
22 | ///
23 | /// 条码高度(1-255)
24 | public EscPosSetBarcodeHeight(byte n)
25 | {
26 | if (n == 0)
27 | throw new ArgumentOutOfRangeException("条码高度不能为0");
28 | this.N = n;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetCustomCharset.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:选择自定义字符集
10 | ///
11 | public class EscPosSetCustomCharset : EscPosCommand
12 | {
13 | public bool UseCustomCharset { get; set; }
14 |
15 | public override byte[] GetBytes()
16 | {
17 | return new byte[] { ESC, 0x25, Convert.ToByte(this.UseCustomCharset) };
18 | }
19 |
20 | ///
21 | ///
22 | ///
23 | /// 是否使用自定义字符集
24 | public EscPosSetCustomCharset(bool useCustomCharset)
25 | {
26 | this.UseCustomCharset = useCustomCharset;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetQrCodeSize.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:设置二维码尺寸
10 | ///
11 | public class EscPosSetQrCodeSize : EscPosCommand
12 | {
13 | public byte Size { get; set; }
14 |
15 | public override byte[] GetBytes()
16 | {
17 | return new byte[] { GS, 0x28, 0x6B, 0x03, 0x00, 0x31, 0x43, this.Size };
18 | }
19 |
20 | ///
21 | ///
22 | ///
23 | /// 二维码尺寸(1-16)
24 | public EscPosSetQrCodeSize(byte size)
25 | {
26 | if (size < 1 || size > 16)
27 | throw new ArgumentOutOfRangeException("二维码尺寸只能在1-16之间");
28 | this.Size = size;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/Printer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper
7 | {
8 | public abstract class Printer
9 | {
10 | ///
11 | /// 已连接
12 | ///
13 | public abstract bool Connected { get; }
14 |
15 | ///
16 | /// 发送数据
17 | ///
18 | /// 数据
19 | public abstract void WriteRaw(byte[] data);
20 |
21 | ///
22 | /// 发送ESC/POS指令
23 | ///
24 | /// ESC/POS指令
25 | public abstract void WriteEscPos(params EscPos.EscPosCommand[] commands);
26 |
27 | ///
28 | /// 连接
29 | ///
30 | public abstract void Connect();
31 |
32 | ///
33 | /// 断开连接
34 | ///
35 | public abstract void Disconnect();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosQrCode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:二维码
10 | ///
11 | public class EscPosQrCode : EscPosCommand
12 | {
13 | public string Content { get; set; }
14 |
15 | public override byte[] GetBytes()
16 | {
17 | List list = new List();
18 | list.AddRange(new byte[] { GS, 0x28, 0x6B, (byte)(this.Content.Length + 3), 0x00, 0x31, 0x50, 0x30 });
19 | list.AddRange(Encoding.UTF8.GetBytes(Content));
20 | return list.ToArray();
21 | }
22 |
23 | ///
24 | ///
25 | ///
26 | /// 二维码内容(最长128字节)
27 | public EscPosQrCode(string content)
28 | {
29 | if (content.Length > 128)
30 | throw new ArgumentOutOfRangeException("content", "数据超长, 最长128字节");
31 | this.Content = content;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("ThermalPrinterWrapper")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ThermalPrinterWrapper")]
13 | [assembly: AssemblyCopyright("By.whc2001")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("154c4847-b764-4d73-843a-d68d20c6c23a")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetBarcodeLineWidth.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// 条码基本线条宽度
10 | ///
11 | public enum BarcodeLineWidth : byte
12 | {
13 | ///
14 | /// 窄
15 | ///
16 | NARROW = 2,
17 |
18 | ///
19 | /// 宽
20 | ///
21 | WIDE = 3,
22 | }
23 |
24 | ///
25 | /// ESCPOS指令:设置条形码宽度
26 | ///
27 | public class EscPosSetBarcodeLineWidth : EscPosCommand
28 | {
29 | public BarcodeLineWidth Width { get; set; }
30 |
31 | public override byte[] GetBytes()
32 | {
33 | return new byte[] { GS, 0x77, (byte)this.Width };
34 | }
35 |
36 | ///
37 | ///
38 | ///
39 | /// 条码基本线条宽度
40 | public EscPosSetBarcodeLineWidth(BarcodeLineWidth width)
41 | {
42 | this.Width = width;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosKickCashdrawer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// ESCPOS指令:钱箱控制脉冲
10 | ///
11 | public class EscPosKickCashdrawer : EscPosCommand
12 | {
13 | public byte OnDutation { get; set; }
14 | public byte OffDutation { get; set; }
15 |
16 | public override byte[] GetBytes()
17 | {
18 | return new byte[] { ESC, 0x70, 0x00, this.OnDutation, this.OffDutation };
19 | }
20 |
21 | public EscPosKickCashdrawer()
22 | {
23 | this.OnDutation = 0x3C;
24 | this.OffDutation = 0xFF;
25 | }
26 |
27 | ///
28 | ///
29 | ///
30 | /// 钱箱信号开启时间
31 | /// 钱箱信号关闭时间
32 | public EscPosKickCashdrawer(byte onDuration, byte offDuration)
33 | {
34 | this.OnDutation = onDuration;
35 | this.OffDutation = offDuration;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27004.2002
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThermalPrinterWrapper", "ThermalPrinterWrapper\ThermalPrinterWrapper.csproj", "{154C4847-B764-4D73-843A-D68D20C6C23A}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {154C4847-B764-4D73-843A-D68D20C6C23A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {154C4847-B764-4D73-843A-D68D20C6C23A}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {154C4847-B764-4D73-843A-D68D20C6C23A}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {154C4847-B764-4D73-843A-D68D20C6C23A}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {393DF9A1-5C20-43AE-992B-21EF441452C6}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetLineAlignment.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// 输出对齐方式
10 | ///
11 | public enum LineAlignment : byte
12 | {
13 | ///
14 | /// 左对齐
15 | ///
16 | LEFT = 0,
17 |
18 | ///
19 | /// 居中对齐
20 | ///
21 | MIDDLE = 1,
22 |
23 | ///
24 | /// 右对齐
25 | ///
26 | RIGHT = 2
27 | }
28 |
29 | ///
30 | /// ESCPOS指令:设置输出对齐方式
31 | ///
32 | public class EscPosSetLineAlignment : EscPosCommand
33 | {
34 | public LineAlignment Alignment { get; set; }
35 |
36 | public override byte[] GetBytes()
37 | {
38 | return new byte[] { ESC, 0x61, (byte)this.Alignment };
39 | }
40 |
41 | ///
42 | ///
43 | ///
44 | /// 输出对齐方式
45 | public EscPosSetLineAlignment(LineAlignment alignment)
46 | {
47 | this.Alignment = alignment;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetBarcodeHriPosition.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// 条码文本(HRI)位置
10 | ///
11 | public enum BarcodeHriPosition : byte
12 | {
13 | ///
14 | /// 不打印
15 | ///
16 | DISABLED = 0,
17 |
18 | ///
19 | /// 在条码上方
20 | ///
21 | ABOVE = 1,
22 |
23 | ///
24 | /// 在条码下方
25 | ///
26 | BELOW = 2,
27 |
28 | ///
29 | /// 在条码上方和下方
30 | ///
31 | ABOVE_AND_BELOW = 3
32 | }
33 |
34 | ///
35 | /// ESCPOS指令:设定条码对应的字符(HRI)打印方式
36 | ///
37 | public class EscPosSetBarcodeHriPosition : EscPosCommand
38 | {
39 | public BarcodeHriPosition Position { get; set; }
40 |
41 | public override byte[] GetBytes()
42 | {
43 | return new byte[] { GS, 0x48, (byte)this.Position };
44 | }
45 |
46 | ///
47 | ///
48 | ///
49 | /// 条码位置
50 | public EscPosSetBarcodeHriPosition(BarcodeHriPosition position)
51 | {
52 | this.Position = position;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosSetTextStyle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | [Flags]
9 | public enum TextStyle : byte
10 | {
11 | ///
12 | /// 反白
13 | ///
14 | INVERT = 0x01,
15 |
16 | ///
17 | /// 上下倒置
18 | ///
19 | UPSIDE_DOWN = 0x02,
20 |
21 | ///
22 | /// 加粗
23 | ///
24 | BOLD = 0x04,
25 |
26 | ///
27 | /// 双倍高度
28 | ///
29 | DOUBLE_HEIGHT = 0x08,
30 |
31 | ///
32 | /// 双倍宽度
33 | ///
34 | DOUBLE_WIDTH = 0x10,
35 |
36 | ///
37 | /// 删除线
38 | ///
39 | STROKE = 0x20
40 | }
41 |
42 | ///
43 | /// ESCPOS指令:设置打印字符模式
44 | ///
45 | public class EscPosSetTextStyle : EscPosCommand
46 | {
47 | public TextStyle Style { get; set; }
48 |
49 | public override byte[] GetBytes()
50 | {
51 | return new byte[] { ESC, 0x33, (byte)this.Style };
52 | }
53 |
54 | ///
55 | ///
56 | ///
57 | /// 打印字符模式(位标识可叠加)
58 | public EscPosSetTextStyle(TextStyle style)
59 | {
60 | this.Style = style;
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosPlainString.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// 普通文本
10 | ///
11 | public class EscPosPlainString : EscPosCommand
12 | {
13 | public Encoding SourceEncoding { get; set; }
14 | public Encoding DestinationEncoding { get; set; }
15 | public string StringContent { get; set; }
16 |
17 | public override byte[] GetBytes()
18 | {
19 | return Encoding.Convert(SourceEncoding, DestinationEncoding, SourceEncoding.GetBytes(StringContent));
20 | }
21 |
22 | ///
23 | ///
24 | ///
25 | /// 文本字串
26 | public EscPosPlainString(string str)
27 | {
28 | this.StringContent = str;
29 | this.SourceEncoding = Encoding.Default;
30 | this.DestinationEncoding = GBK;
31 | }
32 |
33 | ///
34 | ///
35 | ///
36 | /// 文本字串
37 | /// 源编码
38 | public EscPosPlainString(string str, Encoding source)
39 | {
40 | this.StringContent = str;
41 | this.SourceEncoding = source;
42 | this.DestinationEncoding = GBK;
43 | }
44 |
45 | ///
46 | ///
47 | ///
48 | /// 文本字串
49 | /// 源编码
50 | /// 目标编码
51 | public EscPosPlainString(string str, Encoding source, Encoding destination)
52 | {
53 | this.StringContent = str;
54 | this.SourceEncoding = source;
55 | this.DestinationEncoding = destination;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/EscPos/EscPosBarcode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ThermalPrinterWrapper.EscPos
7 | {
8 | ///
9 | /// 条码类型
10 | ///
11 | public enum BarcodeType : byte
12 | {
13 | UPC_A = 0,
14 | UPC_E = 1,
15 | EAN13 = 2,
16 | EAN8 = 3,
17 | CODE39 = 4,
18 | I25 = 5,
19 | CODEBAR = 6,
20 | CODE93 = 7,
21 | CODE128 = 8,
22 | CODE11 = 9,
23 | MSI = 10,
24 | }
25 |
26 | ///
27 | /// ESCPOS指令:条形码
28 | ///
29 | public class EscPosBarcode : EscPosCommand
30 | {
31 | public BarcodeType Type { get; set; }
32 |
33 | public string Content { get; set; }
34 |
35 | private bool IsContentValid(BarcodeType type, string content)
36 | {
37 | switch(type)
38 | {
39 | case BarcodeType.UPC_A:
40 | case BarcodeType.UPC_E:
41 | return (content.Length == 11 || content.Length == 12) && (content.All(i => i >= 48 && i <= 57));
42 | case BarcodeType.EAN13:
43 | return (content.Length == 12 || content.Length == 13) && (content.All(i => i >= 48 && i <= 57));
44 | case BarcodeType.EAN8:
45 | return (content.Length == 7 || content.Length == 8) && (content.All(i => i >= 48 && i <= 57));
46 | case BarcodeType.CODE39:
47 | return content.All(i => (i >= 45 && i <= 57) || (i >= 65 && i <= 90) || i == 32 || i == 36 || i == 37 || i == 43);
48 | case BarcodeType.I25:
49 | return (content.Length % 2 == 0) && (content.All(i => i >= 48 && i <= 57));
50 | case BarcodeType.CODEBAR:
51 | return content.All(i => (i >= 45 && i <= 58) || (i >= 65 && i <= 68) || i == 36 || i == 43);
52 | case BarcodeType.CODE93:
53 | case BarcodeType.CODE128:
54 | return content.All(i => i >= 0 && i <= 127);
55 | case BarcodeType.CODE11:
56 | case BarcodeType.MSI:
57 | return content.All(i => i >= 48 && i <= 57);
58 | }
59 | return false;
60 | }
61 |
62 | public override byte[] GetBytes()
63 | {
64 | List list = new List();
65 | list.AddRange(new byte[] { GS, 0x6B, (byte)this.Type });
66 | list.AddRange(Encoding.ASCII.GetBytes(Content));
67 | list.Add(0x00);
68 | return list.ToArray();
69 | }
70 |
71 | ///
72 | ///
73 | ///
74 | /// 条码类型
75 | /// 条码内容
76 | public EscPosBarcode(BarcodeType type, string content)
77 | {
78 | if (!IsContentValid(type, content))
79 | throw new ArgumentException("条码内容不符合选择类型的规定");
80 | this.Type = type;
81 | this.Content = content;
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/SerialPrinter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using System.IO.Ports;
7 | using ThermalPrinterWrapper.EscPos;
8 |
9 | namespace ThermalPrinterWrapper
10 | {
11 | public class SerialPrinter : Printer
12 | {
13 | private SerialPort serial;
14 |
15 | ///
16 | /// 串行端口
17 | ///
18 | public string Port { get; set; }
19 |
20 | ///
21 | /// 波特率
22 | ///
23 | public int Baud { get; set; }
24 |
25 | ///
26 | /// 已连接
27 | ///
28 | public override bool Connected => serial != null && serial.IsOpen;
29 |
30 | ///
31 | /// 获得所有可用串行端口
32 | ///
33 | ///
34 | public string[] GetSerialPortNames()
35 | => SerialPort.GetPortNames();
36 |
37 | ///
38 | /// 连接设备
39 | ///
40 | public override void Connect()
41 | {
42 | if (serial.IsOpen)
43 | throw new InvalidOperationException("已连接, 请先断开");
44 | if (string.IsNullOrEmpty(Port))
45 | throw new ArgumentNullException("Port", "端口名称为空");
46 | if(Baud <= 0)
47 | throw new ArgumentOutOfRangeException("Baud", "波特率必须大于等于0");
48 | serial.PortName = Port;
49 | serial.BaudRate = Baud;
50 | serial.Open();
51 | }
52 |
53 | ///
54 | /// 断开连接
55 | ///
56 | public override void Disconnect()
57 | {
58 | serial.Dispose();
59 | }
60 |
61 | ///
62 | /// 发送数据
63 | ///
64 | /// 数据
65 | public override void WriteRaw(byte[] data)
66 | {
67 | try
68 | {
69 | serial.Write(data, 0, data.Length);
70 | }
71 | catch
72 | {
73 | Disconnect();
74 | throw new InvalidOperationException("设备未就绪, 不能写入");
75 | }
76 | }
77 |
78 | ///
79 | /// 发送ESC/POS指令
80 | ///
81 | /// ESC/POS指令
82 | public override void WriteEscPos(params EscPosCommand[] commands)
83 | {
84 | List bytes = new List();
85 | foreach (EscPosCommand cmd in commands)
86 | bytes.AddRange(cmd.GetBytes());
87 | WriteRaw(bytes.ToArray());
88 | }
89 |
90 | public SerialPrinter()
91 | {
92 | serial = new SerialPort();
93 | }
94 |
95 | public SerialPrinter(string port) : this()
96 | {
97 | Port = port;
98 | }
99 |
100 | public SerialPrinter(string port, int baud) : this(port)
101 | {
102 | Baud = baud;
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/ThermalPrinterWrapper.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {154C4847-B764-4D73-843A-D68D20C6C23A}
8 | Library
9 | Properties
10 | ThermalPrinterWrapper
11 | ThermalPrinterWrapper
12 | v3.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\packages\32feet.NET.3.5.0.0\lib\net\InTheHand.Net.Personal.dll
35 |
36 |
37 |
38 |
39 | False
40 | ..\..\..\..\..\..\..\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/UsbPrinter.cs:
--------------------------------------------------------------------------------
1 | //https://support.microsoft.com/en-us/help/322091/how-to-send-raw-data-to-a-printer-by-using-visual-c--net
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Drawing.Printing;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Runtime.InteropServices;
9 | using System.Text;
10 | using ThermalPrinterWrapper.EscPos;
11 |
12 | namespace ThermalPrinterWrapper
13 | {
14 | public class UsbPrinter : Printer
15 | {
16 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
17 | private class DOCINFOA
18 | {
19 | [MarshalAs(UnmanagedType.LPStr)] public string pDocName;
20 | [MarshalAs(UnmanagedType.LPStr)] public string pOutputFile;
21 | [MarshalAs(UnmanagedType.LPStr)] public string pDataType;
22 | }
23 | [DllImport("winspool.drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
24 | private static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string szPrinter, out IntPtr hPrinter, IntPtr pd);
25 |
26 | [DllImport("winspool.drv", EntryPoint = "ClosePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
27 | private static extern bool ClosePrinter(IntPtr hPrinter);
28 |
29 | [DllImport("winspool.drv", EntryPoint = "StartDocPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
30 | private static extern bool StartDocPrinter(IntPtr hPrinter, Int32 level, [In, MarshalAs(UnmanagedType.LPStruct)] DOCINFOA di);
31 |
32 | [DllImport("winspool.drv", EntryPoint = "EndDocPrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
33 | private static extern bool EndDocPrinter(IntPtr hPrinter);
34 |
35 | [DllImport("winspool.drv", EntryPoint = "StartPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
36 | private static extern bool StartPagePrinter(IntPtr hPrinter);
37 |
38 | [DllImport("winspool.drv", EntryPoint = "EndPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
39 | private static extern bool EndPagePrinter(IntPtr hPrinter);
40 |
41 | [DllImport("winspool.drv", EntryPoint = "WritePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
42 | private static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, Int32 dwCount, out Int32 dwWritten);
43 |
44 | private IntPtr printerHandle = new IntPtr(0);
45 |
46 | public string PrinterName { get; set; }
47 |
48 | public override bool Connected => printerHandle != IntPtr.Zero;
49 |
50 | public void SendBytesToPrinter(string szPrinterName, byte[] data)
51 | {
52 | int dwWritten = 0;
53 | IntPtr dataPtr = new IntPtr(0);
54 | DOCINFOA di = new DOCINFOA();
55 | di.pDocName = "EscPosData";
56 | di.pDataType = "RAW";
57 |
58 | dataPtr = Marshal.AllocCoTaskMem(data.Length);
59 | Marshal.Copy(data, 0, dataPtr, data.Length);
60 |
61 | StartDocPrinter(printerHandle, 1, di);
62 | StartPagePrinter(printerHandle);
63 | bool success = WritePrinter(printerHandle, dataPtr, data.Length, out dwWritten);
64 |
65 | bool endPageSuccess = EndPagePrinter(printerHandle);
66 | bool endDocSuccess = EndDocPrinter(printerHandle);
67 | Marshal.FreeCoTaskMem(dataPtr);
68 |
69 | if(!success)
70 | throw new InvalidOperationException("设备未就绪, 不能写入");
71 | }
72 |
73 | public override void Connect()
74 | {
75 | if (false)
76 | throw new InvalidOperationException("打开失败: 打印机不存在或离线");
77 | else
78 | OpenPrinter(PrinterName.Normalize(), out printerHandle, IntPtr.Zero);
79 | }
80 |
81 | public override void Disconnect()
82 | {
83 | if (Connected)
84 | ClosePrinter(printerHandle);
85 | printerHandle = IntPtr.Zero;
86 | }
87 |
88 | public override void WriteEscPos(params EscPosCommand[] commands)
89 | {
90 | List bytes = new List();
91 | foreach (EscPosCommand cmd in commands)
92 | bytes.AddRange(cmd.GetBytes());
93 | WriteRaw(bytes.ToArray());
94 | }
95 |
96 | public override void WriteRaw(byte[] data)
97 | {
98 | SendBytesToPrinter(PrinterName, data);
99 | }
100 | }
101 | }
--------------------------------------------------------------------------------
/ThermalPrinterWrapper/BluetoothPrinter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using InTheHand.Net.Bluetooth;
6 | using InTheHand.Net.Sockets;
7 | using InTheHand.Net.Ports;
8 | using InTheHand.Net;
9 | using System.IO;
10 | using ThermalPrinterWrapper.EscPos;
11 |
12 | namespace ThermalPrinterWrapper
13 | {
14 | ///
15 | /// 蓝牙打印机
16 | ///
17 | public class BluetoothPrinter : Printer
18 | {
19 | private BluetoothAddress address;
20 | private BluetoothDeviceInfo device;
21 | private BluetoothClient client;
22 | private Stream clientStream;
23 |
24 | ///
25 | /// 选择的设备地址
26 | ///
27 | public byte[] Address { get; set; }
28 |
29 | public override bool Connected => client != null && client.Connected;
30 |
31 | //实例化BluetoothClient
32 | private void InitClient()
33 | {
34 | if (client != null)
35 | return;
36 | try
37 | {
38 | client = new BluetoothClient();
39 | }
40 | catch
41 | {
42 | throw new NotSupportedException("无法找到支持的蓝牙软件栈, 请考虑使用微软自带的蓝牙驱动");
43 | }
44 | }
45 |
46 | ///
47 | /// 搜索设备
48 | ///
49 | ///
50 | public Dictionary DiscoverDevice()
51 | {
52 | InitClient();
53 | BluetoothDeviceInfo[] devices = client.DiscoverDevices(int.MaxValue, true, true, true, false);
54 | return devices.ToDictionary(k => k.DeviceName, v => v.DeviceAddress.ToByteArray());
55 | }
56 |
57 | ///
58 | /// 连接设备
59 | ///
60 | public override void Connect()
61 | {
62 | if (Address == null)
63 | throw new InvalidOperationException("设备地址为空");
64 | Connect(Address);
65 | }
66 |
67 | ///
68 | /// 连接设备
69 | ///
70 | /// 设备地址
71 | /// 设备PIN码
72 | public void Connect(byte[] deviceAddress, string pin = "0000")
73 | {
74 | if (client != null && client.Connected)
75 | throw new InvalidOperationException("已连接, 请先断开");
76 | Address = deviceAddress;
77 | address = new BluetoothAddress(Address);
78 | device = new BluetoothDeviceInfo(address);
79 | if (device == null)
80 | throw new ArgumentException("无法找到指定地址的蓝牙设备");
81 | try
82 | {
83 | device.SetServiceState(BluetoothService.SerialPort, true);
84 | }
85 | catch
86 | {
87 | throw new InvalidOperationException("设备不支持SPP连接方式");
88 | }
89 | if (!device.Authenticated)
90 | if (!BluetoothSecurity.PairRequest(address, pin))
91 | throw new InvalidOperationException("配对失败");
92 | try
93 | {
94 | client.Connect(address, BluetoothService.SerialPort);
95 | clientStream = client.GetStream();
96 | }
97 | catch(Exception ex)
98 | {
99 | throw new InvalidOperationException("连接失败");
100 | }
101 | }
102 |
103 | ///
104 | /// 断开设备
105 | ///
106 | public override void Disconnect()
107 | {
108 | if (clientStream != null)
109 | {
110 | clientStream.Dispose();
111 | clientStream = null;
112 | }
113 | if (client != null)
114 | {
115 | client.Close();
116 | client.Dispose();
117 | }
118 | client = null;
119 | device = null;
120 | address = null;
121 | }
122 |
123 | ///
124 | /// 发送数据
125 | ///
126 | /// 数据
127 | public override void WriteRaw(byte[] data)
128 | {
129 | try
130 | {
131 | clientStream.Write(data, 0, data.Length);
132 | clientStream.Flush();
133 | }
134 | catch
135 | {
136 | Disconnect();
137 | throw new InvalidOperationException("设备未就绪, 不能写入");
138 | }
139 | }
140 |
141 | ///
142 | /// 发送ESC/POS指令
143 | ///
144 | /// ESC/POS指令
145 | public override void WriteEscPos(params EscPosCommand[] commands)
146 | {
147 | List bytes = new List();
148 | foreach (EscPosCommand cmd in commands)
149 | bytes.AddRange(cmd.GetBytes());
150 | WriteRaw(bytes.ToArray());
151 | }
152 |
153 | public BluetoothPrinter()
154 | {
155 | InitClient();
156 | }
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # Benchmark Results
46 | BenchmarkDotNet.Artifacts/
47 |
48 | # .NET Core
49 | project.lock.json
50 | project.fragment.lock.json
51 | artifacts/
52 | **/Properties/launchSettings.json
53 |
54 | *_i.c
55 | *_p.c
56 | *_i.h
57 | *.ilk
58 | *.meta
59 | *.obj
60 | *.pch
61 | *.pdb
62 | *.pgc
63 | *.pgd
64 | *.rsp
65 | *.sbr
66 | *.tlb
67 | *.tli
68 | *.tlh
69 | *.tmp
70 | *.tmp_proj
71 | *.log
72 | *.vspscc
73 | *.vssscc
74 | .builds
75 | *.pidb
76 | *.svclog
77 | *.scc
78 |
79 | # Chutzpah Test files
80 | _Chutzpah*
81 |
82 | # Visual C++ cache files
83 | ipch/
84 | *.aps
85 | *.ncb
86 | *.opendb
87 | *.opensdf
88 | *.sdf
89 | *.cachefile
90 | *.VC.db
91 | *.VC.VC.opendb
92 |
93 | # Visual Studio profiler
94 | *.psess
95 | *.vsp
96 | *.vspx
97 | *.sap
98 |
99 | # TFS 2012 Local Workspace
100 | $tf/
101 |
102 | # Guidance Automation Toolkit
103 | *.gpState
104 |
105 | # ReSharper is a .NET coding add-in
106 | _ReSharper*/
107 | *.[Rr]e[Ss]harper
108 | *.DotSettings.user
109 |
110 | # JustCode is a .NET coding add-in
111 | .JustCode
112 |
113 | # TeamCity is a build add-in
114 | _TeamCity*
115 |
116 | # DotCover is a Code Coverage Tool
117 | *.dotCover
118 |
119 | # AxoCover is a Code Coverage Tool
120 | .axoCover/*
121 | !.axoCover/settings.json
122 |
123 | # Visual Studio code coverage results
124 | *.coverage
125 | *.coveragexml
126 |
127 | # NCrunch
128 | _NCrunch_*
129 | .*crunch*.local.xml
130 | nCrunchTemp_*
131 |
132 | # MightyMoose
133 | *.mm.*
134 | AutoTest.Net/
135 |
136 | # Web workbench (sass)
137 | .sass-cache/
138 |
139 | # Installshield output folder
140 | [Ee]xpress/
141 |
142 | # DocProject is a documentation generator add-in
143 | DocProject/buildhelp/
144 | DocProject/Help/*.HxT
145 | DocProject/Help/*.HxC
146 | DocProject/Help/*.hhc
147 | DocProject/Help/*.hhk
148 | DocProject/Help/*.hhp
149 | DocProject/Help/Html2
150 | DocProject/Help/html
151 |
152 | # Click-Once directory
153 | publish/
154 |
155 | # Publish Web Output
156 | *.[Pp]ublish.xml
157 | *.azurePubxml
158 | # Note: Comment the next line if you want to checkin your web deploy settings,
159 | # but database connection strings (with potential passwords) will be unencrypted
160 | *.pubxml
161 | *.publishproj
162 |
163 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
164 | # checkin your Azure Web App publish settings, but sensitive information contained
165 | # in these scripts will be unencrypted
166 | PublishScripts/
167 |
168 | # NuGet Packages
169 | *.nupkg
170 | # The packages folder can be ignored because of Package Restore
171 | **/packages/*
172 | # except build/, which is used as an MSBuild target.
173 | !**/packages/build/
174 | # Uncomment if necessary however generally it will be regenerated when needed
175 | #!**/packages/repositories.config
176 | # NuGet v3's project.json files produces more ignorable files
177 | *.nuget.props
178 | *.nuget.targets
179 |
180 | # Microsoft Azure Build Output
181 | csx/
182 | *.build.csdef
183 |
184 | # Microsoft Azure Emulator
185 | ecf/
186 | rcf/
187 |
188 | # Windows Store app package directories and files
189 | AppPackages/
190 | BundleArtifacts/
191 | Package.StoreAssociation.xml
192 | _pkginfo.txt
193 | *.appx
194 |
195 | # Visual Studio cache files
196 | # files ending in .cache can be ignored
197 | *.[Cc]ache
198 | # but keep track of directories ending in .cache
199 | !*.[Cc]ache/
200 |
201 | # Others
202 | ClientBin/
203 | ~$*
204 | *~
205 | *.dbmdl
206 | *.dbproj.schemaview
207 | *.jfm
208 | *.pfx
209 | *.publishsettings
210 | orleans.codegen.cs
211 |
212 | # Since there are multiple workflows, uncomment next line to ignore bower_components
213 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
214 | #bower_components/
215 |
216 | # RIA/Silverlight projects
217 | Generated_Code/
218 |
219 | # Backup & report files from converting an old project file
220 | # to a newer Visual Studio version. Backup files are not needed,
221 | # because we have git ;-)
222 | _UpgradeReport_Files/
223 | Backup*/
224 | UpgradeLog*.XML
225 | UpgradeLog*.htm
226 |
227 | # SQL Server files
228 | *.mdf
229 | *.ldf
230 | *.ndf
231 |
232 | # Business Intelligence projects
233 | *.rdl.data
234 | *.bim.layout
235 | *.bim_*.settings
236 |
237 | # Microsoft Fakes
238 | FakesAssemblies/
239 |
240 | # GhostDoc plugin setting file
241 | *.GhostDoc.xml
242 |
243 | # Node.js Tools for Visual Studio
244 | .ntvs_analysis.dat
245 | node_modules/
246 |
247 | # Typescript v1 declaration files
248 | typings/
249 |
250 | # Visual Studio 6 build log
251 | *.plg
252 |
253 | # Visual Studio 6 workspace options file
254 | *.opt
255 |
256 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
257 | *.vbw
258 |
259 | # Visual Studio LightSwitch build output
260 | **/*.HTMLClient/GeneratedArtifacts
261 | **/*.DesktopClient/GeneratedArtifacts
262 | **/*.DesktopClient/ModelManifest.xml
263 | **/*.Server/GeneratedArtifacts
264 | **/*.Server/ModelManifest.xml
265 | _Pvt_Extensions
266 |
267 | # Paket dependency manager
268 | .paket/paket.exe
269 | paket-files/
270 |
271 | # FAKE - F# Make
272 | .fake/
273 |
274 | # JetBrains Rider
275 | .idea/
276 | *.sln.iml
277 |
278 | # CodeRush
279 | .cr/
280 |
281 | # Python Tools for Visual Studio (PTVS)
282 | __pycache__/
283 | *.pyc
284 |
285 | # Cake - Uncomment if you are using it
286 | # tools/**
287 | # !tools/packages.config
288 |
289 | # Tabs Studio
290 | *.tss
291 |
292 | # Telerik's JustMock configuration file
293 | *.jmconfig
294 |
295 | # BizTalk build output
296 | *.btp.cs
297 | *.btm.cs
298 | *.odx.cs
299 | *.xsd.cs
300 |
--------------------------------------------------------------------------------