Esempio n. 1
0
        /// <summary>
        ///     Server
        /// </summary>
        /// <param name="e"></param>
        private void ServerHandler(TreeNodeMouseClickEventArgs e)
        {
            RuntimeMongoDbContext.SelectObjectTag = e.Node.Tag.ToString();
            statusStripMain.Items[0].Text         =
                GuiConfig.GetText("Selected Server", "SelectedServer") + ":" +
                RuntimeMongoDbContext.SelectTagData;
            //解禁 创建数据库,关闭服务器
            if (!RuntimeMongoDbContext.CurrentMongoConnectionconfig.IsReadOnly)
            {
                CreateMongoDBToolStripMenuItem.Enabled   = true;
                AddUserToAdminToolStripMenuItem.Enabled  = true;
                AddAdminCustomeRoleStripMenuItem.Enabled = true;
            }
            ServerStatusToolStripMenuItem.Enabled  = true;
            ServerMonitorToolStripMenuItem.Enabled = true;

            if (e.Button == MouseButtons.Right)
            {
                contextMenuStripMain = new ContextMenuStrip();
                if (SystemManager.MonoMode)
                {
                    //悲催MONO不支持
                    var createMongoDb = CreateMongoDBToolStripMenuItem.Clone();
                    createMongoDb.Click += CreateMongoDBToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(createMongoDb);

                    var addUserToAdmin = AddUserToAdminToolStripMenuItem.Clone();
                    addUserToAdmin.Click += AddUserToAdminToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(addUserToAdmin);

                    var restoreMongo = RestoreMongoToolStripMenuItem.Clone();
                    restoreMongo.Click += RestoreMongoToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(restoreMongo);

                    var serverStatus = ServerStatusToolStripMenuItem.Clone();
                    serverStatus.Click += SvrStatusToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(serverStatus);
                }
                else
                {
                    contextMenuStripMain.Items.Add(CreateMongoDBToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(AddUserToAdminToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(AddAdminCustomeRoleStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(RestoreMongoToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(ServerStatusToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(ServerMonitorToolStripMenuItem.Clone());
                }
                e.Node.ContextMenuStrip = contextMenuStripMain;
                contextMenuStripMain.Show(trvsrvlst.PointToScreen(e.Location));
            }
            //PlugIn
            foreach (ToolStripMenuItem item in plugInToolStripMenuItem.DropDownItems)
            {
                if (PlugIn.PlugInList[item.Tag.ToString()].RunLv == PlugInBase.PathLv.ConnectionLv)
                {
                    item.Enabled = true;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Server
        /// </summary>
        /// <param name="e"></param>
        private void ServerHandler(TreeNodeMouseClickEventArgs e)
        {
            RuntimeMongoDbContext.SelectObjectTag = e.Node.Tag.ToString();
            if (GuiConfig.IsUseDefaultLanguage)
            {
                statusStripMain.Items[0].Text = "Selected Server:" + RuntimeMongoDbContext.SelectTagData;
            }
            else
            {
                statusStripMain.Items[0].Text =
                    GuiConfig.GetText(TextType.SelectedServer) + ":" +
                    RuntimeMongoDbContext.SelectTagData;
            }
            //解禁 创建数据库,关闭服务器
            if (!RuntimeMongoDbContext.CurrentMongoConnectionconfig.IsReadOnly)
            {
                CreateMongoDBToolStripMenuItem.Enabled  = true;
                AddUserToAdminToolStripMenuItem.Enabled = true;
                if (RuntimeMongoDbContext.CurrentMongoConnectionconfig.ServerRole ==
                    MongoConnectionConfig.SvrRoleType.MasterSvr ||
                    RuntimeMongoDbContext.CurrentMongoConnectionconfig.ServerRole ==
                    MongoConnectionConfig.SvrRoleType.SlaveSvr)
                {
                    //Master,Slave都可以执行
                    slaveResyncToolStripMenuItem.Enabled = true;
                }
            }
            UserInfoStripMenuItem.Enabled          = true;
            ServerStatusToolStripMenuItem.Enabled  = true;
            ServePropertyToolStripMenuItem.Enabled = true;

            if (e.Button == MouseButtons.Right)
            {
                contextMenuStripMain = new ContextMenuStrip();
                if (SystemManager.MonoMode)
                {
                    //悲催MONO不支持
                    var t1 = CreateMongoDBToolStripMenuItem.Clone();
                    t1.Click += CreateMongoDBToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(t1);

                    var t2 = AddUserToAdminToolStripMenuItem.Clone();
                    t2.Click += AddUserToAdminToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(t2);

                    var t3 = RestoreMongoToolStripMenuItem.Clone();
                    t3.Click += RestoreMongoToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(t3);

                    var t6 = slaveResyncToolStripMenuItem.Clone();
                    t6.Click += slaveResyncToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(t6);

                    var t9 = ServePropertyToolStripMenuItem.Clone();
                    t9.Click += ServePropertyToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(t9);

                    var t10 = ServerStatusToolStripMenuItem.Clone();
                    t10.Click += SvrStatusToolStripMenuItem_Click;
                    contextMenuStripMain.Items.Add(t10);
                }
                else
                {
                    contextMenuStripMain.Items.Add(CreateMongoDBToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(AddUserToAdminToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(AddAdminCustomeRoleStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(UserInfoStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(RestoreMongoToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(slaveResyncToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(ServePropertyToolStripMenuItem.Clone());
                    contextMenuStripMain.Items.Add(ServerStatusToolStripMenuItem.Clone());
                }
                e.Node.ContextMenuStrip = contextMenuStripMain;
                contextMenuStripMain.Show(trvsrvlst.PointToScreen(e.Location));
            }
            //PlugIn
            foreach (ToolStripMenuItem item in plugInToolStripMenuItem.DropDownItems)
            {
                if (PlugIn.PlugInList[item.Tag.ToString()].RunLv == PlugInBase.PathLv.ConnectionLv)
                {
                    item.Enabled = true;
                }
            }
        }