Tidied up: the vncScreen should notify the parent vncTab when the rdp warning needs

to be shown. It is complicated to have the one control call a method in the other
which checks the state on the first control.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2016-08-24 11:48:42 +01:00
parent 38ca217bc3
commit a9a1cd6b9c
3 changed files with 21 additions and 6 deletions

View File

@ -24,6 +24,7 @@ namespace XenAdmin.ConsoleView
if (disposing && vncScreen != null && !vncScreen.IsDisposed)
{
vncScreen.GpuStatusChanged -= ShowGpuWarningIfRequired;
vncScreen.Dispose();
}

View File

@ -156,7 +156,8 @@ namespace XenAdmin.ConsoleView
log.DebugFormat("'{0}' console: Update power state (on VNCTabView constructor)", this.source.Name);
updatePowerState();
this.vncScreen = new XSVNCScreen(source, new EventHandler(RDPorVNCResizeHandler), this, elevatedUsername, elevatedPassword);
ShowGpuWarningIfRequired();
ShowGpuWarningIfRequired(vncScreen.MustConnectRemoteDesktop());
vncScreen.GpuStatusChanged += ShowGpuWarningIfRequired;
if (source.IsControlDomainZero || source.IsHVM && !hasRDP) //Linux HVM guests should only have one console: the console switch button vanishes altogether.
{
@ -1498,10 +1499,9 @@ namespace XenAdmin.ConsoleView
inToogleConsoleFocus = false;
}
internal void ShowGpuWarningIfRequired()
private void ShowGpuWarningIfRequired(bool mustConnectRemoteDesktop)
{
dedicatedGpuWarning.Visible = vncScreen != null && (vncScreen.UseVNC || string.IsNullOrEmpty(vncScreen.rdpIP)) &&
vncScreen.Source.HasGPUPassthrough && vncScreen.Source.power_state == vm_power_state.Running;
dedicatedGpuWarning.Visible = mustConnectRemoteDesktop;
}
internal bool IsVNC

View File

@ -114,6 +114,7 @@ namespace XenAdmin.ConsoleView
public event EventHandler UserCancelledAuth;
public event EventHandler VncConnectionAttemptCancelled;
public event Action<bool> GpuStatusChanged;
internal readonly VNCTabView parentVNCTabView;
@ -568,7 +569,14 @@ namespace XenAdmin.ConsoleView
RemoteConsole.Activate();
}
parentVNCTabView.ShowGpuWarningIfRequired();
if (GpuStatusChanged != null)
GpuStatusChanged(MustConnectRemoteDesktop());
}
internal bool MustConnectRemoteDesktop()
{
return (UseVNC || string.IsNullOrEmpty(rdpIP)) &&
Source.HasGPUPassthrough && Source.power_state == vm_power_state.Running;
}
private void SetKeyboardAndMouseCapture(bool value)
@ -785,7 +793,13 @@ namespace XenAdmin.ConsoleView
}
if (e.PropertyName == "power_state" || e.PropertyName == "VGPUs")
parentVNCTabView.ShowGpuWarningIfRequired();
{
Program.Invoke(this, () =>
{
if (GpuStatusChanged != null)
GpuStatusChanged(MustConnectRemoteDesktop());
});
}
}
internal void imediatelyPollForConsole()