• 大小: 6.91MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-18
  • 语言: C#
  • 标签: js  C#  

资源简介

静态网页通过js与本地C#应用程序基于webSocket实时通讯,调用本地打印机进行post小票打印。服务窗体可最小化托盘,请参考https://blog.csdn.net/weixin_40340362/article/details/89401723

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using PrinterDemo.Model;
using PrinterDemo.Utils;
using System.Collections;
using static PrinterDemo.Utils.PrinterUtils;
using PrinterDemo.myDll;

namespace PrinterDemo
{
    public partial class MainForm : Form
    {

        private PrinterModel printerModel = null;
        private Boolean isOPen=false;


        public MainForm()
        {

            InitializeComponent();
            this.label2.Text = “初次使用请选择打印机并设置为默认值\r\n再开启服务“;
            this.button2.Text = “开启服务“;
            printerModel = FileUtils.getInstance().getPrinterModel();//初始化 默认数据信息
            InitPrinterList(); //初始化 打印列表
          
        }

        private void button1_Click(object sender EventArgs e)
        {

            if (this.checkBox1.Checked)
            {
                setDefaultPrinter(this.comboBox1.Text);
            }

        }

        private void button2_Click(object sender EventArgs e)
        {
         
      
            if (printerModel.Name != null && !printerModel.Name.Equals(““))
            {
                if (!isOPen)
                {
                    try {
                        OpenFleckPrinter.GetInstance().Start();
                        this.button2.Text = “服务已经开启“;
                        isOPen = true;
                    }
                    catch (Exception ex) {
                        MessageBox.Show(“当前服务已开启,请勿重新启动“);
                    }
                 
                }
                
     
            }
            else {
                this.label2.Text = “请先设置默认打印机!“;
                this.button2.Text = “开启服务“;
                return;
            }




        }
        /// 
        /// 初始化打印机列表 如果有默认的选中默认,
        /// 

        private void InitPrinterList()
        {
            int index = 0;

            //List items = new List();
            comboBox1.Items.Clear();
            for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)       //获取当前打印机
            {
                if (printerModel != null && printerModel.Name.Equals(PrinterSettings.InstalledPrinters[i]))
                {
                    index = i;
                    PrinterUtils.getInstance().setPrinterName(printerModel.Name);
                }
            //   items.Add(new ComboBoxItem(PrinterSettings.InstalledPrinters[i] PrinterSettings.InstalledPrinters[i]));

                comboBox1.Items.Add(PrinterSettings.InstalledPrinters[i]);
            }

            comboBox1.SelectedIndex = index;
            checkBox1.Checked = (printerModel != null ? printerModel.

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       9662  2019-03-13 22:36  C#打印客服端 - 测试\20190313103828853_easyicon_net_48.ico

    ..A..H.     76800  2019-04-27 14:19  C#打印客服端 - 测试\PrinterDemo\.vs\PrinterDemo\v15\.suo

     文件          0  2019-03-10 21:32  C#打印客服端 - 测试\PrinterDemo\.vs\PrinterDemo\v15\Server\sqlite3\db.lock

     文件    1798144  2019-04-15 18:18  C#打印客服端 - 测试\PrinterDemo\.vs\PrinterDemo\v15\Server\sqlite3\storage.ide

     文件      32768  2019-04-15 11:06  C#打印客服端 - 测试\PrinterDemo\.vs\PrinterDemo\v15\Server\sqlite3\storage.ide-shm

     文件    4548512  2019-04-15 18:21  C#打印客服端 - 测试\PrinterDemo\.vs\PrinterDemo\v15\Server\sqlite3\storage.ide-wal

    ..A..H.    108544  2019-05-01 12:03  C#打印客服端 - 测试\PrinterDemo\.vs\PrinterDemo\v16\.suo

     文件          0  2019-04-27 20:04  C#打印客服端 - 测试\PrinterDemo\.vs\PrinterDemo\v16\Server\sqlite3\db.lock

     文件     864256  2019-05-01 12:03  C#打印客服端 - 测试\PrinterDemo\.vs\PrinterDemo\v16\Server\sqlite3\storage.ide

     文件      18499  2018-11-27 14:12  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\.signature.p7s

     文件     552872  2018-11-27 18:07  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\net20\Newtonsoft.Json.dll

     文件     214252  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\net20\Newtonsoft.Json.pdb

     文件     595928  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\net20\Newtonsoft.Json.xml

     文件     487848  2018-11-27 18:07  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\net35\Newtonsoft.Json.dll

     文件     207060  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\net35\Newtonsoft.Json.pdb

     文件     541047  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\net35\Newtonsoft.Json.xml

     文件     553384  2018-11-27 18:07  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\net40\Newtonsoft.Json.dll

     文件     220704  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\net40\Newtonsoft.Json.pdb

     文件     552966  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\net40\Newtonsoft.Json.xml

     文件     675240  2018-11-27 18:07  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll

     文件     250244  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.pdb

     文件     699263  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.xml

     文件     645032  2018-11-27 18:07  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\netstandard1.0\Newtonsoft.Json.dll

     文件     238684  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\netstandard1.0\Newtonsoft.Json.pdb

     文件     677908  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\netstandard1.0\Newtonsoft.Json.xml

     文件     663464  2018-11-27 18:07  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\netstandard1.3\Newtonsoft.Json.dll

     文件     246076  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\netstandard1.3\Newtonsoft.Json.pdb

     文件     686114  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\netstandard1.3\Newtonsoft.Json.xml

     文件     669096  2018-11-27 18:07  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\netstandard2.0\Newtonsoft.Json.dll

     文件     247516  2018-11-27 17:59  C#打印客服端 - 测试\PrinterDemo\packages\Newtonsoft.Json.12.0.1\lib\netstandard2.0\Newtonsoft.Json.pdb

............此处省略120个文件信息

评论

共有 条评论