예제 #1
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            if (txt_Name.Text.Trim() == "")
            {
                MessageBox.Show("请输入资源名称");
                return;
            }
            if (txt_Path.Text.Trim() == "")
            {
                MessageBox.Show("请输入资源路径");
                return;
            }

            string Typeobject = cbb_Type.SelectedItem.ToString();

            if (Typeobject == null)
            {
                MessageBox.Show("请选择类型,再填加");
                return;
            }
            HObject hobj;
            HTuple  obj_model = new HTuple();

            if (Typeobject == "region")
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (txt_Name.Text == row.Cells[0].Value.ToString())
                    {
                        MessageBox.Show("已包含同名资源,请重新设定");
                        return;
                    }
                }
                HOperatorSet.GenEmptyObj(out hobj);
                try
                {
                    HOperatorSet.ReadRegion(out hobj, txt_Path.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("载入区域region失败,请检测类型是否正确");
                    return;
                }
                Info_Source new_info = new Info_Source(txt_Name.Text + ".region", "region", txt_Path.Text);
                _sourceBuffer[Source_number]._s_ObjectBuffer.Add(new_info, hobj);
                int index = dataGridView1.Rows.Add();

                dataGridView1.Rows[index].Cells[0].Value = txt_Name.Text.Trim();
                dataGridView1.Rows[index].Cells[1].Value = cbb_Type.SelectedItem.ToString();
                dataGridView1.Rows[index].Cells[2].Value = txt_Path.Text;
                UpdateSourceBuffer.OnSendUpdateSourceBuffer(new UpdateSourceBufferEventArgs(_sourceBuffer, _executeBuffer));
            }


            if (Typeobject == "shapemode_contour" || Typeobject == "tuple" || Typeobject == "shapemode_grey")
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (txt_Name.Text == row.Cells[0].Value.ToString())
                    {
                        MessageBox.Show("已包含同名资源,请重新设定");
                        return;
                    }
                }
                // HOperatorSet.GenEmptyObj(out obj_model);
                Info_Source new_info = new Info_Source(txt_Name.Text, "region", txt_Path.Text);
                try
                {
                    if (Typeobject == "shapemode_contour")
                    {
                        HOperatorSet.ReadShapeModel(txt_Path.Text, out obj_model);
                        new_info.Name = txt_Name.Text + ".shapemode_contour";
                        new_info.Type = "shapemode_contour";
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("载入形状模板失败,请检查类型是否正确");
                    return;
                }


                try
                {
                    if (Typeobject == "shapemode_grey")
                    {
                        //HOperatorSet.ReadShapeModel(txt_Path.Text, out obj_model);
                        HOperatorSet.ReadTemplate(txt_Path.Text, out obj_model);
                        new_info.Name = txt_Name.Text + ".shapemode_grey";
                        new_info.Type = "shapemode_grey";
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("载入灰度模板失败,请检查类型是否正确");
                    return;
                }

                try
                {
                    if (Typeobject == "tuple")
                    {
                        HOperatorSet.ReadTuple(txt_Path.Text, out obj_model);
                        new_info.Name = txt_Name.Text + ".tuple";
                        new_info.Type = "tuple";
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("载入Tuple文件失败,请检查类型是否正确");
                    return;
                }

                _sourceBuffer[Source_number]._s_ControlBuffer.Add(new_info, obj_model);
                int index = dataGridView1.Rows.Add();

                dataGridView1.Rows[index].Cells[0].Value = txt_Name.Text.Trim();
                dataGridView1.Rows[index].Cells[1].Value = cbb_Type.SelectedItem.ToString();
                dataGridView1.Rows[index].Cells[2].Value = txt_Path.Text;
                UpdateSourceBuffer.OnSendUpdateSourceBuffer(new UpdateSourceBufferEventArgs(_sourceBuffer, _executeBuffer));
            }
        }
예제 #2
0
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int selectcount = dataGridView1.SelectedRows.Count;

            Info_Source Del_item = new Info_Source();

            int model = 0;

            foreach (DataGridViewRow row in dataGridView1.SelectedRows)
            {
                if (row.Cells[1].Value.ToString() == "region")
                {
                    model = 0;
                    foreach (Info_Source keybufferobject in _sourceBuffer[Source_number]._s_ObjectBuffer.Keys)
                    {
                        if (keybufferobject.Name == (row.Cells[0].Value.ToString() + ".region") && keybufferobject.Type == row.Cells[1].Value.ToString() && keybufferobject.Path == row.Cells[2].Value.ToString())
                        {
                            Del_item = keybufferobject;
                            break;
                        }
                    }
                    Clear_list(Del_item.Name, model);
                    _sourceBuffer[Source_number]._s_ObjectBuffer.Remove(Del_item);
                    //   Clear_list(Del_item.Name,model);
                    UpdateSourceBuffer.OnSendUpdateSourceBuffer(new UpdateSourceBufferEventArgs(_sourceBuffer, _executeBuffer));
                }

                else
                {
                    model = 1;
                    foreach (Info_Source keybuffcontrol in _sourceBuffer[Source_number]._s_ControlBuffer.Keys)
                    {
                        if (keybuffcontrol.Type == row.Cells[1].Value.ToString() && keybuffcontrol.Path == row.Cells[2].Value.ToString())
                        {
                            if (keybuffcontrol.Type == "shapemode_contour")
                            {
                                if (keybuffcontrol.Name == row.Cells[0].Value.ToString() + ".shapemode_contour")
                                {
                                    Del_item = keybuffcontrol;
                                    break;
                                }
                            }
                            if (keybuffcontrol.Type == "shapemode_grey")
                            {
                                if (keybuffcontrol.Name == row.Cells[0].Value.ToString() + ".shapemode_grey")
                                {
                                    Del_item = keybuffcontrol;
                                    break;
                                }
                            }
                            if (keybuffcontrol.Type == "tuple")
                            {
                                if (keybuffcontrol.Name == row.Cells[0].Value.ToString() + ".tuple")
                                {
                                    Del_item = keybuffcontrol;
                                    break;
                                }
                            }
                            if (keybuffcontrol.Type == "xld")
                            {
                                if (keybuffcontrol.Name == row.Cells[0].Value.ToString() + ".xld")
                                {
                                    Del_item = keybuffcontrol;
                                    break;
                                }
                            }
                        }
                    }
                    Clear_list(Del_item.Name, 1);
                    _sourceBuffer[Source_number]._s_ControlBuffer.Remove(Del_item);

                    UpdateSourceBuffer.OnSendUpdateSourceBuffer(new UpdateSourceBufferEventArgs(_sourceBuffer, _executeBuffer));
                }
            }
            while (selectcount > 0)
            {
                if (!dataGridView1.SelectedRows[0].IsNewRow)
                {
                    dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[0].Index);
                }
                selectcount--;
            }
        }