|
|
|
|
@ -6,6 +6,9 @@ using System.Linq;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using SmartAquaViewer.Controls;
|
|
|
|
|
using SmartAquaViewer.DataAnalysis;
|
|
|
|
|
using SmartAquaViewer.Model;
|
|
|
|
|
|
|
|
|
|
@ -13,7 +16,7 @@ namespace SmartAquaViewer.ViewModel
|
|
|
|
|
{
|
|
|
|
|
public class CCTVViewModel : INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
public List<CCTVInfo> CCTVInfoList { get; } = new List<CCTVInfo>();
|
|
|
|
|
public ObservableCollection<CCTVInfo> CCTVInfoList { get; } = new ObservableCollection<CCTVInfo>();
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<FFPlayerViewModel> PlayerVMs { get; } = new();
|
|
|
|
|
|
|
|
|
|
@ -45,72 +48,179 @@ namespace SmartAquaViewer.ViewModel
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _isOpenMode;
|
|
|
|
|
public bool IsOpenMode
|
|
|
|
|
{
|
|
|
|
|
get => _isOpenMode;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_isOpenMode != value)
|
|
|
|
|
{
|
|
|
|
|
_isOpenMode = value;
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
|
|
|
|
|
BtnVisibilityLeft = _isOpenMode ? Visibility.Collapsed : Visibility.Visible;
|
|
|
|
|
BtnVisibilityRight = _isOpenMode ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Visibility _btnVisibilityLeft;
|
|
|
|
|
public Visibility BtnVisibilityLeft
|
|
|
|
|
{
|
|
|
|
|
get => _btnVisibilityLeft;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_btnVisibilityLeft != value)
|
|
|
|
|
{
|
|
|
|
|
_btnVisibilityLeft = value;
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Visibility _btnVisibilityRight;
|
|
|
|
|
public Visibility BtnVisibilityRight
|
|
|
|
|
{
|
|
|
|
|
get => _btnVisibilityRight;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_btnVisibilityRight != value)
|
|
|
|
|
{
|
|
|
|
|
_btnVisibilityRight = value;
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Visibility _btnVisibilityPlay;
|
|
|
|
|
public Visibility BtnVisibilityPlay
|
|
|
|
|
{
|
|
|
|
|
get => _btnVisibilityPlay;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_btnVisibilityPlay != value)
|
|
|
|
|
{
|
|
|
|
|
_btnVisibilityPlay = value;
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Visibility _btnVisibilityStop;
|
|
|
|
|
public Visibility BtnVisibilityStop
|
|
|
|
|
{
|
|
|
|
|
get => _btnVisibilityStop;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_btnVisibilityStop != value)
|
|
|
|
|
{
|
|
|
|
|
_btnVisibilityStop = value;
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ICommand ChangeDrawerStatusCommand { get; }
|
|
|
|
|
|
|
|
|
|
public ICommand PlayAllCCTVCommand { get; }
|
|
|
|
|
|
|
|
|
|
public ICommand StopAllCCTVCommand { get; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CCTVViewModel()
|
|
|
|
|
{
|
|
|
|
|
ColumnCount = 4; // Default value
|
|
|
|
|
RowCount = 2; // Default value
|
|
|
|
|
|
|
|
|
|
CCTVInfoList = new List<CCTVInfo>()
|
|
|
|
|
IsOpenMode = false;
|
|
|
|
|
BtnVisibilityRight = Visibility.Collapsed;
|
|
|
|
|
BtnVisibilityStop = Visibility.Collapsed;
|
|
|
|
|
|
|
|
|
|
CCTVInfoList = new ObservableCollection<CCTVInfo>()
|
|
|
|
|
{
|
|
|
|
|
new()
|
|
|
|
|
{
|
|
|
|
|
DeviceId = "000001",
|
|
|
|
|
DeviceName = "CCTV 1",
|
|
|
|
|
RtspUrl = "rtsp://210.217.121.58:8554/CAM-211",
|
|
|
|
|
Status = "Active"
|
|
|
|
|
Status = CCTVStatus.Disconnected
|
|
|
|
|
},
|
|
|
|
|
new()
|
|
|
|
|
{
|
|
|
|
|
DeviceId = "000002",
|
|
|
|
|
DeviceName = "CCTV 2",
|
|
|
|
|
RtspUrl = "rtsp://210.217.121.58:8554/CAM-212",
|
|
|
|
|
Status = "Active"
|
|
|
|
|
Status = CCTVStatus.Disconnected
|
|
|
|
|
},
|
|
|
|
|
new()
|
|
|
|
|
{
|
|
|
|
|
DeviceId = "000003",
|
|
|
|
|
DeviceName = "CCTV 3",
|
|
|
|
|
RtspUrl = "rtsp://210.217.121.58:8554/CAM-01",
|
|
|
|
|
Status = "Active"
|
|
|
|
|
Status = CCTVStatus.Disconnected
|
|
|
|
|
},
|
|
|
|
|
new()
|
|
|
|
|
{
|
|
|
|
|
DeviceId = "000004",
|
|
|
|
|
DeviceName = "CCTV 4",
|
|
|
|
|
RtspUrl = "rtsp://210.217.121.58:8554/CAM-02",
|
|
|
|
|
Status = "Active"
|
|
|
|
|
Status = CCTVStatus.Disconnected
|
|
|
|
|
},
|
|
|
|
|
new()
|
|
|
|
|
{
|
|
|
|
|
DeviceId = "000005",
|
|
|
|
|
DeviceName = "CCTV 5",
|
|
|
|
|
RtspUrl = "rtsp://210.217.121.58:8554/CAM-03",
|
|
|
|
|
Status = "Active"
|
|
|
|
|
Status = CCTVStatus.Disconnected
|
|
|
|
|
},
|
|
|
|
|
new()
|
|
|
|
|
{
|
|
|
|
|
DeviceId = "000006",
|
|
|
|
|
DeviceName = "CCTV 6",
|
|
|
|
|
RtspUrl = "rtsp://210.217.121.58:8554/CAM-04",
|
|
|
|
|
Status = "Active"
|
|
|
|
|
Status = CCTVStatus.Disconnected
|
|
|
|
|
},
|
|
|
|
|
new()
|
|
|
|
|
{
|
|
|
|
|
DeviceId = "000007",
|
|
|
|
|
DeviceName = "CCTV 7",
|
|
|
|
|
RtspUrl = "rtsp://210.217.121.58:8554/CAM-05",
|
|
|
|
|
Status = "Active"
|
|
|
|
|
Status = CCTVStatus.Disconnected
|
|
|
|
|
},
|
|
|
|
|
new()
|
|
|
|
|
{
|
|
|
|
|
DeviceId = "000008",
|
|
|
|
|
DeviceName = "CCTV 8",
|
|
|
|
|
RtspUrl = "rtsp://210.217.121.58:8554/CAM-06",
|
|
|
|
|
Status = "Active"
|
|
|
|
|
Status = CCTVStatus.Disconnected
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BuildPlayers(CCTVInfoList);
|
|
|
|
|
|
|
|
|
|
ChangeDrawerStatusCommand = new RelayCommand(_ => IsOpenMode = !IsOpenMode);
|
|
|
|
|
PlayAllCCTVCommand = new RelayCommand(PlayAllCCTV);
|
|
|
|
|
StopAllCCTVCommand = new RelayCommand(StopAllCCTV);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PlayAllCCTV(object obj)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ff in PlayerVMs)
|
|
|
|
|
ff.StartMedia(ff.CCTVInfo.RtspUrl!);
|
|
|
|
|
|
|
|
|
|
BtnVisibilityPlay = Visibility.Collapsed;
|
|
|
|
|
BtnVisibilityStop = Visibility.Visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void StopAllCCTV(object obj)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ff in PlayerVMs)
|
|
|
|
|
ff.ClosePlayer();
|
|
|
|
|
|
|
|
|
|
BtnVisibilityPlay = Visibility.Visible;
|
|
|
|
|
BtnVisibilityStop = Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void BuildPlayers(IEnumerable<CCTVInfo> infos)
|
|
|
|
|
|