Esempio n. 1
0
        //确定添加点阵
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                m_nLayer     = Convert.ToInt32(this.tbLayer.Text);
                m_strObjName = tbObjName.Text.ToString();
            }
            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_AddDotMatrix(ptBuf, m_nPtNum, m_nLayer, m_strObjName);

            if (nRet == 0)
            {
                MessageBox.Show("AddDotMatrix success!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClickOkBtn = true;
                this.Close();
            }
            else
            {
                MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }