基本信息
源码名称:C# 屏幕广播/屏幕截图实例源码(含服务端客户端)
源码大小:0.04M
文件格式:.zip
开发语言:C#
更新时间:2017-10-12
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.IO;

namespace screen_cast
{
    public partial class MainFrame : Form
    {
        private ScreenCapture _ObjCapture = new ScreenCapture();
        private UdpHelper _ObjUdp = new UdpHelper("255.255.255.255",12345);
        private Boolean _bRunning = false;

        public MainFrame()
        {
            InitializeComponent();

            this.text_fps.Text = "20";
            this.text_quality.Text = "80";
            this._ObjCapture.OnScreenDataEventHandler  = new EventHandler<ScreenCaptureEventArgs>(this.OnScreenData);
            this.picture_screen.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
        }

        private void btn_start_Click(object sender, EventArgs e)
        {
            if (this._bRunning == false)
            {
                int Fps = int.Parse(this.text_fps.Text);
                int Quality = int.Parse(this.text_quality.Text);

                this._ObjCapture.UpdateQuality(Quality);
                this._ObjCapture.StartCapture(1000L / Fps);

                this._bRunning = true;
                this.btn_start.Text = "Stop";
            }
            else
            {
                this._ObjCapture.StopCapture();

                this._bRunning = false;
                this.btn_start.Text = "Start";
            }

        }

        private void OnScreenData(Object obj,ScreenCaptureEventArgs evt)
        {
            try
            {
                MemoryStream imgStream = new MemoryStream(evt.data, 0, evt.data.Length);
                Bitmap map = (Bitmap)Image.FromStream(imgStream);
                if (map != null)
                    this.picture_screen.BackgroundImage = map;

                _ObjUdp.Send(evt.data);
            }
            catch
            {

            }
        }
    }
}