using System; using System.IO; namespace ClipForge { public class ClipFile : System.ComponentModel.INotifyPropertyChanged { public event System.ComponentModel.PropertyChangedEventHandler? PropertyChanged; private string _thumbnailPath = ""; public string Path { get; set; } = ""; public string Title { get; set; } = ""; public string Duration { get; set; } = ""; public string FileSize { get; set; } = ""; public DateTime CreatedAt { get; set; } public string CreatedAtDisplay => CreatedAt.ToString("MMM d, yyyy h:mm tt"); public string ThumbnailPath { get => _thumbnailPath; set { _thumbnailPath = value; PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs( nameof(ThumbnailPath))); } } public bool HasThumbnail => File.Exists(_thumbnailPath); public static ClipFile FromPath(string path) { var info = new FileInfo(path); var thumbPath = System.IO.Path.ChangeExtension(path, ".thumb.png"); return new ClipFile { Path = path, Title = System.IO.Path.GetFileNameWithoutExtension(path), FileSize = FormatFileSize(info.Length), CreatedAt = info.CreationTime, Duration = "0:30", ThumbnailPath = thumbPath }; } private static string FormatFileSize(long bytes) { if (bytes >= 1_073_741_824) return $"{bytes / 1_073_741_824.0:F1} GB"; if (bytes >= 1_048_576) return $"{bytes / 1_048_576.0:F0} MB"; return $"{bytes / 1024.0:F0} KB"; } } }