Ejemplo n.º 1
0
        public static MemService AddService(int port)
        {
            var name    = string.Format("{0} {1}", servicePreName, port);
            var service = new MemService(name);

            return(service);
        }
Ejemplo n.º 2
0
        private void RefreshService()
        {
            var ms = MemService.GetMemService();

            this.cmbBoxPort.Items.AddRange(ms);
            if (ms.Length > 0)
            {
                this.cmbBoxPort.SelectedIndex = 0;
            }
        }
Ejemplo n.º 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var add = new AddFrom();

            if (add.ShowDialog() == DialogResult.OK)
            {
                int port = add.Port;
                int mem  = add.MaxMem;

                var s = MemService.GetMemService().FirstOrDefault(item => item.Port == port);
                if (s != null)
                {
                    MessageBox.Show("此端口的服务已经存在...", "提示");
                    return;
                }

                s = MemService.AddService(port);
                s.Start(mem, port);
                this.cmbBoxPort.Items.Add(s);
                this.cmbBoxPort.SelectedItem = s;
            }
        }
Ejemplo n.º 4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("删除服务会带来数据丢,确定要继续吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            if (this.currentService != null)
            {
                this.currentService.Delete();
            }

            var item = this.currentService;

            this.currentService = null;
            this.cmbBoxPort.Items.Remove(item);
            if (this.cmbBoxPort.Items.Count > 0)
            {
                this.cmbBoxPort.SelectedIndex = 0;
            }
            this.BindingStatus();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 选择变化
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmbBoxPort_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.currentService = this.cmbBoxPort.SelectedItem as MemService;
     this.BindingStatus();
 }