Browse Source

commit: import LinePrinter

HOME 4 years ago
parent
commit
85b6f69d15

+ 6 - 0
LinePrinterPoC/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
+    </startup>
+</configuration>

+ 150 - 0
LinePrinterPoC/LinePrinter.cs

@@ -0,0 +1,150 @@
+/*
+ *  LPrinter - A simple line printer class in C#
+ *  ============================================
+ *
+ *  Written by Antonino Porcino, iz8bly@yahoo.it
+ *
+ *  26-sep-2008, public domain.
+ *
+ *
+ *  some useful print codes:
+ *  ========================
+ *    12 = FF (form feed)
+ *    14 = enlarged on
+ *    20 = enlarged off
+ *    15 = compress on
+ *    18 = compress off
+ *    ESC + "E" = bold on
+ *    ESC + "F" = bold off
+ */
+
+using System;
+using System.Drawing.Printing;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Windows.Forms;
+
+namespace LinePrinterPoC
+{
+    internal class LinePrinter
+    {
+        // Structure and API declarions:
+        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
+        public class DOCINFOA
+        {
+            [MarshalAs(UnmanagedType.LPStr)]
+            public string pDocName;
+
+            [MarshalAs(UnmanagedType.LPStr)]
+            public string pOutputFile;
+
+            [MarshalAs(UnmanagedType.LPStr)]
+            public string pDataType;
+        }
+
+        [DllImport("winspool.Drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
+        public static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string szPrinter, out IntPtr hPrinter, IntPtr pd);
+
+        [DllImport("winspool.Drv", EntryPoint = "ClosePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
+        public static extern bool ClosePrinter(IntPtr hPrinter);
+
+        [DllImport("winspool.Drv", EntryPoint = "StartDocPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
+        public static extern bool StartDocPrinter(IntPtr hPrinter, int level, [In, MarshalAs(UnmanagedType.LPStruct)] DOCINFOA di);
+
+        [DllImport("winspool.Drv", EntryPoint = "EndDocPrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
+        public static extern bool EndDocPrinter(IntPtr hPrinter);
+
+        [DllImport("winspool.Drv", EntryPoint = "StartPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
+        public static extern bool StartPagePrinter(IntPtr hPrinter);
+
+        [DllImport("winspool.Drv", EntryPoint = "EndPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
+        public static extern bool EndPagePrinter(IntPtr hPrinter);
+
+        [DllImport("winspool.Drv", EntryPoint = "WritePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
+        public static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, int dwCount, out int dwWritten);
+
+        /*=================================================*/
+
+        private IntPtr HandlePrinter;
+        private PrinterSettings ps;
+
+        public LinePrinter()
+        {
+            HandlePrinter = IntPtr.Zero;
+            ps = new PrinterSettings();
+        }
+
+        public string PrinterName
+        {
+            get
+            {
+                return ps.PrinterName;
+            }
+            set
+            {
+                ps.PrinterName = value;
+            }
+        }
+
+        public bool ChoosePrinter(IWin32Window parent = null)
+        {
+            var pd = new PrintDialog
+            {
+                PrinterSettings = ps
+            };
+
+            if (pd.ShowDialog(parent) != DialogResult.OK)
+                return false;
+
+            ps = pd.PrinterSettings;
+            return true;
+        }
+
+        public bool Open(string docName)
+        {
+            // see if printer is already open
+            if (HandlePrinter != IntPtr.Zero) return false;
+
+            // opens the printer
+            var risp = OpenPrinter(ps.PrinterName, out HandlePrinter, IntPtr.Zero);
+            if (risp == false) return false;
+
+            // starts a print job
+            var docInfo = new DOCINFOA
+            {
+                pDocName = docName,
+                pOutputFile = null,
+                pDataType = "RAW"
+            };
+
+            if (!StartDocPrinter(HandlePrinter, 1, docInfo))
+                return false;
+
+            StartPagePrinter(HandlePrinter); //starts a page
+            return true;
+        }
+
+        public bool Close()
+        {
+            if (HandlePrinter == IntPtr.Zero) return false;
+            if (!EndPagePrinter(HandlePrinter)) return false;
+            if (!EndDocPrinter(HandlePrinter)) return false;
+            if (!ClosePrinter(HandlePrinter)) return false;
+            HandlePrinter = IntPtr.Zero;
+            return true;
+        }
+
+        public bool Print(string outputstring)
+        {
+            if (HandlePrinter == IntPtr.Zero) return false;
+            IntPtr buf = Marshal.StringToCoTaskMemAnsi(outputstring);
+
+            Int32 done;
+            bool ok = WritePrinter(HandlePrinter, buf, Encoding.Default.GetByteCount(outputstring), out done);
+
+            Marshal.FreeCoTaskMem(buf);
+
+            return ok;
+        }
+    }
+}

+ 108 - 0
LinePrinterPoC/LinePrinterForm.Designer.cs

@@ -0,0 +1,108 @@
+using System.Windows.Forms;
+
+namespace LinePrinterPoC
+{
+    partial class LinePrinterForm
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows 窗体设计器生成的代码
+
+        /// <summary>
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LinePrinterForm));
+            this.MainToolBar = new System.Windows.Forms.ToolStrip();
+            this.ChooseButton = new System.Windows.Forms.ToolStripButton();
+            this.PrinterLabel = new System.Windows.Forms.ToolStripLabel();
+            this.PrintButton = new System.Windows.Forms.ToolStripButton();
+            this.MainToolBar.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // MainToolBar
+            // 
+            this.MainToolBar.Location = new System.Drawing.Point(0, 0);
+            this.MainToolBar.Name = "MainToolBar";
+            this.MainToolBar.Size = new System.Drawing.Size(800, 25);
+            this.MainToolBar.TabIndex = 0;
+            this.MainToolBar.Text = "toolStrip1";
+            this.MainToolBar.Items.AddRange(new ToolStripItem[]
+            {
+
+                ChooseButton,
+                PrinterLabel,
+                PrintButton
+
+
+            });
+            // 
+            // ChooseButton
+            // 
+            this.ChooseButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
+            this.ChooseButton.Image = ((System.Drawing.Image)(resources.GetObject("ChooseButton.Image")));
+            this.ChooseButton.ImageTransparentColor = System.Drawing.Color.Magenta;
+            this.ChooseButton.Name = "ChooseButton";
+            this.ChooseButton.Size = new System.Drawing.Size(98, 22);
+            this.ChooseButton.Text = "Choose Printer";
+            this.ChooseButton.Click += new System.EventHandler(this.ChooseButton_Click);
+            // 
+            // PrinterLabel
+            // 
+            this.PrinterLabel.Name = "PrinterLabel";
+            this.PrinterLabel.Size = new System.Drawing.Size(90, 22);
+            this.PrinterLabel.Text = "[Printer name]";
+            // 
+            // PrintButton
+            // 
+            this.PrintButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
+            this.PrintButton.Image = ((System.Drawing.Image)(resources.GetObject("PrintButton.Image")));
+            this.PrintButton.ImageTransparentColor = System.Drawing.Color.Magenta;
+            this.PrintButton.Name = "PrintButton";
+            this.PrintButton.Size = new System.Drawing.Size(38, 22);
+            this.PrintButton.Text = "Print";
+            this.PrintButton.Click += new System.EventHandler(this.PrintButton_Click);
+            // 
+            // LinePrinterForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(800, 450);
+            this.Controls.Add(this.MainToolBar);
+            this.Name = "LinePrinterForm";
+            this.Text = "Line Printer PoC";
+            this.Shown += new System.EventHandler(this.LinePrinterForm_Shown);
+            this.MainToolBar.ResumeLayout(false);
+            this.MainToolBar.PerformLayout();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.ToolStrip MainToolBar;
+        private System.Windows.Forms.ToolStripButton ChooseButton;
+        private System.Windows.Forms.ToolStripLabel PrinterLabel;
+        private System.Windows.Forms.ToolStripButton PrintButton;
+    }
+}
+

+ 47 - 0
LinePrinterPoC/LinePrinterForm.cs

@@ -0,0 +1,47 @@
+using ScintillaNET;
+using System;
+using System.Windows.Forms;
+
+namespace LinePrinterPoC
+{
+    public partial class LinePrinterForm : Form
+    {
+        private Scintilla _textBox;
+        private LinePrinter _printer;
+
+        public LinePrinterForm()
+        {
+            InitializeComponent();
+        }
+
+        private void LinePrinterForm_Shown(object sender, EventArgs e)
+        {
+            _printer = new LinePrinter();
+            _textBox = new Scintilla { Dock = DockStyle.Fill };
+            Controls.Add(_textBox);
+            _textBox.BringToFront();
+        }
+
+        private void ChooseButton_Click(object sender, EventArgs e)
+        {
+            if (_printer.ChoosePrinter(this)) PrinterLabel.Text = _printer.PrinterName;
+        }
+
+        private void PrintButton_Click(object sender, EventArgs e)
+        {
+            if (false == _printer.Open("print doc"))
+            {
+                MessageBox.Show("Open printer fail");
+                return;
+            }
+
+            MessageBox.Show(
+                _printer.Print(_textBox.Text)
+                    ? "OK"
+                    : "Fail"
+            );
+
+            _printer.Close();
+        }
+    }
+}

+ 154 - 0
LinePrinterPoC/LinePrinterForm.resx

@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <metadata name="MainToolBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  <data name="ChooseButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+        YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
+        YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
+        0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
+        bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
+        VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
+        c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
+        Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
+        mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
+        kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
+        TgDQASA1MVpwzwAAAABJRU5ErkJggg==
+</value>
+  </data>
+  <data name="PrintButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+        YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
+        YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
+        0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
+        bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
+        VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
+        c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
+        Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
+        mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
+        kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
+        TgDQASA1MVpwzwAAAABJRU5ErkJggg==
+</value>
+  </data>
+</root>

+ 71 - 0
LinePrinterPoC/LinePrinterPoC.csproj

@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{3BF4BF09-3BEC-4E9B-BFBE-2FB830439D3B}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <RootNamespace>LinePrinterPoC</RootNamespace>
+    <AssemblyName>LinePrinterPoC</AssemblyName>
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="ScintillaNET, Version=3.6.3.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>C:\NuGetLocalRepo\jacobslusser.ScintillaNET.3.6.3\lib\net40\ScintillaNET.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="LinePrinter.cs" />
+    <Compile Include="LinePrinterForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="LinePrinterForm.Designer.cs">
+      <DependentUpon>LinePrinterForm.cs</DependentUpon>
+    </Compile>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <EmbeddedResource Include="LinePrinterForm.resx">
+      <DependentUpon>LinePrinterForm.cs</DependentUpon>
+    </EmbeddedResource>
+    <None Include="packages.config" />
+    <None Include="README.md" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 22 - 0
LinePrinterPoC/Program.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace LinePrinterPoC
+{
+    static class Program
+    {
+        /// <summary>
+        /// 应用程序的主入口点。
+        /// </summary>
+        [STAThread]
+        static void Main()
+        {
+            Application.EnableVisualStyles();
+            Application.SetCompatibleTextRenderingDefault(false);
+            Application.Run(new LinePrinterForm());
+        }
+    }
+}

+ 36 - 0
LinePrinterPoC/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("LinePrinterPoC")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("LinePrinterPoC")]
+[assembly: AssemblyCopyright("Copyright ©  2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("3bf4bf09-3bec-4e9b-bfbe-2fb830439d3b")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 5 - 0
LinePrinterPoC/README.md

@@ -0,0 +1,5 @@
+# LinePrinterPoC
+
+LinePrinter 源码引用自 [CodeProject](http://www.codeproject.com/Articles/29709/Line-Printer-Class-in-C) 作者是 Antonino Porcino
+
+本引用修正打印中文时,因字符编码长度计算错误而出现打印内容不完整的bug

+ 4 - 0
LinePrinterPoC/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="jacobslusser.ScintillaNET" version="3.6.3" targetFramework="net461" />
+</packages>

+ 6 - 0
NuGet.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?> 
+<configuration> 
+  <config> 
+    <add key="repositorypath" value="C:\NuGetLocalRepo" /> 
+  </config> 
+</configuration>

+ 7 - 0
PoC.sln

@@ -11,6 +11,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlWrapsPoC", "ControlW
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "@", "@", "{65C086E5-79F9-46DC-B5E2-110C480E0ECC}"
 	ProjectSection(SolutionItems) = preProject
+		NuGet.config = NuGet.config
 		README.md = README.md
 	EndProjectSection
 EndProject
@@ -20,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListViewNativeArrowIconPoC"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomUrlSchemeRegistrationPoC", "CustomUrlSchemeRegistrationPoC\CustomUrlSchemeRegistrationPoC.csproj", "{9C6A1213-F5F6-48B0-BCF9-599662FD91C3}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinePrinterPoC", "LinePrinterPoC\LinePrinterPoC.csproj", "{3BF4BF09-3BEC-4E9B-BFBE-2FB830439D3B}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -50,6 +53,10 @@ Global
 		{9C6A1213-F5F6-48B0-BCF9-599662FD91C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{9C6A1213-F5F6-48B0-BCF9-599662FD91C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{9C6A1213-F5F6-48B0-BCF9-599662FD91C3}.Release|Any CPU.Build.0 = Release|Any CPU
+		{3BF4BF09-3BEC-4E9B-BFBE-2FB830439D3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{3BF4BF09-3BEC-4E9B-BFBE-2FB830439D3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{3BF4BF09-3BEC-4E9B-BFBE-2FB830439D3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{3BF4BF09-3BEC-4E9B-BFBE-2FB830439D3B}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE