private void RecordFile(object sender, MouseButtonEventArgs e)
 {
     this.Dispatcher.Invoke(() =>
     {
         if (!this.isRecord)
         {
             isRecord = true;
             foreach (UIElement uiE in this.UICCTVContent.Children)
             {
                 if (uiE is CameraCCTV)
                 {
                     CameraCCTV uiCamera = uiE as CameraCCTV;
                     uiCamera.RecordFile();
                 }
             }
             UIRecordBtn.Foreground = Brushes.Red;
         }
         else
         {
             foreach (UIElement uiE in this.UICCTVContent.Children)
             {
                 if (uiE is CameraCCTV)
                 {
                     CameraCCTV uiCamera = uiE as CameraCCTV;
                     uiCamera.StopRecord();
                 }
             }
             UIRecordBtn.Foreground = Brushes.White;
             isRecord = false;
         }
     });
 }
        private void TimeCheckFunctionThread()
        {
            while (true)
            {
                this.Dispatcher.Invoke(() =>
                {
                    this.UIUnLock.IsEnabled = false;
                    this.UILock.IsEnabled   = false;
                    try
                    {
                        bool isChange = false;
                        foreach (UIElement uiE in this.UIMapContent.Children)
                        {
                            if (uiE is UIMapAlarm)
                            {
                                UIMapAlarm uiAlarm = uiE as UIMapAlarm;
                                if (uiAlarm.Alarm != null && uiAlarm.Alarm.TimeOffs.Count > 0 && uiAlarm.Alarm.Auto)
                                {
                                    if (DateTime.Now.TimeOfDay >= uiAlarm.Alarm.TimeOffs[0].beginTime.TimeOfDay && DateTime.Now.TimeOfDay < uiAlarm.Alarm.TimeOffs[0].EndTime.TimeOfDay)
                                    {
                                        if (uiAlarm.Alarm.status)
                                        {
                                            uiAlarm.Disable();
                                        }
                                    }
                                    else if ((DateTime.Now.TimeOfDay < uiAlarm.Alarm.TimeOffs[0].beginTime.TimeOfDay || DateTime.Now.TimeOfDay > uiAlarm.Alarm.TimeOffs[0].EndTime.TimeOfDay))
                                    {
                                        if (!uiAlarm.Alarm.status)
                                        {
                                            uiAlarm.Enable();
                                        }
                                    }
                                }
                            }
                        }
                        if (isChange)
                        {
                            this.DrawMap();
                        }
                    }
                    catch (Exception)
                    {
                    }
                    this.UIUnLock.IsEnabled = true;
                    this.UILock.IsEnabled   = true;

                    if (App.curFolder != this.curFolder)
                    {
                        this.curFolder = App.curFolder;

                        if (this.isRecord)
                        {
                            foreach (UIElement uiE in this.UICCTVContent.Children)
                            {
                                if (uiE is CameraCCTV)
                                {
                                    CameraCCTV uiCamera = uiE as CameraCCTV;
                                    uiCamera.StopRecord();
                                }
                            }
                            Thread.Sleep(1500);
                            if (App.DataAlarm != null)
                            {
                                for (int i = 0; i < App.DataAlarm.Count; i++)
                                {
                                    App.DataAlarm[i].isDisable = false;
                                    App.DataAlarm[i].isEnable  = false;
                                }
                            }

                            foreach (UIElement uiE in this.UICCTVContent.Children)
                            {
                                if (uiE is CameraCCTV)
                                {
                                    CameraCCTV uiCamera = uiE as CameraCCTV;
                                    uiCamera.RecordFile();
                                }
                            }
                            UIRecordBtn.Foreground = Brushes.Red;
                        }
                    }
                });

                Thread.Sleep(2000);
            }
        }