Пример #1
0
        private void btn_Repair_Click(object sender, EventArgs e)
        {
            if (_sb._s_ControlBuffer.ContainsKey(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()))
            {
                _sb._s_ControlBuffer.Remove(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
            }
            if (_sb._s_ObjectBuffer.ContainsKey(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()))
            {
                _sb._s_ObjectBuffer.Remove(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
            }

            string nscl = "HYvision" + "." + cbb_Type.SelectedItem + "source";
            var    x    = Activator.CreateInstance(null, nscl);

            Iloadsource = (ILoadSource)x.Unwrap();
            if (!Iloadsource.LoadSource(_sb, txt_Name.Text.Trim(), txt_Path.Text.Trim()))
            {
                MessageBox.Show("资源新增失败,请检查");
                return;
            }
            _source.EraseSection(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
            _source.IniWrite(txt_Name.Text.Trim(), "type", cbb_Type.SelectedItem.ToString());
            _source.IniWrite(txt_Name.Text.Trim(), "path", txt_Path.Text.Trim());
            dataGridView1.SelectedRows[0].Cells[0].Value = txt_Name.Text.Trim();
            dataGridView1.SelectedRows[0].Cells[1].Value = cbb_Type.SelectedItem;
            dataGridView1.SelectedRows[0].Cells[2].Value = txt_Path.Text.Trim();
            dataGridView1.SelectedRows[0].Cells[3].Value = "非空";
        }
Пример #2
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;
            }

            List <string> sections1 = _source.ReadSections();

            if (sections1.Contains(txt_Name.Text.Trim()))
            {
                MessageBox.Show("已包含同名资源,请重新设定");
                return;
            }

            string nscl = "HYvision" + "." + cbb_Type.SelectedItem + "source";
            var    x    = Activator.CreateInstance(null, nscl);

            Iloadsource = (ILoadSource)x.Unwrap();
            if (!Iloadsource.LoadSource(_sb, txt_Name.Text.Trim(), txt_Path.Text.Trim()))
            {
                MessageBox.Show("资源加载失败,请检查");
                return;
            }
            _source.IniWrite(txt_Name.Text.Trim(), "type", cbb_Type.SelectedItem.ToString());
            _source.IniWrite(txt_Name.Text.Trim(), "path", txt_Path.Text.Trim());

            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;
            dataGridView1.Rows[index].Cells[3].Value = "非空";
        }