/// <summary>Gets the UI ready for receiving image data from the server and asks for the first update.</summary> /// <param name="connectionInfo">Information about the connection.</param> private void StartFrameBuffer(ConnectionInfo connectionInfo) { var frameWidth = connectionInfo.Width; var frameHeight = connectionInfo.Height; if (this.frameBufferBitmap == null || this.frameBufferBitmap.PixelWidth != frameWidth || this.frameBufferBitmap.PixelHeight != frameHeight) { this.frameBufferBitmap = new WriteableBitmap(frameWidth, frameHeight); } if (this.zoomBufferBitmap == null) { this.zoomBufferBitmap = new WriteableBitmap(50, 50); } this.FrameBuffer.Source = this.frameBufferBitmap; this.ZoomBrush.ImageSource = this.zoomBufferBitmap; this.connection.StartAsync(); this.connection.UpdateAsync(true); var timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(250); timer.Tick += (s, e) => this.OnTimer(); timer.Start(); this.updateTimer = timer; }
/// <summary>Initialize the frame buffer with the reported width and /// height from the server.</summary> /// <param name="info">The connection info.</param> private void StartFramebuffer(ConnectionInfo info) { this.DoInvoke( () => { this.ShowStatus = Visibility.Collapsed; this.FrameWidth = Math.Max(info.Width, 320); this.FrameHeight = Math.Max(info.Height, 240); this.Framebuffer = new WriteableBitmap( this.FrameWidth, this.FrameHeight, 96, 96, PixelFormats.Bgr32, null); this.connectionPort.StartAsync(); this.connectionPort.UpdateAsync(true); this.Title = info.Name + " - Old Man of the VNC"; this.timer = new DispatcherTimer( TimeSpan.FromSeconds(1.0 / 4), DispatcherPriority.Background, OnTimer, Dispatcher); this.timer.Start(); }); }