protected override void OnLoad(EventArgs e)
 {
     video = new UserVideo();
     video.BorderStyle = BorderStyle.FixedSingle;
     video.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
     video.Alarm += new EventHandler<IVideo.AlarmEventArgs>(video_Alarm);
     video.Bounds = new Rectangle(12, 12, 160, 100);
     video.Initialize("计算机学院", "楼顶大镜头1");
     this.Controls.Add(video);
     video.LoginEncoder();
     video.OpenVideo();
 }
        private void tVAreaDevices_DoubleClick(object sender, EventArgs e)
        {
            TreeNode TN = tVAreaDevices.SelectedNode;
            if (TN == null) return;

            if (TN.Level == 1)
            {
                if (TN.Tag == null)
                {//新建
                    video = new UserVideo();
                    video.Initialize(TN.Parent.Text, TN.Text);
                    video.Alarm += new EventHandler<AlarmEventArgs>(video_AlarmCallback);
                    video.ReceiveHorizon += new EventHandler<IVideo.HorizonEventArgs>(video_HorizonCallback);
                    video.ReceiveVertical += new EventHandler<IVideo.VerticalEventArgs>(video_ReceiveVertical);

                    this.alarmsGroup.Add(video, null);
                    this.alarmsInfo.Add(video, new List<Bitmap>());
                    this.alarmsIndex.Add(video, 0);

                    if (video.LoginEncoder())//登陆
                    {
                        if (video.OpenVideo())//开启
                        {
                            int x = videos.Count % 2;
                            int y = videos.Count / 2;
                            video.SetBounds(x * 352, y * 288, 352, 288);
                            this.tPRealVideo.Controls.Add(video);

                            UCShowDecode control = new UCShowDecode();
                            control.SetBounds(x * 352, y * 288, 352, 288);
                            this.tPVideoDecode.Controls.Add(control);

                            this.video.DecodeShow = control;

                            TN.Tag = video;
                            videos.Add(video);
                        }
                        else
                        {
                            MessageBox.Show("打开视频失败");
                        }
                    }
                    else
                        MessageBox.Show("登陆编码器失败");
                }
                else
                {//开关
                    video = TN.Tag as UserVideo;

                    if (video.IsOpened)
                    {
                        video.CloseVideo();    //关

                        video.Invalidate();     //刷新
                    }
                    else
                        video.OpenVideo();     //开
                }
            }
            else if (TN.Level == 2)
            {
                if (TN.Tag == null || TN.Parent.Tag == null) return;
                GroupInfo alarmGroup = TN.Tag as GroupInfo;
                VideoBase video = TN.Parent.Tag as VideoBase;

                if (alarmGroup == null || video == null) return;

                this.alarmsGroup[video] = alarmGroup;
            }
        }
        private void tVAreaDevices_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode TN = tVAreaDevices.SelectedNode;
            if (TN == null || TN.Level != 1 || TN.Tag == null) return;

            this.video = TN.Tag as UserVideo;
        }
        private void tVAreaDevices_DoubleClick(object sender, EventArgs e)
        {
            TreeNode TNDevice = tVAreaDevices.SelectedNode;

            if (TNDevice == null || TNDevice.Level != 1 || TNDevice.Text.StartsWith("[不可用]")) return;

            if (TNDevice.Tag == null)
            {//初始化
                UserVideo video = new UserVideo();
                video.VideoOpened += new EventHandler(video_VideoOpened);
                if (video.Initialize(TNDevice.Parent.Text, TNDevice.Text)
                    && video.LoginEncoder() && video.OpenVideo())
                {
                    video.VideoClosed += new EventHandler(video_VideoClosed);
                    video.SelectedChanged += new EventHandler(video_SelectedChanged);
                    //video.IsExpandButton = true;
                    video.BorderStyle = BorderStyle.FixedSingle;
                    TNDevice.Tag = video;
                    Form f = new Form();
                    f.Text = video.AreaName + " - " + video.DeviceName;
                    f.ControlBox = false;
                    f.TopMost = true;
                    f.ClientSize = new Size(352, 288);
                    f.FormBorderStyle = FormBorderStyle.FixedSingle;
                    f.Show();
                    video.AnalyzeShow = f;

                    UserVideo.SelectDevice(video.AreaName, video.DeviceName, false);
                }
                else
                {
                    TNDevice.Text = "[不可用]" + TNDevice.Text;
                    video.Dispose();
                }
            }
            else
            {
                UserVideo video = TNDevice.Tag as UserVideo;

                if (video != null && video.IsLogined)
                {
                    if (video.IsOpened)
                    {
                        video.CloseVideo();
                        if (video.AnalyzeShow != null) video.AnalyzeShow.Hide();
                    }
                    else
                    {
                        video.OpenVideo();
                        if (video.AnalyzeShow != null) video.AnalyzeShow.Show();
                    }
                }
            }
        }
        private void tVAreaDevices_DoubleClick(object sender, EventArgs e)
        {
            TreeNode TNDevice = tVAreaDevices.SelectedNode;

            if (TNDevice == null || TNDevice.Level != 1 || TNDevice.Text.StartsWith("[不可用]")) return;

            if (TNDevice.Tag == null)
            {//初始化
                UserVideo video = new UserVideo();

                video.Initialize(TNDevice.Parent.Text, TNDevice.Text);

                if (video.LoginEncoder() && video.OpenVideo())
                {
                    video.BorderStyle = BorderStyle.FixedSingle;
                    video.MouseDown += new MouseEventHandler(video_MouseDown);
                    video.MouseMove += new MouseEventHandler(video_MouseMove);
                    video.MouseUp += new MouseEventHandler(video_MouseUp);
                    Size size = new Size((int)(this.Times * 352), (int)(this.Times * 288));
                    Point location = this.MapToClient(new Point(Convert.ToInt32(video.Longitude), Convert.ToInt32(video.Latitude)));
                    location.Offset((int)((352 - size.Width) / 2), (int)((288 - size.Height) / 2));
                    video.SetBounds(location.X, location.Y, size.Width, size.Height);
                    TNDevice.Tag = video;
                    this.Controls.Add(video);
                    videos.Add(video);
                }
                else
                    TNDevice.Text = "[不可用]" + TNDevice.Text;
            }
            else
            {
                VideoBase video = TNDevice.Tag as VideoBase;

                if (video != null && video.IsLogined)
                {
                    if (video.IsOpened) video.CloseVideo();
                    else video.OpenVideo();
                }
            }
        }