Esempio n. 1
0
        //显示打标状态
        private void btnStatus_Click(object sender, EventArgs e)
        {
            int nFlag = 0;
            int nRet  = CSharpInterface.HS_IsMarkEnd(ref nFlag);

            if (nRet == 0)
            {
                if (nFlag == 0)
                {
                    this.tbNote.Text = "Marking ......!";
                }
                else
                {
                    this.tbNote.Text = "打标结束.....!";
                    int nTime = 0;
                    CSharpInterface.HS_GetMarkTime(ref nTime);
                    this.tbNote.Text = "Mark finish...! Last time " + nTime.ToString() + " ms";
                    Preview();//预览
                }
            }
            else
            {
                ShowLastError();
            }
        }
Esempio n. 2
0
        //初始化打标系统
        private void btnInitSystem_Click(object sender, EventArgs e)
        {
            string strCurPath = System.Environment.CurrentDirectory;     //获取当前路径
            int    nRet       = CSharpInterface.HS_InitialMachine(strCurPath);

            if (nRet == 0)
            {
                tbNote.Text           = "打标系统初始化成功!";
                tsslabCardStatus.Text = "状态:初始化成功!";

                CSharpInterface.g_strPathName = strCurPath;
                m_bInitOk = true;

                double px = 0, py = 0;
                CSharpInterface.HS_GetMarkRange(ref px, ref py);
                tsslabMarkRange.Text = "打标范围:" + px.ToString() + "*" + py.ToString() + "mm";
                //设置预览滑标
                tbrX.SetRange(-(int)(px / 2), (int)(px / 2));
                tbrY.SetRange(-(int)(py / 2), (int)(py / 2));
                tbrS.SetRange(0, 100);
                ResetPreview();//设置滑标位置
            }
            else
            {
                ShowLastError();
                tsslabCardStatus.Text = "状态:初始化失败!";
            }
            UpdateView();
        }
Esempio n. 3
0
        //缩放对象
        private void btnScale_Click(object sender, EventArgs e)
        {
            try
            {
                m_dbParaX = Convert.ToDouble(tbParaX.Text);
                m_dbParaY = Convert.ToDouble(tbParaY.Text);
                m_dbBaseX = Convert.ToDouble(tbBaseX.Text);
                m_dbBaseY = Convert.ToDouble(tbBaseY.Text);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("输入的数据不合法!\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            int nRet = CSharpInterface.HS_Scale(m_dbBaseX, m_dbBaseY, m_dbParaX, m_dbParaY);

            if (nRet == 0)
            {
                tbNote.Text = "Scale success!";
                Preview();
            }
            else
            {
                ShowLastError();
            }
            SelectSize();
        }
Esempio n. 4
0
        private void btnWriteOutPort_Click(object sender, EventArgs e)
        {
            try
            {
                m_dwOutPort = Convert.ToInt32(this.tbOutPort.Text);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("请输入一个正整数输入!\n" + ex.Message, "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                m_dwOutPort         = 0;
                this.tbOutPort.Text = "0";
                return;
            }
            if (m_dwOutPort < 0)
            {
                MessageBox.Show("请输入一个正整数输入!", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                m_dwOutPort         = 0;
                this.tbOutPort.Text = "0";
                return;
            }

            int nRet = CSharpInterface.HS_WritePort(m_dwOutPort, 0xFFFF);

            if (0 == nRet)
            {
                tbNote.Text = "Write output port successfully!";
            }
            else
            {
                tbNote.Text = "Write output port failed!";
                MessageBox.Show("操作失败!\n返回值:" + nRet.ToString() + "\n错误信息:"
                                + CSharpInterface.GetError().ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            try
            {
                m_dbPosX      = Convert.ToDouble(tbPosX.Text);
                m_dbPosY      = Convert.ToDouble(tbPosY.Text);
                m_dbWidth     = Convert.ToDouble(tbWidth.Text);
                m_dbHeight    = Convert.ToDouble(tbHeight.Text);
                m_dbRotate    = Convert.ToDouble(tbRotate.Text);
                m_nHatchLayer = Convert.ToInt32(tbHatchLayer.Text);
                m_strObjName  = tbObjName.Text;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("输入的数据不合法!\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            int nRet = CSharpInterface.HS_ImportVectorFile(m_strFileName, m_dbPosX, m_dbPosY, m_dbWidth, m_dbHeight,
                                                           m_dbRotate, m_bHatch, m_nHatchLayer, m_strObjName);

            if (nRet == 0)
            {
                MessageBox.Show("ImportVectorFile success!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClickImport = true;
                this.Close();
            }
            else
            {
                MessageBox.Show("导入失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 6
0
        private void LaserMark()
        {
            try
            {
                this.m_nWaitTimeForTouch = Convert.ToInt32(this.tbWaitTouchTime.Text);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("信号等待最大时长 必须为正整数!\n" + ex.Message, "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (m_nWaitTimeForTouch < 0)
            {
                MessageBox.Show("信号等待最大时长 必须为正整数!", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            int nRet = CSharpInterface.HS_Mark(0, m_bWaitTouch, m_bWaitEnd, m_nWaitTimeForTouch, true);

            if (0 == nRet)
            {
                this.tbNote.Text = "打标成功!";
            }
            else
            {
                ShowLastError();
            }
        }
Esempio n. 7
0
        //显示错误信息
        string ShowLastError()
        {
            int           nErr   = 0;
            StringBuilder szBuff = new StringBuilder(200);

            CSharpInterface.HS_GetLastError(ref nErr, szBuff, 200);
            tbNote.Text = szBuff.ToString();
            return(szBuff.ToString());
        }
Esempio n. 8
0
        //自定义打标
        private void btnMarkCustomData_Click(object sender, EventArgs e)
        {
            int nRet = CSharpInterface.HS_MarkStorkeList(0, m_listCustom);

            if (nRet != 0)
            {
                ShowLastError();
            }
        }
Esempio n. 9
0
        //继续打标
        private void btnMarkResume_Click(object sender, EventArgs e)
        {
            int nRet = CSharpInterface.HS_Remark();

            if (0 == nRet)
            {
                this.tbNote.Text = "继续打标!";
            }
            else
            {
                ShowLastError();
            }
        }
Esempio n. 10
0
        //停止打标
        private void btnMarkStop_Click(object sender, EventArgs e)
        {
            int nRet = CSharpInterface.HS_MarkStop();

            if (0 == nRet)
            {
                this.tbNote.Text = "停止打标!";
            }
            else
            {
                ShowLastError();
            }
        }
Esempio n. 11
0
        //硬件设置
        private void btnSetHardWare_Click(object sender, EventArgs e)
        {
            int nRet = CSharpInterface.HS_SetDevCfg();

            if (0 == nRet)
            {
                tbNote.Text = "Set hardware finished!";
            }
            else
            {
                ShowLastError();
            }
        }
Esempio n. 12
0
        //设置
        private void btnSet_Click(object sender, EventArgs e)
        {
            int nRet = CSharpInterface.HS_SetFontPara2(m_nFontType, nCharSet, m_strFontName, m_strShxCN, m_strShxEN, m_strShxNum);

            if (nRet == 0)
            {
                MessageBox.Show("设置字体参数成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("设置字体参数失败!\n" + CSharpInterface.GetError(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 13
0
        //改变层时,显示相应层的参数
        private void numudLayerNo_ValueChanged(object sender, EventArgs e)
        {
            m_nLayerNo = Convert.ToInt32(numudLayerNo.Value);
            int nRet = CSharpInterface.HS_GetLayerPara(m_nLayerNo, ref m_layerPara);

            if (nRet != 0)
            {
                MessageBox.Show("读取层参数数据失败!\n返回值:" + nRet.ToString() + "\n错误信息:"
                                + CSharpInterface.GetError().ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            SetData(false);
        }
Esempio n. 14
0
        //确定添加曲线对象
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                m_nLayer      = Convert.ToInt32(this.tbLayer.Text);
                m_strObjName  = tbObjName.Text.ToString();
                m_nHatchLayer = Convert.ToInt32(tbHatchLayer.Text);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("输入的数据不合法!\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            m_strObjName = m_strObjName.Trim();//去除空格等
            if (m_strObjName.Length <= 0)
            {
                MessageBox.Show("对象名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (m_nLayer < 0)
            {
                MessageBox.Show("层号不能为负数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (m_arrayDot.Count <= 0)
            {
                MessageBox.Show("曲线中至少要包含一个点对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            double[,] ptBuf = new double[m_nPtNum, 2];

            for (int i = 0; i < m_nPtNum; i++)
            {
                ptBuf[i, 0] = m_arrayDot[i].X;
                ptBuf[i, 1] = m_arrayDot[i].Y;
            }

            int nRet = CSharpInterface.HS_AddCurve(ptBuf, m_nPtNum, m_nLayer, m_bHatch, m_nHatchLayer, m_strObjName);

            if (nRet == 0)
            {
                MessageBox.Show("AddCurve success!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClickAdd = true;
                this.Close();
            }
            else
            {
                MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 15
0
        //FFT设置
        private void btnTTF_Click(object sender, EventArgs e)
        {
            FontDialog fontDialog1 = new FontDialog();

            fontDialog1.Font = new Font(CSharpInterface.FromASCIIByteArray(m_lf.lfFaceName), 8);
            if (DialogResult.OK == fontDialog1.ShowDialog())
            {
                m_strFontName       = fontDialog1.Font.Name;
                m_lf.lfFaceName     = System.Text.Encoding.Default.GetBytes(fontDialog1.Font.Name);
                m_fontPara.nCharSet = fontDialog1.Font.GdiCharSet;
                m_lf.lfCharSet      = fontDialog1.Font.GdiCharSet;
            }
            UpdateData(false);
        }
Esempio n. 16
0
        //获取当前操作对象的属性,并显示在状态栏中
        void SelectSize()
        {
            double l = 0, t = 0, r = 0, b = 0;
            int    nRet = CSharpInterface.HS_GetObjProperty(ref l, ref t, ref r, ref b);

            if (0 == nRet)
            {
                tsslabObjSize.Text = "对象属性:[宽" + (r - l).ToString("f2") + "mm,高"
                                     + (t - b).ToString("f2") + "mm,中心(" + (0.5 * (r + l)).ToString("f2") + "," + (0.5 * (t + b)).ToString("f2") + ")]";
            }
            else
            {
                ShowLastError();
            }
        }
Esempio n. 17
0
        //删除选择的对象
        private void btnClearDocSelObj_Click(object sender, EventArgs e)
        {
            int nRet = CSharpInterface.HS_ClearObjects();

            if (nRet == 0)
            {
                ReLoadObjList();
                Preview();
            }
            else
            {
                this.tbNote.Text = "HS_ClearObj fail!";
            }
            SelectSize();
        }
Esempio n. 18
0
        //窗口加载函数
        private void SetLayerParaForm_Load(object sender, EventArgs e)
        {
            numudLayerNo.Maximum = m_nLayerCount - 1;
            numudLayerNo.Minimum = 0;

            m_nLayerNo = 0;
            int nRet = CSharpInterface.HS_GetLayerPara(m_nLayerNo, ref m_layerPara);

            if (nRet != 0)
            {
                MessageBox.Show("读取层参数数据失败!\n返回值:" + nRet.ToString() + "\n错误信息:"
                                + CSharpInterface.GetError().ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            SetData(false);
        }
Esempio n. 19
0
        //输入口读入
        private void btnReadInPort_Click(object sender, EventArgs e)
        {
            int nRet = CSharpInterface.HS_ReadPort(ref m_dwInPort);

            if (0 == nRet)
            {
                tbNote.Text        = "Read input port successfully!";
                this.tbInPort.Text = m_dwInPort.ToString();
            }
            else
            {
                tbNote.Text = "Read input port failed!";
                MessageBox.Show("操作失败!\n返回值:" + nRet.ToString() + "\n错误信息:"
                                + CSharpInterface.GetError().ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 20
0
        //文本替换
        private void btnChangeTextByID_Click(object sender, EventArgs e)
        {
            m_strModelName = this.tbTextID.Text;
            m_strTextTxt   = this.tbTextTXT.Text;
            int nRet = CSharpInterface.HS_ChangeTextByName(m_strModelName, m_strTextTxt);

            if (0 == nRet)
            {
                tbNote.Text = "Change text successfully!";
                SelectSize();
                Preview();
            }
            else
            {
                ShowLastError();
            }
        }
Esempio n. 21
0
        //XYZ轴位置跳转
        private void btnJumpPosition_Click(object sender, EventArgs e)
        {
            XYZPositionForm xyzpositionform = new XYZPositionForm();

            xyzpositionform.ShowDialog();
            if (xyzpositionform.ClickSetBtn)
            {
                int nRet = CSharpInterface.HS_IGotoXYZ(xyzpositionform.m_iXYZType, xyzpositionform.m_dbXPos, xyzpositionform.m_dbYPos, xyzpositionform.m_dbZPos);
                if (nRet != 0)
                {
                    ShowLastError();
                }
                else
                {
                    this.tbNote.Text = "Goto XYZ successful!";
                }
            }
        }
Esempio n. 22
0
        //获取自定义数据
        private void btnGetCustomData_Click(object sender, EventArgs e)
        {
            int selindex = this.cmbObjList.SelectedIndex;

            if (selindex == -1)
            {
                return;
            }
            else if (selindex == 0)
            {
                CSharpInterface.HS_FreeStrokeList(m_listCustom);
            }
            else if (selindex == 1)
            {
                CSharpInterface.HS_FreeStrokeList(m_listCustom);
                int nRet = CSharpInterface.HS_GetStrokeList(null, m_listCustom);
                if (nRet == 0)
                {
                    tbNote.Text = "Get cutstom data success!";
                    Preview();
                }
                else
                {
                    ShowLastError();
                }
                return;
            }
            else
            {
                CSharpInterface.HS_FreeStrokeList(m_listCustom);
                string strObj;
                strObj = cmbObjList.Items[selindex].ToString();
                int nRet = CSharpInterface.HS_GetStrokeList(strObj, m_listCustom);
                if (nRet == 0)
                {
                    tbNote.Text = "获取自定义数据成功!";
                    Preview();
                }
                else
                {
                    ShowLastError();
                }
            }
        }
Esempio n. 23
0
        private void btnHome_Click(object sender, EventArgs e)
        {
            if (UpdateData(true) == false)
            {
                return;
            }
            this.tbNote.Text = "";
            int nRet = CSharpInterface.HS_HomeMoveV(m_nAxisNo, m_bSoft0);

            if (0 == nRet)
            {
                this.tbNote.Text = "Move motor successfully!";
            }
            else
            {
                MessageBox.Show("操作失败!\n返回值:" + nRet.ToString() + "\n错误信息:"
                                + CSharpInterface.GetError().ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 24
0
        //文本获取W
        private void btnGetTextByIDW_Click(object sender, EventArgs e)
        {
            m_strModelName = this.tbTextID.Text;
            int nSize = 200;

            byte[] szText = new byte[200];
            int    nRet   = CSharpInterface.HS_GetTextByNameW(m_strModelName, szText, ref nSize);

            if (0 == nRet)
            {
                tbNote.Text = "Get text value successfully!";
            }
            else
            {
                ShowLastError();
                return;
            }
            this.tbTextTXT.Text = m_strTextTxt = Encoding.Unicode.GetString(szText);
        }
Esempio n. 25
0
        //文本替换W
        private void btnChangeTextByIDW_Click(object sender, EventArgs e)
        {
            string szText2 = tbTextTXT.Text;

            Byte[] szText = Encoding.Unicode.GetBytes(szText2);
            int    nRet   = CSharpInterface.HS_ChangeTextByNameW(m_strModelName, szText);

            if (0 == nRet)
            {
                tbNote.Text = "ChangeTextValue successfully!";
                SelectSize();
            }
            else
            {
                ShowLastError();
                return;
            }
            Preview();
        }
Esempio n. 26
0
        //文本获取
        private void btnGetTextByID_Click(object sender, EventArgs e)
        {
            m_strModelName = this.tbTextID.Text;
            int           nSize  = 200;
            StringBuilder szText = new StringBuilder(200);
            int           nRet   = CSharpInterface.HS_GetTextByName(m_strModelName, szText, ref nSize);

            if (0 == nRet)
            {
                tbNote.Text = "Get text value successfully!";
            }
            else
            {
                ShowLastError();
                return;
            }

            this.tbTextTXT.Text = m_strTextTxt = szText.ToString();
        }
Esempio n. 27
0
        //保存为模板文件
        private void btnSaveMarkFile_Click(object sender, EventArgs e)
        {
            SaveMarkFileForm savemarkfile = new SaveMarkFileForm();

            savemarkfile.ShowDialog();
            if (savemarkfile.ClickSave == true)
            {
                string szfilename = savemarkfile.m_strFileName;
                int    nRet       = CSharpInterface.HS_SaveMarkFile(szfilename);
                if (nRet == 0)
                {
                    tbNote.Text = "SaveMarkFile success!";
                }
                else
                {
                    ShowLastError();
                }
            }
        }
Esempio n. 28
0
        //显示预览
        void Preview()
        {
            if (bDrawing)
            {
                return;
            }

            bDrawing = true;
            if (myImageTab1.Handle != null)
            {
                int nRet = CSharpInterface.HS_PreviewGraph(myImageTab1.Handle, m_dbViewX, m_dbViewY, m_dbViewRate);
                if (0 != nRet)
                {
                    ShowLastError();
                }
            }

            bDrawing = false;
        }
Esempio n. 29
0
        //设置层参数
        private void btnSet_Click(object sender, EventArgs e)
        {
            // TODO: Add your control notification handler code here
            if (SetData(true) == false)
            {
                return;
            }
            int nRet = CSharpInterface.HS_SetLayerPara(m_nLayerNo, ref m_layerPara);

            if (nRet == 0)
            {
                MessageBox.Show("层参数设置成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("层参数设置失败!\n返回值:" + nRet.ToString() + "\n错误信息:"
                                + CSharpInterface.GetError().ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 30
0
 //打开或关闭激光
 private void btnLaserOnOff_Click(object sender, EventArgs e)
 {
     if (this.btnLaserOnOff.Text == "开激光")
     {
         LaserCmdParaForm lasercmdparaform = new LaserCmdParaForm();
         lasercmdparaform.ShowDialog();
         if (lasercmdparaform.ClickSetBtn == false)
         {
             this.btnLaserOnOff.Text = m_bLaserOnOff ? "关激光" : "开激光";
             return;
         }
         int nRet = CSharpInterface.HS_ILaserOn(lasercmdparaform.m_dbQFrq, lasercmdparaform.m_dbQRls, 20, 0);
         if (nRet == 0)
         {
             this.tbNote.Text        = "激光打开成功!";
             this.btnLaserOnOff.Text = "关激光";
             m_bLaserOnOff           = true;
         }
         else
         {
             ShowLastError();
             this.btnLaserOnOff.Text = m_bLaserOnOff ? "关激光" : "开激光";
             m_bLaserOnOff           = false;
         }
     }
     else if (this.btnLaserOnOff.Text == "关激光")
     {
         int nRet = CSharpInterface.HS_ILaserOff();
         if (nRet == 0)
         {
             this.tbNote.Text        = "激光关闭成功!";
             this.btnLaserOnOff.Text = "开激光";
             m_bLaserOnOff           = false;
         }
         else
         {
             ShowLastError();
             this.btnLaserOnOff.Text = "开激光";
             m_bLaserOnOff           = true;
         }
     }
 }