DreamineVMS 1.0.0.0
Windows PC의 RTSP·USB 카메라 영상을 HLS로 변환해 원격 CCTV Viewer에 전달하는 데스크톱 에이전트입니다.
로딩중...
검색중...
일치하는것 없음
CameraRowViewModel.cs
이 파일의 문서화 페이지로 가기
2using System.ComponentModel;
3using System.Runtime.CompilerServices;
4using System.Windows.Media;
5
7
24public sealed class CameraRowViewModel : INotifyPropertyChanged, IDisposable
25{
43 private bool _isDisposed;
44
78 {
79 Device = device ?? throw new ArgumentNullException(nameof(device));
80 _runtimeState = runtimeState ?? throw new ArgumentNullException(nameof(runtimeState));
81
82 _runtimeState.PropertyChanged += OnRuntimeStatePropertyChanged;
83 }
84
93 public event PropertyChangedEventHandler? PropertyChanged;
94
103 public CameraDevice Device { get; }
104
113 public string Id => Device.Id;
114
123 public string Name => Device.Name;
124
133 public string RtspUrl => Device.RtspUrl;
134
143 public string HlsUrl => Device.HlsUrl;
144
154
163 public string StateText => _runtimeState.State.ToString();
164
173 public Brush StateBrush => _runtimeState.State switch
174 {
175 CameraConnectionState.Connected => new SolidColorBrush(Color.FromRgb(0x22, 0xc5, 0x5e)),
176 CameraConnectionState.Connecting => new SolidColorBrush(Color.FromRgb(0xf5, 0x9e, 0x0b)),
177 CameraConnectionState.Faulted => new SolidColorBrush(Color.FromRgb(0xef, 0x44, 0x44)),
178 _ => new SolidColorBrush(Color.FromRgb(0x6b, 0x72, 0x80))
179 };
180
189 public void Dispose()
190 {
191 if (_isDisposed)
192 {
193 return;
194 }
195
196 _isDisposed = true;
197 _runtimeState.PropertyChanged -= OnRuntimeStatePropertyChanged;
198 }
199
224 private void OnRuntimeStatePropertyChanged(object? sender, PropertyChangedEventArgs e)
225 {
226 // RuntimeState의 어떤 속성이 바뀌어도 행 표시에 영향이 있으므로 일괄 알림.
227 OnPropertyChanged(nameof(State));
230 }
231
248 private void OnPropertyChanged([CallerMemberName] string? propertyName = null)
249 {
250 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
251 }
252}
void OnRuntimeStatePropertyChanged(object? sender, PropertyChangedEventArgs e)
void OnPropertyChanged([CallerMemberName] string? propertyName=null)
CameraRowViewModel(CameraDevice device, CameraRuntimeState runtimeState)
PropertyChangedEventHandler? PropertyChanged