To keep things simple, I decided to follow this approach. Server when launched and clicked on the Start button, captures desktop every sec and saves an image file. Client when launched and clicked on the View Desktop button, reads the image into a picturebox every 500 millisec.
But I've a problem displaying image in the Client form. It displays the initial image but not any other subsequent images, just stays still.
I've tried Refresh() and Invalidate() but nothing works. Can you guys help me solve this
Server Code
using System;
using System.Windows.Forms;
using System.IO;
using System.Timers;
namespace SMSServer
{
public partial class SMSServerForm : Form
{
private static System.Timers.Timer txtTimer;
private CaptureDesktop cd;
public SMSServerForm()
{
InitializeComponent();
}
private void btnStart_Click(object sender, EventArgs e)
{
cd = new CaptureDesktop();
txtTimer = new System.Timers.Timer(1000);
txtTimer.Elapsed += txtTimer_Elapsed;
txtTimer.Enabled = true;
}
private void txtTimer_Elapsed(object sender, ElapsedEventArgs e)
{
cd.CaptureDesktopAsImage();
}
}
}
Client Code
using System;
using System.Windows.Forms;
using System.IO;
using System.Timers;
using System.Drawing;
namespace SMSClient
{
public partial class SMSClientForm : Form
{
private static System.Timers.Timer txtReadTimer;
public SMSClientForm()
{
InitializeComponent();
}
private void txtReadTimer_Elapsed(object sender, ElapsedEventArgs e)
{
desktopPictureBox.Invalidate();
desktopPictureBox.Image = Image.FromFile(Directory.GetCurrentDirectory() + @"\CurrentImage.png");
}
private void btnView_Click(object sender, EventArgs e)
{
txtReadTimer = new System.Timers.Timer(500);
txtReadTimer.Elapsed += txtReadTimer_Elapsed;
txtReadTimer.Enabled = true;
}
}
}
To capture desktop, I've used the method described here: Capture desktop C# including semitransparent