Ejemplo n.º 1
0
        protected void CreateMainMenu()
        {
            _sessionConnectServerMenuItem = new DelegateMenuItem("连接", MenuNames.SessionConnect, "Enter", delegate
            {
                _server.Connect();
            });
            _sessionConnectServerAsMenuItem = new DelegateMenuItem("连接为...", MenuNames.SessionConnectAs, "Shift+Enter", delegate
            {
                _server.DoConnectAs();
            });
            _sessionReconnectServerMenuItem = new DelegateMenuItem("重连接", MenuNames.SessionReconnect, delegate
            {
                _server.Reconnect();
            });
            _sessionDisconnectServerMenuItem = new DelegateMenuItem("断开连接", MenuNames.SessionDisconnect, delegate
            {
                _server.Disconnect();
            });
            _sessionFullScreenMenuItem = new DelegateMenuItem("全屏", MenuNames.SessionFullScreen, delegate
            {
                _server.Client.MsRdpClient.FullScreen = true;
            });
            DelegateMenuItem value = new DelegateMenuItem("停靠", MenuNames.SessionDock, delegate
            {
                Close();
            });

            _sessionScreenCaptureMenuItem = new DelegateMenuItem("屏幕截图", MenuNames.SessionScreenCapture, delegate
            {
                _server.ScreenCapture();
            });
            DelegateMenuItem value2 = new DelegateMenuItem("属性", MenuNames.EditProperties, "Alt+Enter", delegate
            {
                _server.DoPropertiesDialog();
            });
            ToolStripMenuItem toolStripMenuItem = _menuStrip.Add("会话", MenuNames.Session);

            toolStripMenuItem.DropDownItems.Add(_sessionConnectServerMenuItem);
            toolStripMenuItem.DropDownItems.Add(_sessionConnectServerAsMenuItem);
            toolStripMenuItem.DropDownItems.Add(_sessionReconnectServerMenuItem);
            toolStripMenuItem.DropDownItems.Add("-");
            _sessionSendKeysMenuItem = toolStripMenuItem.DropDownItems.Add("发送按键", MenuNames.SessionSendKeys);
            MenuHelper.AddSendKeysMenuItems(_sessionSendKeysMenuItem, () => _server);
            if (RdpClient.SupportsRemoteSessionActions)
            {
                _sessionRemoteActionsMenuItem = toolStripMenuItem.DropDownItems.Add("远程动作", MenuNames.SessionRemoteActions);
                MenuHelper.AddRemoteActionsMenuItems(_sessionRemoteActionsMenuItem, () => _server);
            }
            toolStripMenuItem.DropDownItems.Add("-");
            toolStripMenuItem.DropDownItems.Add(_sessionDisconnectServerMenuItem);
            toolStripMenuItem.DropDownItems.Add("-");
            toolStripMenuItem.DropDownItems.Add(_sessionFullScreenMenuItem);
            toolStripMenuItem.DropDownItems.Add(value);
            toolStripMenuItem.DropDownItems.Add("-");
            toolStripMenuItem.DropDownItems.Add(_sessionScreenCaptureMenuItem);
            toolStripMenuItem.DropDownItems.Add("-");
            toolStripMenuItem.DropDownItems.Add(value2);
            ToolStripMenuItem toolStripMenuItem2 = _menuStrip.Add("视图", MenuNames.View);
            ToolStripMenuItem toolStripMenuItem3 = toolStripMenuItem2.DropDownItems.Add("桌面大小", MenuNames.ViewClientSize);

            Size[] stockSizes = SizeHelper.StockSizes;
            foreach (Size size in stockSizes)
            {
                ClientSizeCheckedMenuItem value3 = new ClientSizeCheckedMenuItem(this, size);
                toolStripMenuItem3.DropDownItems.Add(value3);
            }
            toolStripMenuItem3.DropDownItems.Add(new CustomClientSizeCheckedMenuItem(this, "自定义"));
            toolStripMenuItem3.DropDownItems.Add(new ToolStripMenuItem("适应远程桌面大小", null, delegate
            {
                SetClientSize(_server.IsConnected ? _server.Client.DesktopSize : _server.RemoteDesktopSettings.DesktopSize.Value);
            }));
        }