using Standard; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows.Input; using System.Xml.Linq; using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header; namespace VideoConcat.Models { public class VideoModel : INotifyPropertyChanged { private int _num; private int _maxNum; private string _folderPath = ""; private string _auditImagePath = ""; private bool _canStart = false; private ObservableCollection _FolderInfos = []; public int Num { get => _num; set { _num = value; OnPropertyChanged(); UpdateSum(); } } public string AuditImagePath { get => _auditImagePath; set { _auditImagePath = value; OnPropertyChanged(); } } public int MaxNum { get => _maxNum; set { _maxNum = value; } } public struct FolderInfo { public DirectoryInfo DirectoryInfo { set; get; } public int Num { set; get; } public List VideoPaths { set; get; } } public ObservableCollection FolderInfos { get { return _FolderInfos; } set { if (_FolderInfos != null) { _FolderInfos.CollectionChanged -= ItemList_CollectionChanged; } _FolderInfos = value; if (_FolderInfos != null) { _FolderInfos.CollectionChanged += ItemList_CollectionChanged; } OnPropertyChanged(); UpdateSum(); } } public string FolderPath { get { return _folderPath; } set { _folderPath = value; OnPropertyChanged(nameof(FolderPath)); } } public bool CanStart { get { return _canStart; } set { _canStart = value; OnPropertyChanged(nameof(CanStart)); } } public ICommand? BtnOpenFolderCommand { get; set; } public ICommand? BtnStartVideoConcatCommand { get; set; } public ICommand? BtnChooseAuditImageCommand { get; set; } public event PropertyChangedEventHandler? PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } private void ItemList_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) { UpdateSum(); } public void UpdateSum() { int _temp = 1; if (FolderInfos.Count > 0) { foreach (FolderInfo item in FolderInfos) { if (item.Num > 0) { _temp *= item.Num; } } MaxNum = _temp; SetCanStart(); } else { MaxNum = 0; SetCanStart(); } } public void SetCanStart() { if (Num > 0 && Num <= MaxNum) { CanStart = true; } else { CanStart = false; } } } }