internal void setCurrentSource(VM source) { Program.AssertOnEventThread(); // activeVNCView is going to change, so the current activeVNCView will become inactive // Start a timer for closing the inactive VNC connection after an interval (20 seconds) StartCloseVNCTimer(activeVNCView); this.Controls.Clear(); if (source == null) { activeVNCView = null; return; } List <Role> allowedRoles = null; if (RbacDenied(source, out allowedRoles)) { lableRbacWarning.Text = String.Format(allowedRoles.Count == 1 ? Messages.RBAC_CONSOLE_WARNING_ONE : Messages.RBAC_CONSOLE_WARNING_MANY, Role.FriendlyCSVRoleList(source.Connection.Session.Roles), Role.FriendlyCSVRoleList(allowedRoles)); this.Controls.Add(RbacWarningPanel); if (activeVNCView != null) { this.Controls.Remove(activeVNCView); } return; } activeVMConsoles.Remove(source); activeVMConsoles.Add(source); StopCloseVncTimer(source); while (activeVMConsoles.Count > MAX_ACTIVE_VM_CONSOLES) { closeVNCForSource(activeVMConsoles[0]); } if (vncViews.ContainsKey(source)) { activeVNCView = vncViews[source]; } else { activeVNCView = new VNCView(source, null, null); vncViews[source] = activeVNCView; } activeVNCView.refreshIsoList(); this.Controls.Add(activeVNCView); this.ClearErrorMessage(); }
internal void setCurrentSource(VM source) { Program.AssertOnEventThread(); this.Controls.Clear(); if (source == null) { activeVNCView = null; return; } List <Role> allowedRoles = null; if (RbacDenied(source, out allowedRoles)) { lableRbacWarning.Text = String.Format(allowedRoles.Count == 1 ? Messages.RBAC_CONSOLE_WARNING_ONE : Messages.RBAC_CONSOLE_WARNING_MANY, Role.FriendlyCSVRoleList(source.Connection.Session.Roles), Role.FriendlyCSVRoleList(allowedRoles)); this.Controls.Add(RbacWarningPanel); if (activeVNCView != null) { this.Controls.Remove(activeVNCView); } return; } activeVMConsoles.Remove(source); activeVMConsoles.Add(source); while (activeVMConsoles.Count > MAX_ACTIVE_VM_CONSOLES) { closeVNCForSource(activeVMConsoles[0]); activeVMConsoles.RemoveAt(0); } if (vncViews.ContainsKey(source)) { activeVNCView = vncViews[source]; } else { activeVNCView = new VNCView(source, null, null); vncViews[source] = activeVNCView; } activeVNCView.refreshIsoList(); this.Controls.Add(activeVNCView); this.ClearErrorMessage(); }
internal void setCurrentSource(VM source) { Program.AssertOnEventThread(); // activeVNCView is going to change, so the current activeVNCView will become inactive // Start a timer for closing the inactive VNC connection after an interval (20 seconds) StartCloseVNCTimer(activeVNCView); tableLayoutPanelRbac.Visible = false; if (activeVNCView != null) { Controls.Remove(activeVNCView); activeVNCView = null; } if (source == null) { return; } List <Role> allowedRoles; if (RbacDenied(source, out allowedRoles)) { string msg = allowedRoles.Count == 1 ? Messages.RBAC_CONSOLE_WARNING_ONE : Messages.RBAC_CONSOLE_WARNING_MANY; lableRbacWarning.Text = string.Format(msg, Role.FriendlyCSVRoleList(source.Connection.Session.Roles), Role.FriendlyCSVRoleList(allowedRoles)); tableLayoutPanelRbac.Visible = true; return; } StopCloseVncTimer(source); //remove one more as we're adding the selected further down //Take(arg) returns empty list if the arg <= 0 var viewsToRemove = vncViews.Where(v => v.Key.opaque_ref != source.opaque_ref).Take(vncViews.Count - 1 - MAX_ACTIVE_VM_CONSOLES); foreach (var view in viewsToRemove) { closeVNCForSource(view.Key); } if (vncViews.ContainsKey(source)) { activeVNCView = vncViews[source]; } else { activeVNCView = new VNCView(source, null, null) { Dock = DockStyle.Fill }; vncViews[source] = activeVNCView; } activeVNCView.refreshIsoList(); Controls.Add(activeVNCView); ClearErrorMessage(); }