// This event handler deals with Frambebuffer Updates coming from the host. An // EncodedRectangle object is passed via the VncEventArgs (actually an IDesktopUpdater // object so that *only* Draw() can be called here--Decode() is done elsewhere). // The VncClient object handles thread marshalling onto the UI thread. protected void VncUpdate(object sender, VncEventArgs e) { e.DesktopUpdater.Draw(desktop); Invalidate(desktopPolicy.AdjustUpdateRectangle(e.DesktopUpdater.UpdateRectangle)); if (state == RuntimeState.Connected) { vnc.RequestScreenUpdate(fullScreenRefresh); // Make sure the next screen update is incremental fullScreenRefresh = false; } }
// This event handler deals with Frambebuffer Updates coming from the host. An // EncodedRectangle object is passed via the VncEventArgs (actually an IDesktopUpdater // object so that *only* Draw() can be called here--Decode() is done elsewhere). // The VncClient object handles thread marshalling onto the UI thread. protected void VncUpdate(object sender, VncEventArgs e) { _dispatcher.BeginInvoke(new Action(() => { //e.DesktopUpdater.Draw(desktopBM); //iRDF.Source = desktopBM.ToBitmapSource(); e.DesktopUpdater.Draw(desktopWBM); if (state == RuntimeState.Connected) { vnc.RequestScreenUpdate(fullScreenRefresh); // Make sure the next screen update is incremental fullScreenRefresh = false; } })); }
// This event handler deals with Frambebuffer Updates coming from the host. An // EncodedRectangle object is passed via the VncEventArgs (actually an IDesktopUpdater // object so that *only* Draw() can be called here--Decode() is done elsewhere). // The VncClient object handles thread marshalling onto the UI thread. protected void VncUpdate(object sender, VncEventArgs e) { e.DesktopUpdater.Draw(desktop); // Before Invalidating the control, specify the rectangle that needs to be // re-painted. This speeds OnPaint dramatically, since the rest of the // screen doesn't need to change. Also, adjust the invalidated rectangle // to accomodate scrolling or centering, since the desktop will either be // clipped or centered on the screen. int x, y; if (ClientSize.Width > desktop.Size.Width) { int dx = (ClientRectangle.Width - desktop.Width) / 2; x = e.DesktopUpdater.UpdateRectangle.X + dx; } else { x = e.DesktopUpdater.UpdateRectangle.X + AutoScrollPosition.X; } if (ClientSize.Height > desktop.Size.Height) { int dy = (ClientRectangle.Height - desktop.Height) / 2; y = e.DesktopUpdater.UpdateRectangle.Y + dy; } else { y = e.DesktopUpdater.UpdateRectangle.Y + AutoScrollPosition.Y; } Rectangle adjusted = new Rectangle(x, y, e.DesktopUpdater.UpdateRectangle.Width, e.DesktopUpdater.UpdateRectangle.Height); Invalidate(adjusted); if (state == RuntimeState.Connected) { vnc.RequestScreenUpdate(fullScreenRefresh); // Make sure the next screen update is incremental fullScreenRefresh = false; } }