示例#1
0
        private void AddAlarmHistory(HitAlertInfo hitalert)
        {
            // 报警历史
            int iUCWidth     = 120;
            int iUCHeight    = (int)(4 * iUCWidth / 3);
            int iInterval    = 5;
            int iLabelHeight = 15;

            plAlarmHistory.Controls.Clear();
            InitialalarmHistory();

            if (_listAlertHistory == null || _listAlertHistory.Count <= 0)
            {
                UcImage ucSnapImg = new UcImage(hitalert.ImgData, null, null, null);
                ucSnapImg.SetControlWidth(iUCWidth);
                ucSnapImg.Location       = new Point(plAlarmHistory.Location.X, iLabelHeight + iInterval);
                ucSnapImg.SearchEvent   += UcSnapImg_SearchEvent;
                ucSnapImg.AddModelEvent += UcSnapImg_AddModelEvent;

                UcImage ucStandImg = new UcImage(hitalert.Detail[0].Face, hitalert.Detail[0].PersonId, hitalert.Detail[0].Score.ToString("N2"), hitalert.CreateTime.ToString("yy-MM-dd HH:mm:ss"));
                ucStandImg.SetControlWidth(iUCWidth);
                ucStandImg.pbImage.ContextMenuStrip = null;
                ucStandImg.Location = new Point(ucSnapImg.Right, iLabelHeight + iInterval);

                _listAlertHistory.Add(hitalert);
                plAlarmHistory.Controls.Add(ucSnapImg);
                plAlarmHistory.Controls.Add(ucStandImg);
            }
            else
            {
                int iListNum = _listAlertHistory.Count;
                if (iListNum >= _iAlertHistoryNum)
                {
                    _listAlertHistory.RemoveAt(_iAlertHistoryNum - 1);
                }
                _listAlertHistory.Insert(0, hitalert);
                // 循环临时报警信息集合
                for (int i = 0; i < _listAlertHistory.Count; i++)
                {
                    if (i > 0)
                    {
                        iInterval += iUCHeight + 2;
                    }
                    HitAlertInfo alarmHistory = _listAlertHistory[i];

                    UcImage ucHSnapImg = new UcImage(alarmHistory.ImgData, null, null, null);
                    ucHSnapImg.SetControlWidth(iUCWidth);
                    ucHSnapImg.Location       = new Point(plAlarmHistory.Location.X, iLabelHeight + iInterval);
                    ucHSnapImg.SearchEvent   += UcSnapImg_SearchEvent;
                    ucHSnapImg.AddModelEvent += UcSnapImg_AddModelEvent;
                    UcImage ucStandImg = new UcImage(alarmHistory.Detail[0].Face, alarmHistory.Detail[0].PersonId, alarmHistory.Detail[0].Score.ToString("N2"), alarmHistory.CreateTime.ToString("yy-MM-dd HH:mm:ss"));
                    ucStandImg.SetControlWidth(iUCWidth);
                    ucStandImg.pbImage.ContextMenuStrip = null;
                    ucStandImg.Location = new Point(ucHSnapImg.Right, iLabelHeight + iInterval);

                    plAlarmHistory.Controls.Add(ucHSnapImg);
                    plAlarmHistory.Controls.Add(ucStandImg);
                }
            }
        }
示例#2
0
        private void NoticeAlarmEvent(HitAlertInfo hitalert)
        {
            if (hitalert == null)
            {
                return;
            }

            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
            //双缓冲绘制,避免闪烁
            this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);

            // 报警播报
            var player = new SoundPlayer(Properties.Resources.Beep);

            player.Play();

            this.Invoke((MethodInvoker) delegate
            {
                AddAlarmHistory(hitalert);

                Application.DoEvents();
            });
        }