Пример #1
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);
            }
        }