欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#激光打碼開發(fā)實(shí)例

激光打碼C#

  • 源碼大小:0.03MB
  • 源碼語言:簡體中文
  • 源碼類型:國產(chǎn)軟件
  • 源碼授權(quán):免費(fèi)軟件
  • 源碼類別:C#源碼
  • 應(yīng)用平臺:c#
  • 更新時間:2025-07-17
  • 網(wǎng)友評分:
360通過 騰訊通過 金山通過

情介紹

激光碼(Laser Coding)通常指的是使用激光技術(shù)對物體進(jìn)行編碼或標(biāo)記,比如在工業(yè)制造中對產(chǎn)品進(jìn)行序列號標(biāo)記。在C#中實(shí)現(xiàn)一個激光碼的模擬或演示,我們可以使用圖形庫來模擬激光束的效果,并通過控制臺或圖形界面展示。

核心代碼

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using LmcLib;
namespace Ezcad_Funtion_Show
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            dlg.Filter = "Ezd files (*.ezd)|*.ezd";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = dlg.FileName;
            }
        }
        public void ShowPreviewBmp()
        {
            int w = pictureBox1.Size.Width;
            int h = pictureBox1.Size.Height;
            if (w > h)
            {
                w = h;
            }
            else
            {
                h = w;
            }
            pictureBox1.Image = MarkEzdDll.GetCurPreviewImage(w, h);
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                String dir = Application.StartupPath;
                int nErr = MarkEzdDll.Initialize(dir, false);
                MessageBox.Show("Initial=" nErr.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.Close();
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (!backgroundWorker1.IsBusy)
            {
                backgroundWorker1.RunWorkerAsync();
            }
        }
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            int nErr = MarkEzdDll.Mark(false);
            //MessageBox.Show("Mark="   nErr.ToString());
        }
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //MessageBox.Show("Finish");
            //button8_Click(sender, e);
            ShowPreviewBmp();
        }
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            MarkEzdDll.Close();
        }
        private void button4_Click(object sender, EventArgs e)
        {
            MarkEzdDll.SetDevCfg();
        }
        private void button3_Click(object sender, EventArgs e)
        {
          MarkEzdDll.ChangeTextByName(textBox2.Text, textBox3.Text);
        }
        private void button6_Click(object sender, EventArgs e)
        {
            MarkEzdDll.ClearLibAllEntity();
            ShowPreviewBmp();
        }
        private void button5_Click(object sender, EventArgs e)
        {
            /// <summary>
            /// 向數(shù)據(jù)庫添加一條曲線對象
            /// 注意PtBuf必須為2維數(shù)組,且第一維為2,如 double[5,2],double[n,2],
            /// ptNum為PtBuf數(shù)組的第2維,如PtBuf為double[5,2]數(shù)組,則ptNum=5
            /// </summary> 
            /// 
            double[,] PtBuf = { { 0,0 }, { 10,0 }, { 10,10 }, { 0,10}, { 0,0 } };//10x10的矩形
            MarkEzdDll.AddCurveToLib(PtBuf, 5, "Curve", 0, 0);
            ShowPreviewBmp();
        }
        private void button7_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            dlg.Filter = "Ezd files (*.ezd)|*.ezd";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                textBox4.Text = dlg.FileName;
            }
        }
        bool test = false;
        private void button8_Click(object sender, EventArgs e)
        {
            if (test)
            {
                if (MarkEzdDll.LoadEzdFile(textBox1.Text) != 0)
                {
                    MessageBox.Show("打開Ezd文件"   textBox1.Text   "失敗!");
                }
                else
                {
                    test = false;
                }
            }
            else
            {
                if (MarkEzdDll.LoadEzdFile(textBox4.Text) != 0)
                {
                    MessageBox.Show("打開Ezd文件"   textBox4.Text   "失敗!");
                }
                else
                {
                    test = true;
                }
            }
            ShowPreviewBmp();
        }
    }
    public class MarkEzdDll
    {
        /// <summary>
        /// 初始化函數(shù)庫
        /// PathName 是MarkEzd.dll所在的目錄
        /// </summary>     
        [DllImport("MarkEzd", EntryPoint = "lmc1_Initial2", CharSet= CharSet.Unicode,CallingConvention = CallingConvention.StdCall)]
        public static extern int Initialize(string PathName,bool bTestMode);
        [DllImport("MarkEzd", EntryPoint = "lmc1_SetDevCfg", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
        public static extern int SetDevCfg();
        [DllImport("MarkEzd", EntryPoint = "lmc1_Close",CharSet= CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
        public static extern int Close();
        [DllImport("MarkEzd", EntryPoint = "lmc1_LoadEzdFile", CharSet= CharSet.Unicode,CallingConvention = CallingConvention.StdCall)]
        public static extern int LoadEzdFile(string FileName);
        [DllImport("MarkEzd", EntryPoint = "lmc1_Mark",CharSet= CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
        public static extern int Mark(bool Fly);
       [DllImport("MarkEzd", EntryPoint = "lmc1_ChangeTextByName", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
        public static extern int ChangeTextByName(string EntName, string NewText);
        [DllImport("gdi32.dll")]
        internal static extern bool DeleteObject(IntPtr hObject);
        [DllImport("MarkEzd", EntryPoint = "lmc1_GetPrevBitmap2", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
        internal static extern IntPtr GetCurPrevBitmap(int bmpwidth, int bmpheight);
        public static Image GetCurPreviewImage(int bmpwidth, int bmpheight)
        {
            IntPtr pBmp = GetCurPrevBitmap(bmpwidth, bmpheight);
            Image img = Image.FromHbitmap(pBmp);
            MarkEzdDll.DeleteObject(pBmp);
            return img;
        }
        [DllImport("MarkEzd", EntryPoint = "lmc1_AddCurveToLib", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
        public static extern int AddCurveToLib([MarshalAs(UnmanagedType.LPArray)] double[,] PtBuf, int ptNum, string strEntName, int nPenNo, int bHatch);
        [DllImport("MarkEzd", EntryPoint = "lmc1_ClearEntLib", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
        public static extern int ClearLibAllEntity();
    }
}

載地址

C#激光打碼開發(fā)實(shí)例

      氣源碼

      關(guān)文章

      載聲明

      ☉ 解壓密碼:www.dbjr.com.cn 就是本站主域名,希望大家看清楚,[ 分享碼的獲取方法 ]可以參考這篇文章
      ☉ 推薦使用 [ 迅雷 ] 下載,使用 [ WinRAR v5 ] 以上版本解壓本站軟件。
      ☉ 如果這個軟件總是不能下載的請?jiān)谠u論中留言,我們會盡快修復(fù),謝謝!
      ☉ 下載本站資源,如果服務(wù)器暫不能下載請過一段時間重試!或者多試試幾個下載地址
      ☉ 如果遇到什么問題,請?jiān)u論留言,我們定會解決問題,謝謝大家支持!
      ☉ 本站提供的一些商業(yè)軟件是供學(xué)習(xí)研究之用,如用于商業(yè)用途,請購買正版。
      ☉ 本站提供的C#激光打碼開發(fā)實(shí)例資源來源互聯(lián)網(wǎng),版權(quán)歸該下載資源的合法擁有者所有。