예제 #1
0
        void mi_Click(object sender, EventArgs e)
        {
            Cell c = this.squareListView1.SelectedCell;

            if (c == null)
            {
                return;
            }

            ToolStripMenuItem menuItem = sender as ToolStripMenuItem;

            Camera cam = menuItem.Tag as Camera;



            TcpClient tcp = new TcpClient();

            System.Net.IPAddress  ip = System.Net.IPAddress.Parse(cam.IpAddress);
            System.Net.IPEndPoint ep = new System.Net.IPEndPoint(ip, 20000);
            try
            {
                ConnectInfo info = new ConnectInfo()
                {
                    Socket = tcp, Target = c, Source = cam
                };

                LiveClient lc = new LiveClient(tcp);
                lc.Tag = info;

                tcp.BeginConnect(ip, 20000, this.ConnectCallback, lc);
            }
            catch (System.Net.Sockets.SocketException)
            {
                MessageBox.Show(this, "无法连接, 请检查设备", "连接错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
예제 #2
0
        private void ConnectCallback(IAsyncResult ar)
        {
            LiveClient  lc   = ar.AsyncState as LiveClient;
            ConnectInfo info = lc.Tag as ConnectInfo;

            try
            {
                info.Socket.EndConnect(ar);
            }
            catch (System.Net.Sockets.SocketException)
            {
                string msg = string.Format("无法连接 {0}, 请检查设备", info.Source.Config.Name);

                Action showMsg = () => MessageBox.Show(this, msg, "连接错误", MessageBoxButtons.OK, MessageBoxIcon.Error);

                this.BeginInvoke(showMsg);

                return;
            }

            if (CellCameraMap.ContainsKey(info.Target))
            {
                CellCameraMap[info.Target].ImageReceived -= this.lc_ImageReceived;

                CellCameraMap[info.Target].Stop();

                CellCameraMap.Remove(info.Target);
            }


            lc.ImageReceived  += new EventHandler <ImageCapturedEventArgs>(lc_ImageReceived);
            lc.ConnectAborted += new EventHandler(lc_ConnectAborted);
            lc.Start();

            CellCameraMap.Add(info.Target, lc);
        }
예제 #3
0
        void mi_Click(object sender, EventArgs e)
        {
            Cell c = this.squareListView1.SelectedCell;

            if (c == null) return;

            ToolStripMenuItem menuItem = sender as ToolStripMenuItem;

            Camera cam = menuItem.Tag as Camera;

            TcpClient tcp = new TcpClient();
            System.Net.IPAddress ip = System.Net.IPAddress.Parse(cam.IpAddress);
            System.Net.IPEndPoint ep = new System.Net.IPEndPoint(ip, 20000);
            try
            {
                ConnectInfo info = new ConnectInfo() { Socket = tcp, Target = c, Source = cam };

                LiveClient lc = new LiveClient(tcp);
                lc.Tag = info;

                tcp.BeginConnect(ip, 20000, this.ConnectCallback, lc);

            }
            catch (System.Net.Sockets.SocketException)
            {
                MessageBox.Show(this, "无法连接, 请检查设备", "连接错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
예제 #4
0
 private static void UpdateCellProperty(Damany.RemoteImaging.Common.Frame frame, ConnectInfo connect)
 {
     connect.Target.Image = frame.image;
     connect.Target.OverlayText = connect.Source.Config.Name + " " + frame.timeStamp.ToString();
     connect.Target.EnableOverlayText = true;
 }
예제 #5
0
 private static void UpdateCellProperty(Damany.RemoteImaging.Common.Frame frame, ConnectInfo connect)
 {
     connect.Target.Image             = frame.image;
     connect.Target.OverlayText       = connect.Source.Config.Name + " " + frame.timeStamp.ToString();
     connect.Target.EnableOverlayText = true;
 }