Beispiel #1
0
        void IVXProtocol_SearchItemImageReceived(SearchImageInfo obj)
        {
            bool matched = false;

            lock (m_MRERequestImage)
            {
                if (m_SyncRequsestImageRecord != null)
                {
                    if (m_SyncRequsestImageRecord.Item2)
                    {
                        if (string.Compare(m_SyncRequsestImageRecord.Item1.OrgPicPath, obj.ImageURL, true) == 0)
                        {
                            m_SyncRequsestImageRecord.Item1.OriginalPic = obj.Image;
                            matched = true;
                            m_MRERequestImage.Set();
                        }
                    }
                    else
                    {
                        if (string.Compare(m_SyncRequsestImageRecord.Item1.ThumbPicPath, obj.ImageURL, true) == 0)
                        {
                            matched = true;
                            m_SyncRequsestImageRecord.Item1.ThumbNailPic = obj.Image;
                            m_MRERequestImage.Set();
                        }
                    }
                }
            }

            if (!matched)
            {
                Framework.Container.Instance.EvtAggregator.GetEvent <SearchItemImageReceivedEvent>().Publish(obj);
            }
        }
        //void OnSearchBegin(SearchSession session)
        //{
        //    m_searchSessionID = session.SearchId;
        //    //m_currSearchItem = summary.SearchPara.CurrentSearchItem;
        //}

        void OnSearchItemImageReceived(SearchImageInfo info)
        {
            string key = GetRecordKey(info.dwCameraID, info.dwTaskUnitID, info.dwMoveObjID);

            if (m_DTKey2Record.ContainsKey(key))
            {
                SearchResultRecord record = m_DTKey2Record[key];
                if (string.Compare(record.ThumbPicPath, info.ImageURL, true) == 0)
                {
                    MyLog4Net.Container.Instance.Log.DebugFormat("### OnSearchItemImageReceived, taskunitname: {0}, taskUnitID: {1}", Title, m_currSearchItem.TaskUnitId);
                    if (record.ThumbNailPic == null)
                    {
                        record.ThumbNailPic = info.Image;

                        DataRow dataRow = this.m_ResultSummary.AllSearchResultList.Rows.Find(info.dwMoveObjID);

                        if (dataRow != null)
                        {
                            dataRow["ThumbNailPic"] = info.Image;
                        }

                        if (ThumbNailImageRetrieved != null)
                        {
                            ThumbNailImageRetrieved(record);
                        }
                    }
                }
                else
                {
                    int result = string.Compare(record.OrgPicPath, info.ImageURL, true);
                    // Debug.Assert(result == 0);
                    if (result == 0)
                    {
                        if (record.OriginalPic == null)
                        {
                            record.OriginalPic = info.Image;

                            Framework.Container.Instance.CacheMgr.Register(record);

                            if (OriginalImageRetrieved != null)
                            {
                                if (record.ObjectRect != Rectangle.Empty)
                                {
                                    // 先提取目标图
                                    Image    img = new Bitmap(record.ObjectRect.Width, record.ObjectRect.Height);
                                    Graphics g   = Graphics.FromImage(img);
                                    g.DrawImage(record.OriginalPic, new Rectangle(0, 0, record.ObjectRect.Width, record.ObjectRect.Height), record.ObjectRect, GraphicsUnit.Pixel);
                                    record.ObjectPic = img;
                                    g.Dispose();
                                    // 再在原图上画目标框
                                    g = Graphics.FromImage(record.OriginalPic);
                                    g.DrawRectangle(new Pen(new SolidBrush(Color.Red), 2), record.ObjectRect);
                                    g.Dispose();
                                }
                                OriginalImageRetrieved(record);
                            }
                        }
                    }
                }
            }
            //if (ImageDownloaded != null)
            //{
            //    ImageDownloaded(m_searchSessionID, info.dwCameraID, info.dwTaskUnitID, (int)info.dwMoveObjID, info.ptImageData);
            //}
        }