C#标签设计打印软件开发

1、新建自定义C#控件项目Custom

using System;
using System.Collections.Generic;
using System.Text;

namespace CustomControls
{
    public class CommonSettings
    {
        /// <summary>
        /// 把像素换算成毫米
        /// </summary>
        /// <param name="Pixel">多少像素</param>
        /// <returns>多少毫米</returns>
        public static float PixelConvertMillimeter(float Pixel)
        {
            return Pixel / 96 * 25.4f;
        }
        
        /// <summary>
        /// 把毫米换算成像素
        /// </summary>
        /// <param name="Millimeter">多少毫米</param>
        /// <returns>多少像素</returns>
        public static int MillimeterConvertPixel(float Millimeter)
        {
            return ((int)(Millimeter / 25.4 * 96)+1);
        }
    }
}

GraphicsTools 

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Drawing2D;
using System.Drawing;

namespace CustomControls
{
    internal static class GraphicsTools
    {
        /// <summary>
        /// Creates a rounded rectangle from the specified rectangle and radius
        /// </summary>
        /// <param name="rectangle">Base rectangle</param>
        /// <param name="radius">Radius of the corners</param>
        /// <returns>Rounded rectangle as a GraphicsPath</returns>
        public static GraphicsPath CreateRoundRectangle(Rectangle rectangle, int radius)
        {
            GraphicsPath path = new GraphicsPath();

            int l = rectangle.Left;
            int t = rectangle.Top;
            int w = rectangle.Width;
            int h = rectangle.Height;
            int d = radius << 1;

            path.AddArc(l, t, d, d, 180, 90); // topleft
            path.AddLine(l + radius, t, l + w - radius, t); // top
            path.AddArc(l + w - d, t, d, d, 270, 90); // topright
            path.AddLine(l + w, t + radius, l + w, t + h - radius); // right
            path.AddArc(l + w - d, t + h - d, d, d, 0, 90); // bottomright
            path.AddLine(l + w - radius, t + h, l + radius, t + h); // bottom
            path.AddArc(l, t + h - d, d, d, 90, 90); // bottomleft
            path.AddLine(l, t + h - radius, l, t + radius); // left
            path.CloseFigure();

            return path;
        }

        /// <summary>
        /// Creates a rectangle rounded on the top
        /// </summary>
        /// <param name="rectangle">Base rectangle</param>
        /// <param name="radius">Radius of the top corners</param>
        /// <returns>Rounded rectangle (on top) as a GraphicsPath object</returns>
        public static GraphicsPath CreateTopRoundRectangle(Rectangle rectangle, int radius)
        {
            GraphicsPath path = new GraphicsPath();

            int l = rectangle.Left;
            int t = rectangle.Top;
            int w = rectangle.Width;
            int h = rectangle.Height;
            int d = radius << 1;

            path.AddArc(l, t, d, d, 180, 90); // topleft
            path.AddLine(l + radius, t, l + w - radius, t); // top
            path.AddArc(l + w - d, t, d, d, 270, 90); // topright
            path.AddLine(l + w, t + radius, l + w, t + h); // right
            path.AddLine(l + w, t + h, l, t + h); // bottom
            path.AddLine(l, t + h, l, t + radius); // left
            path.CloseFigure();

            return path;
        }

        /// <summary>
        /// Creates a rectangle rounded on the bottom
        /// </summary>
        /// <param name="rectangle">Base rectangle</param>
        /// <param name="radius">Radius of the bottom corners</param>
        /// <returns>Rounded rectangle (on bottom) as a GraphicsPath object</returns>
        public static GraphicsPath CreateBottomRoundRectangle(Rectangle rectangle, int radius)
        {
            GraphicsPath path = new GraphicsPath();

            int l = rectangle.Left;
            int t = rectangle.Top;
            int w = rectangle.Width;
            int h = rectangle.Height;
            int d = radius << 1;

            path.AddLine(l + radius, t, l + w - radius, t); // top
            path.AddLine(l + w, t + radius, l + w, t + h - radius); // right
            path.AddArc(l + w - d, t + h - d, d, d, 0, 90); // bottomright
            path.AddLine(l + w - radius, t + h, l + radius, t + h); // bottom
            path.AddArc(l, t + h - d, d, d, 90, 90); // bottomleft
            path.AddLine(l, t + h - radius, l, t + radius); // left
            path.CloseFigure();

            return path;
        }
        
    }
}

2、打印机设置界面

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing.Printing;
using System.Text;
using System.Windows.Forms;
using  CustomControls.IO;

namespace CustomControls.Control
{
    public partial class frmSetting : Form
    {
        public frmSetting(PrintConfig confg)
        {
            InitializeComponent();
            pconfig = confg;
        }

        private PrintConfig pconfig;

        private void frmSetting_Load(object sender, EventArgs e)
        {
            for (int i=0; i < PrinterSettings.InstalledPrinters.Count; i++)
            {
                cbPrintName.Items.Add(PrinterSettings.InstalledPrinters[i]);
            }
            if (cbPrintName.Items.Count > 0)
            {
                cbPrintName.SelectedItem = pconfig.PrintName;
            }
            numX.Value = pconfig.XOFFSET;
            numY.Value = pconfig.YOFFSET;
            numZoom.Value = (decimal)pconfig.ZOOM;
            numCopies.Value = pconfig.Copies;

            
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            pconfig.XOFFSET = (int)numX.Value;
            pconfig.YOFFSET = (int)numY.Value;
            pconfig.PrintName = cbPrintName.SelectedItem.ToString();
            pconfig.ZOOM = (float)numZoom.Value;
            pconfig.Copies = (int)numCopies.Value;
            this.Close();
            
        }

       
    }
}

 3、条形码39码\93码实现

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace CustomControls.BarCode
{
    [Serializable]
    internal class Code39 : IBarcode
    {
        public Code39()
        {
            EncodeBarcodeValue();
        }

        #region Variable
        /// <summary>
        /// 是否显示条码的值
        /// </summary>
        private bool bShowText = true;
        /// <summary>
        /// 是否在条码上方显示字符
        /// </summary>
        private bool bShowTextOnTop = false;
        /// <summary>
        /// 条码值的对值的对齐方式
        /// </summary>
        private BarcodeTextAlign align = BarcodeTextAlign.Left;
        /// <summary>
        /// 条码的做图区域
        /// </summary>
        private Rectangle barcodeRect;
        /// <summary>
        /// 条码的值
        /// </summary>
        private String code = "0123456";
        /// <summary>
        /// 条码的高度
        /// </summary>
        private int height = 30;
        /// <summary>
        /// 条码的大小
        /// </summary>
        private BarCodeWeight weight = BarCodeWeight.Small;
        /// <summary>
        /// 旋转
        /// </summary>
        private BarcodeRotation Rotation = BarcodeRotation.Rotation90;
        /// <summary>
        /// 条码的字体
        /// </summary>
        private Font textFont = new Font("Courier", 8);
        /// <summary>
        /// 将条码数据编码
        /// </summary>
        private String encodedString = "";
        /// <summary>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/598002.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

社交媒体数据恢复:华为畅连

尊敬的用户您好&#xff0c;以下是关于社交软件华为畅连的聊天记录数据恢复教程。在华为手机中&#xff0c;我们可以通过华为云服务和第三方软件来恢复删除的聊天记录。以下是详细的步骤&#xff1a; 第一步&#xff1a;登录华为云服务 请在您的华为手机上找到并打开“云服务”…

Learning C# Programming with Unity 3D

作者&#xff1a;Alex Okita 源码地址&#xff1a;GitHub - badkangaroo/UnityProjects: A repo for all of the projects found in the book. 全书 686 页。

实操专区-第11周-课堂练习专区-图的标记线和标记点

下载安装ECharts&#xff0c;完成如下样式图形。 代码和截图上传 完成 3.1.3.5 图的标记线和标记点 中的任务点 在一些折线图或柱状图当中&#xff0c;可以经常看到图中对最高值和最低值进行了标记。 在ECharts中&#xff0c;标记点&#xff08;markPoint&#xff09;常用于表示…

【YesPMP】众包平台5月7日最新外包项目

【YesPMP】众包平台5月7日最新外包项目&#xff0c;感兴趣的小伙伴&#xff0c;可进入平台参与竞标&#xff0c;竞标后与项目方直接与联系&#xff0c;双方直接对接。 1.查看项目&#xff1a;按照客户提供的设计稿美化页面&#xff0c;改html和js代码-YesPMP平台给你设计图&am…

使用免费的数据恢复软件通过简单的步骤恢复丢失的数据

犯错是人之常情&#xff01;您有时可能会意外地从PC或笔记本电脑中删除重要数据&#xff0c;旧的家庭或大学视频/照片&#xff0c;如果您面临数据丢失&#xff0c;则可以使用数据恢复软件轻松恢复丢失的数据。 奇客数据恢复软件可让您从笔记本电脑&#xff0c;PC和可移动存储设…

PowerShell ⇒ Excel 批量创建Excel

New-Object -ComObject Excel.Application&#xff1a;创建Excel对象[System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel) | Out-Null 用来显式释放 Excel COM 对象的资源&#xff0c;以确保在脚本执行完成后&#xff0c;释放 Excel 进程和相关资源&#xff0…

使用API有效率地管理Dynadot域名,设置所有域名默认whois信息

关于Dynadot Dynadot是通过ICANN认证的域名注册商&#xff0c;自2002年成立以来&#xff0c;服务于全球108个国家和地区的客户&#xff0c;为数以万计的客户提供简洁&#xff0c;优惠&#xff0c;安全的域名注册以及管理服务。 Dynadot平台操作教程索引&#xff08;包括域名邮…

【Java】第二讲:字符串相关类

个人主页&#xff1a;深情秋刀鱼-CSDN博客 Java专栏&#xff1a;Java程序设计 目录 一、String 1.Java中的数据类型 2.字符串概述 3.字符串构造方法 4.字符串构造内存原理 5.字符串比较 6.字符串常见方法 二、StringBuilder 1.定义 2.常用方法 3.StringBuilder内存分…

数据集标签数量不均衡如何设计loss均衡数量

数据集标签数量不均衡如何设计loss均衡数量 1. 思路出发点&#xff1a; 对于哪些数量分布比值较少的标签提供更多的loss注意力比重&#xff0c;如何提高训练注意力比重&#xff0c;也就是说&#xff0c;让模型的梯度更多的倾向于有利于数据标签分布较少的数据训练&#xff0c…

js中的复制粘贴(亲测有效)

下方微信公众号 和微信小程序推荐 js中的复制粘贴 navigator.clipboard.writeText(copyText) 是 Web API 中的一个方法&#xff0c;用于将指定的文本内容复制到用户的剪贴板。这个方法属于 Clipboard API&#xff0c;它使得网页能够读取和写入剪贴板的内容。 具体来说&#…

5月6(信息差)

&#x1f30d;一次预测多个token&#xff0c;Meta新模型推理加速3倍&#xff0c;编程任务提高17% https://hub.baai.ac.cn/view/36857 &#x1f384; LeetCode 周赛超越 80% 人类选手&#xff0c;推理性能超 Llama3-70B。 ✨ 我国量子计算机实现“四算合一” 实现通算、…

Rust开发工具有哪些?

目录 一、JetBrains公司的RustRover​编辑 二、微软公司的Visual Studio Code 三、Rust编译工具 一、JetBrains公司的RustRover RustRover是由JetBrains开发的一款专为Rust开发量身定制的新兴IDE&#xff0c;目前还处于早期访问阶段。它支持Rust、Cargo、TOML、Web和数据库等…

学习笔记:【QC】Android Q telephony-data 模块

一、data init 流程图 主要分为3部分&#xff1a; 1.加载TelephonyProvider&#xff0c;解析apns-config.xml文件&#xff0c;调用loadApns将 xml中定义的数据&#xff0c;插入到TelephonyProvider底层的数据库中 2.初始化phone、DcTracker、TelephonyNetworkFactory、Conne…

【Pytorch】3.Transforms的运用

什么是Transforms 在PyTorch中&#xff0c;transforms是用于对数据进行预处理、增强和变换的操作集合。transforms通常用于数据载入和训练过程中&#xff0c;可以包括数据的归一化、裁剪、翻转、旋转、缩放等操作&#xff0c;以及将数据转换成PyTorch可以处理的Tensor格式。 Tr…

Redis-五大数据类型-Zset(有序集合)

五大数据类型-Zset&#xff08;有序集合&#xff09; 简介 Zset与Set非常相似&#xff0c;是一个没有重复元素的String集合。 不同之处是Zset的每个元素都关联了一个分数&#xff08;score&#xff09;&#xff0c;这个分数被用来按照从低分到高分的方式排序集合中的元素。集…

力扣:221. 最大正方形

221. 最大正方形 在一个由 0 和 1 组成的二维矩阵内&#xff0c;找到只包含 1 的最大正方形&#xff0c;并返回其面积。 示例 1&#xff1a; 输入&#xff1a;matrix [["1","0","1","0","0"],["1","0"…

#05 损失函数与优化器:深度学习的调谐师

文章目录 前言什么是损失函数&#xff1f;常见的损失函数 优化器的角色经典优化器 PyTorch中的损失函数与优化器实现一个损失函数选择一个优化器 神经网络训练中的应用结论 前言 深度学习的艺术和科学在于优化&#xff1a;它是一个寻找使模型性能最大化的过程。在这个过程中&am…

深度学习之基于Vgg16卷积神经网络心电图心脏病诊断系统

欢迎大家点赞、收藏、关注、评论啦 &#xff0c;由于篇幅有限&#xff0c;只展示了部分核心代码。 文章目录 一项目简介 二、功能三、系统四. 总结 一项目简介 一、项目背景 心脏病是全球范围内导致死亡的主要原因之一&#xff0c;其早期的准确诊断对于患者的治疗和康复至关重…

【综自系统】配电室综合监控系统

安科瑞电气股份有限公司 祁洁 15000363176 一、系统简介 Acrel-2000E配电室综合监控系统&#xff0c;可实现开关柜运行监控、高压开关柜带电显示、母线及电缆测温监测、环境温湿度监测、有害气体监测、安防监控&#xff0c;可对灯光、风机、除湿机、空调控制等设备进行联动…

MySQL mysqldump备份恢复

目录 1. 备份类型 2. 逻辑备份VS物理备份 3. mysqldump工具 3.1 备份命令格式 3.2 备份选项 3.3 备份全库(结构和数据) 3.4 备份全库(仅结构) 3.5 备份全库(仅数据) 3.6 备份单个数据库(结构和数据) 3.7 备份单个数据库(仅结构) 3.8 备份单个数据库(仅数据) 3.9…
最新文章