mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-24 22:06:59 +01:00
Tidy up XSVNCScreen
: remove this
when unnecessary
Signed-off-by: Danilo Del Busso <danilo.delbusso@cloud.com>
This commit is contained in:
parent
b8eb2b5549
commit
53fba195a7
@ -148,10 +148,10 @@ namespace XenAdmin.ConsoleView
|
|||||||
internal XSVNCScreen(VM source, EventHandler resizeHandler, VNCTabView parent, string elevatedUsername, string elevatedPassword)
|
internal XSVNCScreen(VM source, EventHandler resizeHandler, VNCTabView parent, string elevatedUsername, string elevatedPassword)
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
this.ResizeHandler = resizeHandler;
|
ResizeHandler = resizeHandler;
|
||||||
this.parentVNCTabView = parent;
|
parentVNCTabView = parent;
|
||||||
this.Source = source;
|
Source = source;
|
||||||
this.KeyHandler = parentVNCTabView.KeyHandler;
|
KeyHandler = parentVNCTabView.KeyHandler;
|
||||||
ElevatedUsername = elevatedUsername;
|
ElevatedUsername = elevatedUsername;
|
||||||
ElevatedPassword = elevatedPassword;
|
ElevatedPassword = elevatedPassword;
|
||||||
|
|
||||||
@ -519,9 +519,9 @@ namespace XenAdmin.ConsoleView
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
bool wasFocused = false;
|
bool wasFocused = false;
|
||||||
this.Controls.Clear();
|
Controls.Clear();
|
||||||
//console size with some offset to accomodate focus rectangle
|
//console size with some offset to accomodate focus rectangle
|
||||||
Size currentConsoleSize = new Size(this.Size.Width - CONSOLE_SIZE_OFFSET, this.Size.Height - CONSOLE_SIZE_OFFSET);
|
Size currentConsoleSize = new Size(Size.Width - CONSOLE_SIZE_OFFSET, Size.Height - CONSOLE_SIZE_OFFSET);
|
||||||
|
|
||||||
lock (_rdpConnectionLock)
|
lock (_rdpConnectionLock)
|
||||||
{
|
{
|
||||||
@ -539,7 +539,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
RemoteConsole.DisconnectAndDispose();
|
RemoteConsole.DisconnectAndDispose();
|
||||||
RemoteConsole = null;
|
RemoteConsole = null;
|
||||||
}
|
}
|
||||||
this.vncPassword = null;
|
vncPassword = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,8 +549,8 @@ namespace XenAdmin.ConsoleView
|
|||||||
|
|
||||||
if (UseVNC || String.IsNullOrEmpty(RdpIp))
|
if (UseVNC || String.IsNullOrEmpty(RdpIp))
|
||||||
{
|
{
|
||||||
this.AutoScroll = false;
|
AutoScroll = false;
|
||||||
this.AutoScrollMinSize = new Size(0, 0);
|
AutoScrollMinSize = new Size(0, 0);
|
||||||
|
|
||||||
vncClient = new VNCGraphicsClient(this);
|
vncClient = new VNCGraphicsClient(this);
|
||||||
|
|
||||||
@ -565,10 +565,10 @@ namespace XenAdmin.ConsoleView
|
|||||||
{
|
{
|
||||||
if (rdpClient == null)
|
if (rdpClient == null)
|
||||||
{
|
{
|
||||||
if (this.ParentForm is FullScreenForm)
|
if (ParentForm is FullScreenForm)
|
||||||
currentConsoleSize = ((FullScreenForm)ParentForm).GetContentSize();
|
currentConsoleSize = ((FullScreenForm)ParentForm).GetContentSize();
|
||||||
this.AutoScroll = true;
|
AutoScroll = true;
|
||||||
this.AutoScrollMinSize = oldSize;
|
AutoScrollMinSize = oldSize;
|
||||||
rdpClient = new RdpClient(this, currentConsoleSize, ResizeHandler);
|
rdpClient = new RdpClient(this, currentConsoleSize, ResizeHandler);
|
||||||
|
|
||||||
rdpClient.OnDisconnected += new EventHandler(parentVNCTabView.RdpDisconnectedHandler);
|
rdpClient.OnDisconnected += new EventHandler(parentVNCTabView.RdpDisconnectedHandler);
|
||||||
@ -577,10 +577,10 @@ namespace XenAdmin.ConsoleView
|
|||||||
|
|
||||||
if (RemoteConsole != null && RemoteConsole.ConsoleControl != null)
|
if (RemoteConsole != null && RemoteConsole.ConsoleControl != null)
|
||||||
{
|
{
|
||||||
RemoteConsole.KeyHandler = this.KeyHandler;
|
RemoteConsole.KeyHandler = KeyHandler;
|
||||||
RemoteConsole.SendScanCodes = !this.sourceIsPV;
|
RemoteConsole.SendScanCodes = !sourceIsPV;
|
||||||
RemoteConsole.Scaling = Scaling;
|
RemoteConsole.Scaling = Scaling;
|
||||||
RemoteConsole.DisplayBorder = this.displayFocusRectangle;
|
RemoteConsole.DisplayBorder = displayFocusRectangle;
|
||||||
SetKeyboardAndMouseCapture(autoCaptureKeyboardAndMouse);
|
SetKeyboardAndMouseCapture(autoCaptureKeyboardAndMouse);
|
||||||
if (wasPaused)
|
if (wasPaused)
|
||||||
RemoteConsole.Pause();
|
RemoteConsole.Pause();
|
||||||
@ -694,7 +694,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return this.sourceVM;
|
return sourceVM;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@ -971,8 +971,8 @@ namespace XenAdmin.ConsoleView
|
|||||||
OnVncConnectionAttemptCancelled();
|
OnVncConnectionAttemptCancelled();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.vncPassword = Settings.GetVNCPassword(sourceVM.uuid);
|
vncPassword = Settings.GetVNCPassword(sourceVM.uuid);
|
||||||
if (this.vncPassword == null)
|
if (vncPassword == null)
|
||||||
{
|
{
|
||||||
bool lifecycleOperationInProgress = sourceVM.current_operations.Values.Any(VM.is_lifecycle_operation);
|
bool lifecycleOperationInProgress = sourceVM.current_operations.Values.Any(VM.is_lifecycle_operation);
|
||||||
if (haveTriedLoginWithoutPassword && !lifecycleOperationInProgress)
|
if (haveTriedLoginWithoutPassword && !lifecycleOperationInProgress)
|
||||||
@ -982,7 +982,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
promptForPassword(ignoreNextError ? null : error);
|
promptForPassword(ignoreNextError ? null : error);
|
||||||
});
|
});
|
||||||
ignoreNextError = false;
|
ignoreNextError = false;
|
||||||
if (this.vncPassword == null)
|
if (vncPassword == null)
|
||||||
{
|
{
|
||||||
Log.Debug("User cancelled VNC password prompt: aborting connection attempt");
|
Log.Debug("User cancelled VNC password prompt: aborting connection attempt");
|
||||||
OnUserCancelledAuth();
|
OnUserCancelledAuth();
|
||||||
@ -992,7 +992,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Debug("Attempting passwordless VNC login");
|
Log.Debug("Attempting passwordless VNC login");
|
||||||
this.vncPassword = new char[0];
|
vncPassword = new char[0];
|
||||||
ignoreNextError = true;
|
ignoreNextError = true;
|
||||||
haveTriedLoginWithoutPassword = true;
|
haveTriedLoginWithoutPassword = true;
|
||||||
}
|
}
|
||||||
@ -1007,15 +1007,15 @@ namespace XenAdmin.ConsoleView
|
|||||||
}
|
}
|
||||||
if (s == null)
|
if (s == null)
|
||||||
{
|
{
|
||||||
Log.DebugFormat("Connecting to vncIP={0}, port={1}", this.VncIp, VNC_PORT);
|
Log.DebugFormat("Connecting to vncIP={0}, port={1}", VncIp, VNC_PORT);
|
||||||
s = connectGuest(this.VncIp, VNC_PORT, sourceVM.Connection);
|
s = connectGuest(VncIp, VNC_PORT, sourceVM.Connection);
|
||||||
Log.DebugFormat("Connected to vncIP={0}, port={1}", this.VncIp, VNC_PORT);
|
Log.DebugFormat("Connected to vncIP={0}, port={1}", VncIp, VNC_PORT);
|
||||||
}
|
}
|
||||||
InvokeConnection(v, s, null);
|
InvokeConnection(v, s, null);
|
||||||
|
|
||||||
// store the empty vnc password after a successful passwordless login
|
// store the empty vnc password after a successful passwordless login
|
||||||
if (haveTriedLoginWithoutPassword && this.vncPassword.Length == 0)
|
if (haveTriedLoginWithoutPassword && vncPassword.Length == 0)
|
||||||
Program.Invoke(this, () => Settings.SetVNCPassword(sourceVM.uuid, this.vncPassword));
|
Program.Invoke(this, () => Settings.SetVNCPassword(sourceVM.uuid, vncPassword));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exn)
|
catch (Exception exn)
|
||||||
@ -1036,8 +1036,8 @@ namespace XenAdmin.ConsoleView
|
|||||||
if (f.ShowDialog(this) == DialogResult.OK)
|
if (f.ShowDialog(this) == DialogResult.OK)
|
||||||
{
|
{
|
||||||
// Store password for next time
|
// Store password for next time
|
||||||
this.vncPassword = f.Password;
|
vncPassword = f.Password;
|
||||||
Settings.SetVNCPassword(sourceVM.uuid, this.vncPassword);
|
Settings.SetVNCPassword(sourceVM.uuid, vncPassword);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1118,11 +1118,11 @@ namespace XenAdmin.ConsoleView
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
v.SendScanCodes = UseSource && !this.sourceIsPV;
|
v.SendScanCodes = UseSource && !sourceIsPV;
|
||||||
v.SourceVM = sourceVM;
|
v.SourceVM = sourceVM;
|
||||||
v.Console = console;
|
v.Console = console;
|
||||||
v.UseQemuExtKeyEncoding = sourceVM != null && Helpers.InvernessOrGreater(sourceVM.Connection);
|
v.UseQemuExtKeyEncoding = sourceVM != null && Helpers.InvernessOrGreater(sourceVM.Connection);
|
||||||
v.Connect(stream, this.vncPassword);
|
v.Connect(stream, vncPassword);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1151,7 +1151,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
{
|
{
|
||||||
Program.AssertOffEventThread();
|
Program.AssertOffEventThread();
|
||||||
|
|
||||||
if (this.Disposing || this.IsDisposed)
|
if (Disposing || IsDisposed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Program.Invoke(this, delegate()
|
Program.Invoke(this, delegate()
|
||||||
@ -1174,7 +1174,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Warn(exn, exn);
|
Log.Warn(exn, exn);
|
||||||
this.errorMessage = exn.Message;
|
errorMessage = exn.Message;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1198,21 +1198,21 @@ namespace XenAdmin.ConsoleView
|
|||||||
protected override void OnPaint(PaintEventArgs e)
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnPaint(e);
|
base.OnPaint(e);
|
||||||
if (this.errorMessage != null)
|
if (errorMessage != null)
|
||||||
{
|
{
|
||||||
SizeF size = e.Graphics.MeasureString(this.errorMessage, this.Font);
|
SizeF size = e.Graphics.MeasureString(errorMessage, Font);
|
||||||
e.Graphics.DrawString(this.errorMessage, this.Font, Brushes.Black,
|
e.Graphics.DrawString(errorMessage, Font, Brushes.Black,
|
||||||
((this.Width - size.Width) / 2), ((this.Height - size.Height) / 2));
|
((Width - size.Width) / 2), ((Height - size.Height) / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw focus rectangle
|
// draw focus rectangle
|
||||||
if (DisplayFocusRectangle && this.ContainsFocus && RemoteConsole != null)
|
if (DisplayFocusRectangle && ContainsFocus && RemoteConsole != null)
|
||||||
{
|
{
|
||||||
Rectangle focusRect = Rectangle.Inflate(RemoteConsole.ConsoleBounds, VNCGraphicsClient.BORDER_PADDING / 2,
|
Rectangle focusRect = Rectangle.Inflate(RemoteConsole.ConsoleBounds, VNCGraphicsClient.BORDER_PADDING / 2,
|
||||||
VNCGraphicsClient.BORDER_PADDING / 2);
|
VNCGraphicsClient.BORDER_PADDING / 2);
|
||||||
using (Pen pen = new Pen(focusColor, VNCGraphicsClient.BORDER_WIDTH))
|
using (Pen pen = new Pen(focusColor, VNCGraphicsClient.BORDER_WIDTH))
|
||||||
{
|
{
|
||||||
if (this.Focused)
|
if (Focused)
|
||||||
pen.DashStyle = DashStyle.Dash;
|
pen.DashStyle = DashStyle.Dash;
|
||||||
e.Graphics.DrawRectangle(pen, focusRect);
|
e.Graphics.DrawRectangle(pen, focusRect);
|
||||||
}
|
}
|
||||||
@ -1267,7 +1267,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
Program.AssertOnEventThread();
|
Program.AssertOnEventThread();
|
||||||
base.OnLostFocus(e);
|
base.OnLostFocus(e);
|
||||||
|
|
||||||
this.pressedKeys = new Set<Keys>();
|
pressedKeys = new Set<Keys>();
|
||||||
|
|
||||||
// reset tab stop
|
// reset tab stop
|
||||||
SetKeyboardAndMouseCapture(autoCaptureKeyboardAndMouse);
|
SetKeyboardAndMouseCapture(autoCaptureKeyboardAndMouse);
|
||||||
@ -1370,7 +1370,7 @@ namespace XenAdmin.ConsoleView
|
|||||||
|
|
||||||
if (KeyHandler.handleExtras<Keys>(pressed, pressedKeys, KeyHandler.ExtraKeys, extendedKey, KeyHandler.ModifierKeys, ref modifierKeyPressedAlone))
|
if (KeyHandler.handleExtras<Keys>(pressed, pressedKeys, KeyHandler.ExtraKeys, extendedKey, KeyHandler.ModifierKeys, ref modifierKeyPressedAlone))
|
||||||
{
|
{
|
||||||
this.Focus();
|
Focus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1394,15 +1394,15 @@ namespace XenAdmin.ConsoleView
|
|||||||
private Size oldSize;
|
private Size oldSize;
|
||||||
public void UpdateRDPResolution(bool fullscreen = false)
|
public void UpdateRDPResolution(bool fullscreen = false)
|
||||||
{
|
{
|
||||||
if (rdpClient == null || oldSize.Equals(this.Size))
|
if (rdpClient == null || oldSize.Equals(Size))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//no offsets in fullscreen mode because there is no need to accomodate focus border
|
//no offsets in fullscreen mode because there is no need to accomodate focus border
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
rdpClient.UpdateDisplay(this.Size.Width, this.Size.Height, new Point(0,0));
|
rdpClient.UpdateDisplay(Size.Width, Size.Height, new Point(0,0));
|
||||||
else
|
else
|
||||||
rdpClient.UpdateDisplay(this.Size.Width - CONSOLE_SIZE_OFFSET, this.Size.Height - CONSOLE_SIZE_OFFSET, new Point(3,3));
|
rdpClient.UpdateDisplay(Size.Width - CONSOLE_SIZE_OFFSET, Size.Height - CONSOLE_SIZE_OFFSET, new Point(3,3));
|
||||||
oldSize = new Size(this.Size.Width, this.Size.Height);
|
oldSize = new Size(Size.Width, Size.Height);
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user