mirror of https://github.com/quasar/Quasar.git
Minor fixes
This commit is contained in:
parent
889f16a60e
commit
5ead60e571
|
@ -126,24 +126,22 @@ public void UpdateImage(Bitmap bmp, bool cloneBitmap = false)
|
||||||
|
|
||||||
lock (_imageLock)
|
lock (_imageLock)
|
||||||
{
|
{
|
||||||
if (GetImageSafe != null)
|
// get old image to dispose it correctly
|
||||||
{
|
var oldImage = GetImageSafe;
|
||||||
GetImageSafe.Dispose();
|
|
||||||
GetImageSafe = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
SuspendLayout();
|
||||||
GetImageSafe = cloneBitmap ? new Bitmap(bmp, Width, Height) /*resize bitmap*/ : bmp;
|
GetImageSafe = cloneBitmap ? new Bitmap(bmp, Width, Height) /*resize bitmap*/ : bmp;
|
||||||
|
ResumeLayout();
|
||||||
|
|
||||||
|
if (oldImage != null)
|
||||||
|
oldImage.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException)
|
catch (InvalidOperationException)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
MessageBox.Show(
|
|
||||||
string.Format(
|
|
||||||
"An unexpected error occurred: {0}\n\nPlease report this as fast as possible here:\\https://github.com/MaxXor/xRAT/issues",
|
|
||||||
ex.Message), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,37 +63,20 @@ public void ProcessScreens(object state)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_connectClient.Value.StreamCodec == null)
|
if (_connectClient.Value.StreamCodec == null)
|
||||||
{
|
|
||||||
_connectClient.Value.StreamCodec = new UnsafeStreamCodec(packet.Quality, packet.Monitor, packet.Resolution);
|
_connectClient.Value.StreamCodec = new UnsafeStreamCodec(packet.Quality, packet.Monitor, packet.Resolution);
|
||||||
}
|
|
||||||
else if (_connectClient.Value.StreamCodec.ImageQuality != packet.Quality || _connectClient.Value.StreamCodec.Monitor != packet.Monitor)
|
if (_connectClient.Value.StreamCodec.ImageQuality != packet.Quality || _connectClient.Value.StreamCodec.Monitor != packet.Monitor
|
||||||
{
|
|| _connectClient.Value.StreamCodec.Resolution != packet.Resolution)
|
||||||
if (string.Compare(_connectClient.Value.StreamCodec.Resolution, packet.Resolution, StringComparison.InvariantCultureIgnoreCase) != 0)
|
|
||||||
{
|
{
|
||||||
|
if (_connectClient.Value.StreamCodec != null)
|
||||||
_connectClient.Value.StreamCodec.Dispose();
|
_connectClient.Value.StreamCodec.Dispose();
|
||||||
}
|
|
||||||
|
|
||||||
_connectClient.Value.StreamCodec = new UnsafeStreamCodec(packet.Quality, packet.Monitor, packet.Resolution);
|
_connectClient.Value.StreamCodec = new UnsafeStreamCodec(packet.Quality, packet.Monitor, packet.Resolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (MemoryStream ms = new MemoryStream(packet.Image))
|
using (MemoryStream ms = new MemoryStream(packet.Image))
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
// update the new image from the packet data
|
|
||||||
picDesktop.UpdateImage(_connectClient.Value.StreamCodec.DecodeData(ms), true);
|
picDesktop.UpdateImage(_connectClient.Value.StreamCodec.DecodeData(ms), true);
|
||||||
|
|
||||||
this.Invoke((MethodInvoker)delegate
|
|
||||||
{
|
|
||||||
if (picDesktop != null && !picDesktop.IsDisposed)
|
|
||||||
{
|
|
||||||
picDesktop.Invalidate();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.Image = null;
|
packet.Image = null;
|
||||||
|
@ -114,23 +97,21 @@ public void AddMonitors(int monitors)
|
||||||
catch (InvalidOperationException)
|
catch (InvalidOperationException)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(
|
|
||||||
string.Format(
|
|
||||||
"An unexpected error occurred: {0}\n\nPlease report this as fast as possible here:\\https://github.com/MaxXor/xRAT/issues",
|
|
||||||
ex.Message), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update on frame change.
|
|
||||||
private void _frameCounter_FrameUpdated(FrameUpdatedEventArgs e)
|
private void _frameCounter_FrameUpdated(FrameUpdatedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
this.Invoke((MethodInvoker)delegate
|
this.Invoke((MethodInvoker)delegate
|
||||||
{
|
{
|
||||||
this.Text = string.Format("{0} - FPS: {1}", WindowHelper.GetWindowTitle("Remote Desktop", _connectClient), e.CurrentFramesPerSecond.ToString("0.00"));
|
this.Text = string.Format("{0} - FPS: {1}", WindowHelper.GetWindowTitle("Remote Desktop", _connectClient), e.CurrentFramesPerSecond.ToString("0.00"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ToggleControls(bool t)
|
private void ToggleControls(bool t)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue