Exemplo n.º 1
0
        private void 修改连接配置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode select = treeView1.SelectedNode;

            if (select == null)
            {
                return;
            }
            if (select.ImageKey != "VirtualMachine")
            {
                return;
            }

            if (select.Tag is RedisSettings settings)
            {
                using (FormRedisAdd form = new FormRedisAdd(settings))
                {
                    if (form.ShowDialog( ) == DialogResult.OK)
                    {
                        if (settings.Redis != null)
                        {
                            settings.Redis.ConnectClose( );
                            settings.Redis = null;
                        }
                        SaveRedisSettings( );
                        if (MessageBox.Show("当前的连接配置已经更新,是否重新刷新数据?", "刷新确认", MessageBoxButtons.YesNo) == DialogResult.OK)
                        {
                            RefreshRedisKey(select, true);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            // 新增服务器
            using (FormRedisAdd form = new FormRedisAdd(null))
            {
                while (true)
                {
                    if (form.ShowDialog( ) == DialogResult.OK)
                    {
                        if (redisSettings.Find(m => m.Name == form.Settings.Name) == null)
                        {
                            break;
                        }
                        else
                        {
                            MessageBox.Show("当前输入的服务器别名已经存在,请重新输入!");
                        }
                    }
                    else
                    {
                        return;
                    }
                }

                redisSettings.Add(form.Settings);
                // 配置存储
                SaveRedisSettings( );

                // 添加列表显示
                TreeNode node = new TreeNode(form.Settings.Name);
                node.ImageKey         = "VirtualMachine";
                node.SelectedImageKey = "VirtualMachine";
                node.Tag = form.Settings;
                treeView1.Nodes.Add(node);
            }
        }