www.pudn.com > sharewindows.rar > Form1.cs, change:2015-12-11,size:2813b


´╗┐using NBLH_LINK; 
using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.IO; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
 
namespace Client 
{ 
    public partial class Form1 : Form 
    { 
        //Nblh_Link_Client client = new Nblh_Link_Client(); 
        Nblh_Link_Control_Client client = new Nblh_Link_Control_Client(); 
         
        public Form1() 
        { 
            InitializeComponent(); 
 
            client.BitmapBytesEvent += client_BitmapBytesEvent; 
            client.BitmapSizeEvent += client_BitmapSizeEvent; 
            client.MessageEvent += client_MessageEvent; 
 
            Init(); 
        } 
        void Init() 
        { 
            m_size = label1.Size; 
        } 
        Bitmap m_bitMap = null; 
        Size m_size; 
        void client_MessageEvent(object sender, NBLH_LINK.Args.Nblh_Link_Args_Message message) 
        { 
            this.BeginInvoke(new Action(delegate 
            { 
                if (listBox1.Items.Count > 50) 
                { 
                    for (int pos = listBox1.Items.Count - 1; pos >= 0; pos--) 
                    { 
                        listBox1.Items.RemoveAt(pos); 
                    } 
                } 
 
                this.listBox1.Items.Add(message.Message); 
            })); 
        } 
        ~Form1() 
        { 
            client.BitmapBytesEvent -= client_BitmapBytesEvent; 
            client.BitmapSizeEvent -= client_BitmapSizeEvent; 
        } 
 
        private void button1_Click(object sender, EventArgs e) 
        { 
            //client.Func_Start("127.0.0.1", 9001); 
            //client.Func_Start("192.168.1.30", 9001); 
            client.Func_Start(this.textBox1.Text, 9001); 
        } 
 
        void client_BitmapSizeEvent(object sender, NBLH_LINK.Args.Nblh_Args_BitmapSize args) 
        { 
            //throw new NotImplementedException(); 
        } 
 
        void client_BitmapBytesEvent(object sender, NBLH_LINK.Args.Nblh_Args_BitmapBytes args) 
        { 
            MemoryStream ms = new MemoryStream(args.Bytes, args.Index, args.Length); 
            m_bitMap = (Bitmap)Image.FromStream(ms); 
            this.BeginInvoke(new Action(delegate 
            { 
                Point p = new Point(base.AutoScrollPosition.X, base.AutoScrollPosition.Y); 
 
                this.label1.CreateGraphics().DrawImage(this.m_bitMap, p.X, p.Y, this.label1.Width, this.label1.Height); 
            })); 
        } 
 
        private void button2_Click(object sender, EventArgs e) 
        { 
            client.Func_Stop(); 
        } 
 
        private void label1_Click(object sender, EventArgs e) 
        { 
 
        } 
 
         
    } 
}