This commit is contained in:
2026-02-02 21:56:45 +08:00
commit 320550399d
24 changed files with 4551 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ImageCompressor
{
/// <summary>
/// 用来总的记录各个线程处理照片的进度,以及标记线程运行结果
/// </summary>
class CountProgress
{
ImageCompressorForm owner;
public CountProgress(int totalCount, ImageCompressorForm owner)
{
this.TotalCount = totalCount;
this.owner = owner;
FailedInfos = new List<string>();
}
public ReaderWriterLock RWLock = new ReaderWriterLock();
/// <summary>
/// 总的处理了的照片数量
/// </summary>
public int ProcessedCount => SuccessCount + FailedCount + SkipCount;
/// <summary>
/// 处理过成功的照片数量
/// </summary>
public int SuccessCount { get; set; } = 0;
/// <summary>
/// 处理过失败的照片数量
/// </summary>
public int FailedCount { get; set; } = 0;
/// <summary>
/// 已经跳过的照片数量
/// </summary>
public int SkipCount { get; set; } = 0;
/// <summary>
/// 处理失败的信息
/// </summary>
public List<string> FailedInfos { get; set; }
/// <summary>
/// 需要处理的照片总数
/// </summary>
public int TotalCount { get; private set; }
/// <summary>
/// 是否已经处理完所有照片
/// </summary>
public bool Finished => ProcessedCount == TotalCount;
/// <summary>
/// 处理前照片的大小总和
/// </summary>
public long PreSizeKBSum { get; set; } = 0;
/// <summary>
/// 压缩后照片的大小总和
/// </summary>
public long PostSizeKBSum { get; set; } = 0;
/// <summary>
/// 计时器
/// </summary>
public Stopwatch stopwatch { get; set; } = new Stopwatch();
/// <summary>
/// Update Data To Winform
/// </summary>
public void Update()
{
owner.SetProgressValue(ProcessedCount);
if (Finished)
{
stopwatch.Stop();
owner.ShowReport();
}
}
}
}