using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using SmartAquaViewer.DataAnalysis;
using SmartAquaViewer.Model;

namespace SmartAquaViewer.ViewModel
{
    public class CCTVViewModel : INotifyPropertyChanged
    {
        public List<CCTVInfo> CCTVInfoList { get; } = new List<CCTVInfo>();

        private int _columnCount;
        public int ColumnCount
        {
            get => _columnCount;
            set
            {
                if (_columnCount != value)
                {
                    _columnCount = value;
                    OnPropertyChanged();
                }
            }
        }

        private int _rowCount;
        public int RowCount
        {
            get => _rowCount;
            set
            {
                if (_rowCount != value)
                {
                    _rowCount = value;
                    OnPropertyChanged();
                }
            }
        }

        public CCTVViewModel()
        {
            ColumnCount = 4; // Default value
            RowCount = 2;    // Default value

            CCTVInfoList = new List<CCTVInfo>()
            {
                new()
                {
                    DeviceId = "000001",
                    DeviceName = "CCTV 1",
                    RtspUrl = "rtsp://210.217.121.58:8554/CAM-211",
                    Status = "Active"
                },
                new()
                {
                    DeviceId = "000002",
                    DeviceName = "CCTV 2",
                    RtspUrl = "rtsp://210.217.121.58:8554/CAM-212",
                    Status = "Active"
                },
                new()
                {
                    DeviceId = "000003",
                    DeviceName = "CCTV 3",
                    RtspUrl = "rtsp://210.217.121.58:8554/CAM-211",
                    Status = "Active"
                },
                new()
                {
                    DeviceId = "000004",
                    DeviceName = "CCTV 4",
                    RtspUrl = "rtsp://210.217.121.58:8554/CAM-212",
                    Status = "Active"
                },
                new()
                {
                    DeviceId = "000005",
                    DeviceName = "CCTV 5",
                    RtspUrl = "rtsp://210.217.121.58:8554/CAM-211",
                    Status = "Active"
                },
                new()
                {
                    DeviceId = "000006",
                    DeviceName = "CCTV 6",
                    RtspUrl = "rtsp://210.217.121.58:8554/CAM-212",
                    Status = "Active"
                }
            };
        }

        public event PropertyChangedEventHandler? PropertyChanged;
        private void OnPropertyChanged([CallerMemberName] string? name = null)
            => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }
}
