Example #1
0
        private void button_newInstance_Click(object sender, EventArgs e)
        {
            InstanceDialog dlg = new InstanceDialog();

            FontUtil.AutoSetDefaultFont(dlg);

            dlg.ParentDialog = this;
            dlg.Index        = this.listView_instance.Items.Count;
            dlg.InstanceName = "?";
            // 找到一个没有用过的目录名字
            dlg.DataDir       = GetNewDirectoryName(this.DataDir);
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

            if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            ListViewItem item = new ListViewItem(dlg.InstanceName);

            RefreshItemLine(item, dlg.DataDir);
            this.listView_instance.Items.Add(item);

            if (dlg.InstanceName.IndexOf("?") != -1)
            {
                RefreshInstanceName(item);
            }
        }
Example #2
0
        private void button_modifyInstance_Click(object sender, EventArgs e)
        {
            string strError = "";

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

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

            InstanceDialog dlg = new InstanceDialog();

            FontUtil.AutoSetDefaultFont(dlg);

            dlg.ParentDialog = this;
            dlg.Index        = this.listView_instance.Items.IndexOf(item);
            dlg.InstanceName = ListViewUtil.GetItemText(item, COLUMN_NAME);
            dlg.DataDir      = ListViewUtil.GetItemText(item, COLUMN_DATADIR);

            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

            if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            RefreshItemLine(item, dlg.DataDir);
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Example #3
0
        private void button_newInstance_Click(object sender, EventArgs e)
        {
            InstanceDialog new_instance_dlg = new InstanceDialog();

            FontUtil.AutoSetDefaultFont(new_instance_dlg);

            new_instance_dlg.ParentDialog = this;
            new_instance_dlg.Index        = this.listView_instance.Items.Count;
            new_instance_dlg.InstanceName = "?";
            // 找到一个没有用过的目录名字
            new_instance_dlg.DataDir       = GetNewDirectoryName(this.DataDir);
            new_instance_dlg.StartPosition = FormStartPosition.CenterScreen;
            new_instance_dlg.ShowDialog(this);

            if (new_instance_dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            this.Enabled = false;
            try
            {
                ListViewItem item = new ListViewItem(new_instance_dlg.InstanceName);

                RefreshItemLine(item, new_instance_dlg.DataDir);
                this.listView_instance.Items.Add(item);

                if (new_instance_dlg.InstanceName.IndexOf("?") != -1)
                {
                    RefreshInstanceName(item);
                }

                if (IsDp2CapoRunning())
                {
                    StartOrStopOneInstance(new_instance_dlg.InstanceName, "start");
                }
            }
            finally
            {
                this.Enabled = true;
            }
        }
Example #4
0
        private void button_newInstance_Click(object sender, EventArgs e)
        {
            InstanceDialog dlg = new InstanceDialog();

            FontUtil.AutoSetDefaultFont(dlg);

            dlg.InstanceName = "?";
            // 找到一个没有用过的目录名字
            dlg.DataDir       = GetNewDirectoryName(this.DataDir);
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

            if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            ListViewItem item = new ListViewItem((this.listView_instance.Items.Count + 1).ToString());

            ListViewUtil.ChangeItemText(item, COLUMN_DATADIR, dlg.DataDir);
            this.listView_instance.Items.Add(item);
        }
Example #5
0
        private void button_modifyInstance_Click(object sender, EventArgs e)
        {
            string strError = "";

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

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

            string strInstanceName = ListViewUtil.GetItemText(item, COLUMN_NAME);

            if (IsLocking(strInstanceName))
            {
                strError = "实例 '" + strInstanceName + "' 当前处于被锁定状态,无法进行修改操作";
                goto ERROR1;
            }

            bool bStopped = false;

            if (item.ImageIndex == IMAGEINDEX_RUNNING)
            {
                // 只对正在 running 状态的实例做停止处理
                StartOrStopOneInstance(strInstanceName,
                                       "stop");
                bStopped = true;
            }
            try
            {
                InstanceDialog dlg = new InstanceDialog();
                FontUtil.AutoSetDefaultFont(dlg);

                dlg.ParentDialog = this;
                dlg.Index        = this.listView_instance.Items.IndexOf(item);
                dlg.InstanceName = strInstanceName;
                dlg.DataDir      = ListViewUtil.GetItemText(item, COLUMN_DATADIR);

                dlg.StartPosition = FormStartPosition.CenterScreen;
                dlg.ShowDialog(this);

                if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                RefreshItemLine(item, dlg.DataDir);
            }
            finally
            {
                if (bStopped)
                {
                    StartOrStopOneInstance(strInstanceName,
                                           "start");
                }
            }
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }