private static void MenuPopup(object sender, CancelEventArgs e) { _menu.Items.Clear(); ServerLabel serverLabel = (sender as ContextMenuStrip).SourceControl as ServerLabel; ServerBase server = serverLabel.AssociatedNode; MenuHelper.AddSessionMenuItems(_menu, server); _menu.Items.Add("-"); _menu.Items.Add(new DelegateMenuItem("E&xpand", MenuNames.SessionExpand, delegate { ServerTree.Instance.SelectedNode = server; if (server.IsConnected) { server.Focus(); } })); MenuHelper.AddDockingMenuItems(_menu, server); _menu.Items.Add("-"); MenuHelper.AddMaintenanceMenuItems(_menu, server); Program.PluginAction(delegate(IPlugin p) { p.OnContextMenu(_menu, server); }); e.Cancel = false; }
protected override void OnEnter(EventArgs e) { bool flag = true; base.OnEnter(e); if (_layout != null) { if (_layout.NodeCount > 0) { ServerLabel serverLabel = _layout.LabelArray[_layout.FocusedServerIndex - 1]; if (serverLabel.Parent == this) { serverLabel.Focus(); flag = false; } } } else { ServerBase serverBase = ServerTree.Instance.SelectedNode as ServerBase; if (serverBase != null) { serverBase.Focus(); flag = false; } } if (flag) { Focus(); } }
public static void SelectNewActiveConnection(bool selectPrevious) { List <ServerBase> connectedServers = new List <ServerBase>(); ConnectedGroup.Instance.Nodes.VisitNodes(delegate(RdcTreeNode node) { connectedServers.Add(node as ServerBase); }); connectedServers.Sort((ServerBase a, ServerBase b) => (b as ConnectedServerRef).LastFocusTime.CompareTo((a as ConnectedServerRef).LastFocusTime)); ServerBase serverBase = null; if (selectPrevious) { serverBase = connectedServers[Math.Min(1, connectedServers.Count - 1)]; } else { using (SelectActiveServerForm selectActiveServerForm = new SelectActiveServerForm(connectedServers)) { if (selectActiveServerForm.ShowDialog() == DialogResult.OK) { SelectActiveServerForm.SelectedObject selected = selectActiveServerForm.Selected; switch (selected.Operation) { case SelectActiveServerForm.Operation.MinimizeWindow: { IntPtr window = User.GetWindow(Program.TheForm.Handle, 2u); User.SetForegroundWindow(window); Program.TheForm.WindowState = FormWindowState.Minimized; break; } case SelectActiveServerForm.Operation.SelectServer: serverBase = selected.Server; break; case SelectActiveServerForm.Operation.SelectTree: Program.TheForm.GoToServerTree(); break; } } } } if (serverBase != null) { Program.TheForm.SwitchFullScreenClient(serverBase.ServerNode); ServerTree.Instance.SelectedNode = serverBase; serverBase.Focus(); } }