private void BuildTaskList(uint count)
 {
     if (InvokeRequired)
     {
         this.Invoke(new Action <uint>(BuildTaskList), count);
     }
     else
     {
         MyLog4Net.Container.Instance.Log.Debug("BuildTaskList RealtimeTask count:" + count);
         if (flowLayoutPanel1.Controls.Count == count)
         {
             return;
         }
         while (flowLayoutPanel1.Controls.Count != count)
         {
             if (flowLayoutPanel1.Controls.Count > count)
             {
                 flowLayoutPanel1.Controls.RemoveAt(flowLayoutPanel1.Controls.Count - 1);
             }
             else if (flowLayoutPanel1.Controls.Count < count)
             {
                 ucSingleRealtimeTask uctask = new ucSingleRealtimeTask();
                 uctask.Size              = new System.Drawing.Size(flowLayoutPanel1.Width - 30, SingleHistoryTaskHeight);
                 uctask.Name              = "ucSingleRealtimeTask_" + flowLayoutPanel1.Controls.Count;
                 uctask.Click            += uctask_Click;
                 uctask.TaskPlay         += uctask_TaskPlay;
                 uctask.TaskDeleteClick  += uctask_TaskDeleteClick;
                 uctask.PauseResumeClick += uctask_PauseResumeClick;
                 uctask.TaskDoAction     += uctask_TaskDoAction;
                 uctask.Visible           = false;
                 this.flowLayoutPanel1.Controls.Add(uctask);
             }
         }
     }
 }
        void uctask_Click(object sender, EventArgs e)
        {
            ucSingleRealtimeTask uctask = sender as ucSingleRealtimeTask;

            m_currentTask = uctask;
            ShowSingleTask();
        }
        void uctask_PauseResumeClick(object sender, EventArgs e)
        {
            ucSingleRealtimeTask uctask = sender as ucSingleRealtimeTask;

            if (uctask != null)
            {
                m_viewModel.PauseOrResumeTask(uctask.Task.TaskId);
            }
        }
        void uctask_TaskPlay(object sender, EventArgs e)
        {
            ucSingleRealtimeTask uctask = sender as ucSingleRealtimeTask;

            m_currentTask = uctask;

            FormPlayRealtime f = new FormPlayRealtime(m_currentTask.Task);

            f.ShowDialog();
        }
        void uctask_TaskDeleteClick(object sender, EventArgs e)
        {
            ucSingleRealtimeTask uctask = sender as ucSingleRealtimeTask;

            if (uctask != null)
            {
                m_viewModel.DeleteTask(uctask.Task.TaskId);
                uctask.Init(new TaskInfoV3_1()
                {
                    TaskId = 0, AlgthmType = E_VIDEO_ANALYZE_TYPE.E_ANALYZE_NOUSE, StartTime = new DateTime(), TaskName = "加载中...", Status = E_VDA_TASK_STATUS.E_TASK_STATUS_NOUSE
                }, E_VDA_TASK_STATUS.E_TASK_STATUS_NOUSE, 0);
            }
        }
        void uctask_TaskDoAction(ucSingleRealtimeTask arg1, E_TASK_ACTION_TYPE arg2)
        {
            var cam = m_viewModel.GetCameraInfo(arg1.Task.CameraID);

            switch (arg2)
            {
            case E_TASK_ACTION_TYPE.E_TASK_ACTION_TYPE_NONE:
                break;

            case E_TASK_ACTION_TYPE.E_TASK_ACTION_TYPE_PEOPLE_SEARCH:
                WinFormAppUtil.AppContainer.Instance.EvtAggregator.GetEvent <NavigateEvent>().Publish(new Tuple <SystemMenu, object>(new SystemMenu {
                    URL = "FormPeopleSearch", Title = "行人检索", Discription = "行人检索"
                }, cam));
                break;

            case E_TASK_ACTION_TYPE.E_TASK_ACTION_TYPE_VEHICLE_SEARCH:
                WinFormAppUtil.AppContainer.Instance.EvtAggregator.GetEvent <NavigateEvent>().Publish(new Tuple <SystemMenu, object>(new SystemMenu {
                    URL = "FormVehicleSearch", Title = "车辆检索", Discription = "车辆检索"
                }, cam));
                break;

            case E_TASK_ACTION_TYPE.E_TASK_ACTION_TYPE_CROWD:
                WinFormAppUtil.AppContainer.Instance.EvtAggregator.GetEvent <NavigateEvent>().Publish(new Tuple <SystemMenu, object>(new SystemMenu {
                    URL = "FormCrowdReatime", Title = "实时大客流", Discription = "实时大客流"
                }, arg1.Task));
                break;

            case E_TASK_ACTION_TYPE.E_TASK_ACTION_TYPE_BRIEF:
                FormPlayBriefNew f = new FormPlayBriefNew(arg1.Task);
                f.ShowDialog();
                break;

            case E_TASK_ACTION_TYPE.E_TASK_ACTION_TYPE_TRAFFIC_EVENT:
                WinFormAppUtil.AppContainer.Instance.EvtAggregator.GetEvent <NavigateEvent>().Publish(new Tuple <SystemMenu, object>(new SystemMenu {
                    URL = "FormTrafficEventAlarm", Title = "交通事件", Discription = "交通事件"
                }, arg1.Task));
                break;

            case E_TASK_ACTION_TYPE.E_TASK_ACTION_TYPE_TRAFFIC_EVENT_SEARCH:
                break;

            default:
                break;
            }
        }
        void m_viewModel_UpdateTaskProgress(int index, uint arg1, IVX.DataModel.E_VDA_TASK_STATUS arg2, uint arg3)
        {
            if (isClosed)
            {
                return;
            }

            if (InvokeRequired)
            {
                this.Invoke(new Action <int, uint, IVX.DataModel.E_VDA_TASK_STATUS, uint>(m_viewModel_UpdateTaskProgress), index, arg1, arg2, arg3);
            }
            else
            {
                ucSingleRealtimeTask taskinfo = null;
                try
                {
                    if (flowLayoutPanel1.Controls.ContainsKey("ucSingleRealtimeTask_" + index))
                    {
                        taskinfo = flowLayoutPanel1.Controls["ucSingleRealtimeTask_" + index] as ucSingleRealtimeTask;
                    }
                    if (taskinfo != null)
                    {
                        if (arg1 == 0)
                        {
                            taskinfo.Init(null, arg2, (int)arg3);
                        }
                        else
                        {
                            taskinfo.Init(m_viewModel.GetTaskInfo(arg1), arg2, (int)arg3);
                        }
                        if (m_currentShownTask != null && m_currentShownTask.Created && m_currentShownTask.TaskId == arg1)
                        {
                            m_currentShownTask.UpdateProgress(arg2, (int)arg3);
                        }
                    }
                }
                catch (Exception)
                {
                    return;
                }
            }
        }