private void Live_Button_Click(object sender, RoutedEventArgs e) { if (_recvThread != null) { return; } int i = _cameraCombo.SelectedIndex; SystemAccess.Camera camera = _cameras[i]; _isc = new ImageServerConnection(camera.RecorderUri, camera.Guid.ToString(), 75); _isc.SetCredentials(_sysInfo); _isc.OnImageReceivedMethod += OnLiveImageReceivedMethod; _isc.OnConnectionStoppedMethod += OnLiveConnectionStoppedMethod; _isc.OnStatusItemReceivedMethod += OnStatusItemReceivedMethod; _isc.RenderObject = this; _recvThread = new Thread(_isc.Live); _recvThread.Start(); PlaybackTimeString = "Live"; NotifyPropertyChanged("PlaybackTimeString"); NotifyPropertyChanged("LiveButtonVisibility"); NotifyPropertyChanged("StopButtonVisibility"); NotifyPropertyChanged("CameraComboEnabled"); NotifyPropertyChanged("TokenString"); _tokenTextBlock.Visibility = Visibility.Hidden; _tokenTextBlock.Visibility = Visibility.Visible; }
private void _sequenceList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (_recvThread != null || _sequenceList.SelectedItem == null || _sequenceList.SelectedItem.Equals("no")) { return; } DateTime date = new DateTime(); string str = _sequenceList.SelectedItem is string?(string)_sequenceList.SelectedItem : string.Empty; if (!DateTime.TryParse(str.Substring(0, 8), out date)) { return; } int i = _cameraCombo.SelectedIndex; SystemAccess.Camera camera = _cameras[i]; _isc = new ImageServerConnection(camera.RecorderUri, camera.Guid.ToString(), 75); _isc.SetCredentials(_sysInfo); _isc.OnImageReceivedMethod += OnPlaybackImageReceivedMethod; _isc.OnConnectionStoppedMethod += OnPlaybackConnectionStoppedMethod; _isc.RenderObject = this; _isc.PlaybackStartTime = _sequenceStartTimes[_sequenceList.SelectedIndex]; _isc.PlaybackEndTime = _sequenceEndTimes[_sequenceList.SelectedIndex];; _recvThread = new Thread(_isc.Playback); _recvThread.Start(); NotifyPropertyChanged("LiveButtonVisibility"); NotifyPropertyChanged("StopButtonVisibility"); NotifyPropertyChanged("CameraComboEnabled"); NotifyPropertyChanged("TokenString"); _tokenTextBlock.Visibility = Visibility.Hidden; _tokenTextBlock.Visibility = Visibility.Visible; }
private void _cameraCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (_recvThread != null) { return; } VideoImage = null; NotifyPropertyChanged("VideoImage"); PlaybackTimeString = ""; NotifyPropertyChanged("PlaybackTimeString"); int i = _cameraCombo.SelectedIndex; SystemAccess.Camera camera = _cameras[i]; ImageServerConnection isc = new ImageServerConnection(camera.RecorderUri, camera.Guid.ToString(), 75); isc.SetCredentials(_sysInfo); string sequences = isc.GetSequences(DateTime.Now, 16); _sequenceList.Items.Clear(); _sequenceStartTimes = new List <long>(); _sequenceEndTimes = new List <long>(); if (sequences.StartsWith("#")) { _sequenceList.Items.Add(sequences.Substring(1)); return; } try { XmlDocument doc = new XmlDocument(); doc.LoadXml(sequences); XmlNodeList nodes = doc.GetElementsByTagName("alarm"); foreach (XmlNode node in nodes) { XmlAttributeCollection attrs = node.Attributes; string start = ""; string end = ""; string alarm = "??"; for (int ii = 0; ii < attrs.Count; ii++) { XmlAttribute attr = (XmlAttribute)attrs.Item(ii); if (attr.Name.ToLower().Equals("starttime")) { start = attr.Value; } if (attr.Name.ToLower().Equals("endtime")) { end = attr.Value; } if (attr.Name.ToLower().Equals("alarmtime")) { alarm = attr.Value; } } long ss = long.Parse(start); long ee = long.Parse(end); DateTime sdt = TimeConverter.From(start); DateTime edt = TimeConverter.From(end); TimeSpan sql = edt - sdt; _sequenceList.Items.Insert(0, sdt.ToLongTimeString() + " (" + sql.Seconds + " s)"); _sequenceStartTimes.Insert(0, ss); _sequenceEndTimes.Insert(0, ee); } } catch (Exception ex) { string s = ex.Message; } }