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; } }); }
public void autoRecord() { this.Dispatcher.Invoke(() => { isRecord = true; foreach (UIElement uiE in this.UICCTVContent.Children) { if (uiE is CameraCCTV) { CameraCCTV uiCamera = uiE as CameraCCTV; uiCamera.RecordFile(); } } UIRecordBtn.Foreground = Brushes.Red; }); }
private void LoadCCTVLayout() { isLoadCCTV = true; this.Dispatcher.Invoke(() => { this.UICCTVContent.Children.Clear(); if (App.DataCamera.Count > 0) { if (App.DataCamera.Count == 1) { CameraCCTV View = new CameraCCTV(); View.Height = this.UICCTVContent.Height; View.Width = 1366; View.Camera = App.DataCamera[0]; View.Postion = 0; View.setTop(0); View.setLeft(0); this.UICCTVContent.Children.Add(View); } else if (App.DataCamera.Count < 5) { for (int i = 0; i < App.DataCamera.Count; i++) { CameraCCTV View = new CameraCCTV(); View.Height = this.UICCTVContent.Height / 2; View.Width = 683; View.Camera = App.DataCamera[i]; View.Postion = i; View.setTop((i < 2) ? 0 : this.UICCTVContent.Height / 2.0); View.setLeft((i % 2) * 683); this.UICCTVContent.Children.Add(View); } } else if (App.DataCamera.Count < 10) { int k = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++, k++) { if (k < App.DataCamera.Count) { CameraCCTV View = new CameraCCTV(); View.Height = this.UICCTVContent.Height / 3f; View.Width = 1366 / 3f; View.Camera = App.DataCamera[k]; View.Postion = k; View.setTop(i * this.UICCTVContent.Height / 3.0); View.setLeft(j * 1366 / 3.0); this.UICCTVContent.Children.Add(View); } } } } else { int row = App.DataCamera.Count / 4; if (App.DataAlarm.Count % 4 != 0) { row++; } int k = 0; for (int i = 0; i < row; i++) { for (int j = 0; j < 4; j++, k++) { if (k < App.DataCamera.Count) { CameraCCTV View = new CameraCCTV(); View.Height = this.UICCTVContent.Height / row; View.Width = 1360 / 4f; View.Camera = App.DataCamera[k]; View.Postion = k; View.setTop(i * this.UICCTVContent.Height / row); View.setLeft(j * 1360 / 4f); this.UICCTVContent.Children.Add(View); } } } } } }); }
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); } }