39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using System.Windows.Data;
|
|
using Microsoft.Web.WebView2.Core;
|
|
|
|
namespace VideoDownloader.App.Browser.Features;
|
|
|
|
/// <summary>CoreWebView2DownloadOperation → IDownloadOperation 어댑터.</summary>
|
|
public sealed class DownloadOperationAdapter : IDownloadOperation
|
|
{
|
|
private readonly CoreWebView2DownloadOperation _op;
|
|
public DownloadOperationAdapter(CoreWebView2DownloadOperation op) => _op = op;
|
|
|
|
public string Uri => _op.Uri ?? "";
|
|
public string FileName => Path.GetFileName(_op.ResultFilePath ?? "");
|
|
public long BytesReceived => (long)_op.BytesReceived;
|
|
public long TotalBytesToReceive => (long)(_op.TotalBytesToReceive ?? 0);
|
|
public string State => _op.State.ToString();
|
|
|
|
public void Pause() => _op.Pause();
|
|
public void Resume() => _op.Resume();
|
|
public void Cancel() => _op.Cancel();
|
|
|
|
public event Action? Changed
|
|
{
|
|
add { _op.BytesReceivedChanged += (_, _) => value?.Invoke(); _op.StateChanged += (_, _) => value?.Invoke(); }
|
|
remove { }
|
|
}
|
|
}
|
|
|
|
/// <summary>탭 검색 결과의 IsClosed → "닫힘" 라벨 변환.</summary>
|
|
public sealed class BoolToClosedConverter : IValueConverter
|
|
{
|
|
public static readonly BoolToClosedConverter Instance = new();
|
|
|
|
public object Convert(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
|
|
=> value is true ? "닫힘 · 클릭해서 복원" : "";
|
|
|
|
public object ConvertBack(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
|
|
=> throw new NotSupportedException();
|
|
}
|