Exemple #1
0
        /// <summary>
        ///     连接
        /// </summary>
        /// <param name="strNodeType"></param>
        /// <param name="e"></param>
        private void ConnectionHandler(string strNodeType, TreeNodeMouseClickEventArgs e)
        {
            //普通连接
            statusStripMain.Items[0].Text =
                GuiConfig.GetText("Selected Connection", "SelectedServer") + ":" +
                RuntimeMongoDbContext.SelectTagData;

            DisconnectToolStripMenuItem.Enabled = true;

            switch (strNodeType)
            {
            case ConstMgr.ConnectionTag:
                InitReplsetToolStripMenuItem.Enabled = true;
                break;

            case ConstMgr.ConnectionReplsetTag:
                ReplicaSetToolStripMenuItem.Enabled = true;
                break;

            case ConstMgr.ConnectionClusterTag:
                ShardingConfigToolStripMenuItem.Enabled = true;
                break;
            }
            if (e.Button == MouseButtons.Right)
            {
                contextMenuStripMain = new ContextMenuStrip();
                if (SystemManager.MonoMode)
                {
                    var disconnect = DisconnectToolStripMenuItem.Clone();
                    disconnect.Click += DisconnectToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(disconnect);

                    var initReplset = InitReplsetToolStripMenuItem.Clone();
                    initReplset.Click += InitReplsetToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(initReplset);

                    var replicaSet = ReplicaSetToolStripMenuItem.Clone();
                    replicaSet.Click += ReplicaSetToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(replicaSet);

                    var shardingConfig = ShardingConfigToolStripMenuItem.Clone();
                    shardingConfig.Click += ShardingConfigToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(shardingConfig);
                }
                else
                {
                    contextMenuStripMain.Items.Add(DisconnectToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(InitReplsetToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(ReplicaSetToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(ShardingConfigToolStripMenuItem.Clone());
                }
                e.Node.ContextMenuStrip = contextMenuStripMain;
                contextMenuStripMain.Show(trvsrvlst.PointToScreen(e.Location));
            }
        }
        /// <summary>
        ///     连接
        /// </summary>
        /// <param name="strNodeType"></param>
        /// <param name="e"></param>
        private void ConnectionHandler(string strNodeType, TreeNodeMouseClickEventArgs e)
        {
            //普通连接
            if (GuiConfig.IsUseDefaultLanguage)
            {
                statusStripMain.Items[0].Text = "Selected Connection:" + RuntimeMongoDbContext.SelectTagData;
            }
            else
            {
                statusStripMain.Items[0].Text =
                    GuiConfig.GetText(TextType.SelectedServer) + ":" +
                    RuntimeMongoDbContext.SelectTagData;
            }

            DisconnectToolStripMenuItem.Enabled = true;
            //ShutDownToolStripMenuItem.Enabled = true;
            //ShutDownToolStripButton.Enabled = true;

            switch (strNodeType)
            {
            case ConstMgr.ConnectionTag:
                InitReplsetToolStripMenuItem.Enabled = true;
                break;

            case ConstMgr.ConnectionReplsetTag:
                ReplicaSetToolStripMenuItem.Enabled = true;
                break;

            case ConstMgr.ConnectionClusterTag:
                ShardingConfigToolStripMenuItem.Enabled = true;
                break;
            }
            if (e.Button == MouseButtons.Right)
            {
                contextMenuStripMain = new ContextMenuStrip();
                if (SystemManager.MonoMode)
                {
                    var t1 = DisconnectToolStripMenuItem.Clone();
                    t1.Click += DisconnectToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(t1);

                    var t2 = InitReplsetToolStripMenuItem.Clone();
                    t2.Click += InitReplsetToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(t2);

                    var t3 = ReplicaSetToolStripMenuItem.Clone();
                    t3.Click += ReplicaSetToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(t3);

                    var t4 = ShardingConfigToolStripMenuItem.Clone();
                    t4.Click += ShardingConfigToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(t4);

                    //var t5 = ShutDownToolStripMenuItem.Clone();
                    //t5.Click += ShutDownToolStripMenuItem_Click;
                    //contextMenuStripMain.Items.Add(t5);
                }
                else
                {
                    contextMenuStripMain.Items.Add(DisconnectToolStripMenuItem.Clone());
                    //contextMenuStripMain.Items.Add(ShutDownToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(InitReplsetToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(ReplicaSetToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(ShardingConfigToolStripMenuItem.Clone());
                }
                e.Node.ContextMenuStrip = contextMenuStripMain;
                contextMenuStripMain.Show(trvsrvlst.PointToScreen(e.Location));
            }
        }