using QVCopier.Utility; using System; using System.Windows.Forms; namespace QVCopier.Models { public class WorkItem { public string SourcePath { get; set; } public string DestPath { get; set; } public long Size { get; set; } public WorkItemStatus Status { get; set; } public string SourceChecksum { get; set; } public string DestChecksum { get; set; } public string DestOps { get; set; } public WorkItemDestPolicy DestPolicy { get; set; } private ListViewItem _lvi; public void UpdateUi() { if (_lvi == null) return; if (_lvi.ListView?.InvokeRequired == true) { _lvi.ListView.Invoke(new Action(UpdateListViewItemContent)); } else { UpdateListViewItemContent(); } } private void UpdateListViewItemContent() { _lvi.SubItems.Clear(); _lvi.Text = SourcePath; _lvi.SubItems.Add(DestPath); _lvi.SubItems.Add(Size.ToFriendFileSize()); _lvi.SubItems.Add(Status.ToString()); _lvi.SubItems.Add($"{SourceChecksum ?? "-"} / {DestChecksum ?? "-"}"); _lvi.SubItems.Add(DestOps); } public static implicit operator ListViewItem(WorkItem item) { if (item._lvi != null) return item._lvi; item._lvi = new ListViewItem(); item.UpdateListViewItemContent(); return item._lvi; } } }