Передача данных от задачи, запущенной на сервере, клиенту

Я хочу сделать скриншот с сервера и отправить их клиенту

interface IServer

namespace Server
{
    [ServiceContract]
    public interface IServer
    {
        [OperationContract]
        Bitmap GetScreenshot();
    }
}

Class Server

 namespace Server
    {
        public class Server: IServer
        {
            public Bitmap GetScreenshot()
            {
                Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                    Screen.PrimaryScreen.Bounds.Height,
                    PixelFormat.Format32bppArgb);
                Graphics graphics = Graphics.FromImage(bitmap);
                graphics.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size);
    
                return bitmap;
            }
        }
    }
       

в Клиенте на кнопке

private void buttonScreenshot_Click(object sender, EventArgs e)
{
    Screenshot screenshot = new Screenshot(client.GetScreenshot());
    screenshot.Show();

}

скриншот экрана, отображается в отдельной форме

namespace Client
{
    public partial class Screenshot : Form
    {
        public Screenshot()
        {
            InitializeComponent();
        }
        public Screenshot(Bitmap bitmap)
        {
            InitializeComponent();
            WindowState = FormWindowState.Maximized;
            pictureBoxScreenshot.Image = bitmap;
        }
        private void Screenshot_Load(object sender, EventArgs e)
        {
            FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            Left = Top = 0;
            Width = Screen.PrimaryScreen.WorkingArea.Width;
            Height = Screen.PrimaryScreen.WorkingArea.Height;
        }
    }
}

введите сюда описание изображения

Как правильно реализовать без ошибок


Ответы (0 шт):