示例#1
0
        static public void ResetPrinterSettings(PackageComponent printComponent)
        {
            //this routine sends a binary payload that resets the Epson FX-890 printer back to desirable defaults (listed below)

            //nugget: embedding a binary file in the assembly for runtime retrieval
            //http://www.dotnetscraps.com/dotnetscraps/post/Insert-any-binary-file-in-C-assembly-and-extract-it-at-runtime.aspx
            //the other main thing to do is set the file's properties to "Embedded Resource"

            //reset_epson.bin is generated via "Epson Remote Configuration Manager"
            //download here: http://www.epson.com/cgi-bin/Store/support/supDetail.jsp?BV_UseBVCookie=yes&oid=23730&infoType=Downloads
            //(make sure to run it from a CMD.EXE with %TEMP% set to an accessible 8.3 path, long path names screw up the setup.exe since it's from the Win9x days, but it does still work on Win7!)
            //it's a Windows app that bundles all the special settings and fires them at the printer
            //i could find no other way to select "Normal Draft" out of USD, HSD, Draft
            //this binary file also sets the top-of-form position to the smallest value (0.167)
            //and defaults the pitch to 12cpi

            using (var resetEpson = AssemblyHelper.GetEmbeddedResource("reset_epson.bin"))
            {
                RawPrinterHelper.SendStreamToPrinter(
                    SettingsModel.Local[printComponent == PackageComponent.OrderForm ? "POPrinter" : "AbwPrinter"],
                    resetEpson);
            }
        }