private void BuildTaskList(uint count)
 {
     if (InvokeRequired)
     {
         this.Invoke(new Action <uint>(BuildTaskList), count);
     }
     else
     {
         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)
             {
                 ucSingleHistoryTask uctask = new ucSingleHistoryTask();
                 uctask.Size             = new System.Drawing.Size(flowLayoutPanel1.Width - 30, SingleHistoryTaskHeight);
                 uctask.Name             = "ucSingleHistoryTask_" + flowLayoutPanel1.Controls.Count;
                 uctask.Click           += uctask_Click;
                 uctask.TaskPlay        += uctask_TaskPlay;
                 uctask.ReImport        += uctask_ReImport;
                 uctask.TaskDeleteClick += uctask_TaskDeleteClick;
                 uctask.TaskDoAction    += uctask_TaskDoAction;
                 uctask.Visible          = false;
                 this.flowLayoutPanel1.Controls.Add(uctask);
             }
         }
     }
 }
        void uctask_Click(object sender, EventArgs e)
        {
            ucSingleHistoryTask uctask = sender as ucSingleHistoryTask;

            m_currentTask = uctask;

            ShowSingleTask();
        }
        void uctask_ReImport(object sender, EventArgs e)
        {
            ucSingleHistoryTask uctask = sender as ucSingleHistoryTask;

            //m_currentTask = uctask;

            m_viewModel.ReImport(uctask.Task);
        }
        void uctask_TaskPlay(object sender, EventArgs e)
        {
            ucSingleHistoryTask uctask = sender as ucSingleHistoryTask;
            //m_currentTask = uctask;

            FormPlayHistoryNew f = new FormPlayHistoryNew(uctask.Task);

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

            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(ucSingleHistoryTask arg1, E_TASK_ACTION_TYPE arg2)
        {
            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 = "行人检索"
                }, arg1.Task));
                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 = "车辆检索"
                }, arg1.Task));
                break;

            case E_TASK_ACTION_TYPE.E_TASK_ACTION_TYPE_CROWD:
                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:
                break;

            case E_TASK_ACTION_TYPE.E_TASK_ACTION_TYPE_TRAFFIC_EVENT_SEARCH:
                break;

            case E_TASK_ACTION_TYPE.E_TASK_ACTION_TYPE_DYNMIC_VEHICLE_SEARCH:
                WinFormAppUtil.AppContainer.Instance.EvtAggregator.GetEvent <NavigateEvent>().Publish(new Tuple <SystemMenu, object>(new SystemMenu {
                    URL = "FormVehicleSearch", Title = "车辆检索", Discription = "车辆检索"
                }, arg1.Task));
                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
            {
                ucSingleHistoryTask taskinfo = null;
                try
                {
                    if (flowLayoutPanel1.Controls.ContainsKey("ucSingleHistoryTask_" + index))
                    {
                        taskinfo = flowLayoutPanel1.Controls["ucSingleHistoryTask_" + index] as ucSingleHistoryTask;
                    }
                    if (taskinfo != null)
                    {
                        TaskInfoV3_1 ti = (arg1 == 0)?null:m_viewModel.GetTaskInfo(arg1);
                        taskinfo.Init(ti, arg2, (int)arg3);
                        if (m_currentShownTask != null && m_currentShownTask.Created && m_currentShownTask.TaskId == arg1)
                        {
                            m_currentShownTask.UpdateProgress(arg2, (int)arg3, ti.Order, ti.LeftTime);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MyLog4Net.Container.Instance.Log.Error("m_viewModel_UpdateTaskProgress" + ex);

                    return;
                }
            }
        }