Esempio n. 1
0
        private void button_modifyInstance_Click(object sender, EventArgs e)
        {
            string strError = "";

            try
            {
                HideMessageTip();
            }
            catch
            {
            }


            if (this.listView_instance.SelectedItems.Count == 0)
            {
                strError = "尚未选择要修改的事项";
                goto ERROR1;
            }

            ListViewItem item = this.listView_instance.SelectedItems[0];
            this.m_currentEditItem = item;

            OneInstanceDialog modify_instance_dlg = new OneInstanceDialog();
            GuiUtil.AutoSetDefaultFont(modify_instance_dlg);
            modify_instance_dlg.Text = "修改一个实例";
            modify_instance_dlg.InstanceName = ListViewUtil.GetItemText(item, COLUMN_NAME);
            modify_instance_dlg.DataDir = ListViewUtil.GetItemText(item, COLUMN_DATADIR);
            modify_instance_dlg.Bindings = ListViewUtil.GetItemText(item, COLUMN_BINDINGS).Replace(";", "\r\n");
            modify_instance_dlg.LineInfo = (LineInfo)item.Tag;

            modify_instance_dlg.VerifyInstanceName += new VerifyEventHandler(modify_instance_dlg_VerifyInstanceName);
            modify_instance_dlg.VerifyDataDir += new VerifyEventHandler(modify_instance_dlg_VerifyDataDir);
            modify_instance_dlg.VerifyBindings += new VerifyEventHandler(modify_instance_dlg_VerifyBindings);
            modify_instance_dlg.LoadXmlFileInfo += new LoadXmlFileInfoEventHandler(modify_instance_dlg_LoadXmlFileInfo);

            modify_instance_dlg.StartPosition = FormStartPosition.CenterScreen;
            if (modify_instance_dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel)
                return;

            ListViewUtil.ChangeItemText(item, COLUMN_NAME, modify_instance_dlg.InstanceName);
            ListViewUtil.ChangeItemText(item, COLUMN_DATADIR, modify_instance_dlg.DataDir);
            ListViewUtil.ChangeItemText(item, COLUMN_BINDINGS, modify_instance_dlg.Bindings.Replace("\r\n", ";"));
            modify_instance_dlg.LineInfo.Changed = true;
            item.Tag = modify_instance_dlg.LineInfo;

            ListViewUtil.SelectLine(item, true);

            this.Changed = true;
            return;
        ERROR1:
            MessageBox.Show(this, strError);
            return;
        }
Esempio n. 2
0
        private void button_newInstance_Click(object sender, EventArgs e)
        {
            try
            {
                HideMessageTip();
            }
            catch
            {
            }


            OneInstanceDialog new_instance_dlg = new OneInstanceDialog();
            GuiUtil.AutoSetDefaultFont(new_instance_dlg);
            new_instance_dlg.Text = "创建一个新实例";
            new_instance_dlg.IsNew = true;
            if (this.listView_instance.Items.Count == 0)
            {
            }
            else
            {
                new_instance_dlg.InstanceName = GetNewInstanceName(this.listView_instance.Items.Count + 1);
            }

            new_instance_dlg.VerifyInstanceName += new VerifyEventHandler(new_instance_dlg_VerifyInstanceName);
            new_instance_dlg.VerifyDataDir += new VerifyEventHandler(new_instance_dlg_VerifyDataDir);
            new_instance_dlg.VerifyBindings += new VerifyEventHandler(new_instance_dlg_VerifyBindings);
            new_instance_dlg.LoadXmlFileInfo += new LoadXmlFileInfoEventHandler(new_instance_dlg_LoadXmlFileInfo);

            new_instance_dlg.StartPosition = FormStartPosition.CenterScreen;
            if (new_instance_dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel)
                return;

            ListViewItem item = new ListViewItem();
            ListViewUtil.ChangeItemText(item, COLUMN_NAME, new_instance_dlg.InstanceName);
            ListViewUtil.ChangeItemText(item, COLUMN_DATADIR, new_instance_dlg.DataDir);
            ListViewUtil.ChangeItemText(item, COLUMN_BINDINGS, new_instance_dlg.Bindings.Replace("\r\n", ";"));
            this.listView_instance.Items.Add(item);

            new_instance_dlg.LineInfo.Changed = true;
            item.Tag = new_instance_dlg.LineInfo;

            ListViewUtil.SelectLine(item, true);

            this.Changed = true;
        }