feat(tools): add first-run external tool installer wizard and catalog
첫 실행 시 외부 도구 설치 마법사를 띄우고 7종(FFmpeg·LibreOffice·Pandoc·ImageMagick·H2Orestart·agy·Codex)을 기본 전체 선택 상태로 순차 설치한다. - Core: ExternalToolCatalog(정적 카탈로그, winget ID 실검증), ExternalToolInstaller(winget 무인 실행·재감지 판정, IExternalCommandRunner 시드로 테스트 가능) - Core: ExternalToolDetector에 winget FFmpeg 스캔 + Pandoc/ImageMagick 감지 추가 - App: ToolSetupWindow + ToolSetupViewModel, 첫 실행 플래그(setup.tools.done), 설정 창 '외부 도구 설치/검증' 재진입 버튼 - Tests: ExternalToolInstallerTests 5건 - 기존 미커밋 작업(광고 Ads 지원: AdBannerControl/AdLargeCardControl/AdService, AI 백엔드 agy·switchboard·codex 채팅 클라이언트, 관련 테스트) 포함
This commit is contained in:
parent
f00f6567f4
commit
6a41c4a0dc
37 changed files with 2545 additions and 69 deletions
106
src/Everything2Everything.App/ViewModels/AdViewModel.cs
Normal file
106
src/Everything2Everything.App/ViewModels/AdViewModel.cs
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Input;
|
||||
using Everything2Everything.Core.Ads;
|
||||
|
||||
namespace Everything2Everything.App.ViewModels;
|
||||
|
||||
public class AdViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private readonly IAdService _adService;
|
||||
private AdItem? _currentBannerAd;
|
||||
private AdItem? _currentLargeAd;
|
||||
private bool _isBannerVisible = true;
|
||||
private bool _isLargeCardVisible = true;
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public AdItem? CurrentBannerAd
|
||||
{
|
||||
get => _currentBannerAd;
|
||||
set { _currentBannerAd = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public AdItem? CurrentLargeAd
|
||||
{
|
||||
get => _currentLargeAd;
|
||||
set { _currentLargeAd = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public bool IsBannerVisible
|
||||
{
|
||||
get => _isBannerVisible;
|
||||
set { _isBannerVisible = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public bool IsLargeCardVisible
|
||||
{
|
||||
get => _isLargeCardVisible;
|
||||
set { _isLargeCardVisible = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public ICommand ClickBannerAdCommand { get; }
|
||||
public ICommand ClickLargeAdCommand { get; }
|
||||
public ICommand DismissBannerCommand { get; }
|
||||
public ICommand DismissLargeCardCommand { get; }
|
||||
|
||||
public AdViewModel(IAdService adService)
|
||||
{
|
||||
_adService = adService ?? throw new ArgumentNullException(nameof(adService));
|
||||
|
||||
CurrentBannerAd = _adService.GetNextBannerAd();
|
||||
CurrentLargeAd = _adService.GetNextLargeCardAd();
|
||||
|
||||
ClickBannerAdCommand = new AdCommand(_ =>
|
||||
{
|
||||
if (CurrentBannerAd != null)
|
||||
_adService.OpenAdUrl(CurrentBannerAd);
|
||||
});
|
||||
|
||||
ClickLargeAdCommand = new AdCommand(_ =>
|
||||
{
|
||||
if (CurrentLargeAd != null)
|
||||
_adService.OpenAdUrl(CurrentLargeAd);
|
||||
});
|
||||
|
||||
DismissBannerCommand = new AdCommand(_ => IsBannerVisible = false);
|
||||
DismissLargeCardCommand = new AdCommand(_ => IsLargeCardVisible = false);
|
||||
}
|
||||
|
||||
public void RotateBannerAd()
|
||||
{
|
||||
CurrentBannerAd = _adService.GetNextBannerAd();
|
||||
}
|
||||
|
||||
public void RotateLargeCardAd()
|
||||
{
|
||||
CurrentLargeAd = _adService.GetNextLargeCardAd();
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private sealed class AdCommand : ICommand
|
||||
{
|
||||
private readonly Action<object?> _execute;
|
||||
private readonly Func<object?, bool>? _canExecute;
|
||||
|
||||
public AdCommand(Action<object?> execute, Func<object?, bool>? canExecute = null)
|
||||
{
|
||||
_execute = execute;
|
||||
_canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object? parameter) => _canExecute?.Invoke(parameter) ?? true;
|
||||
public void Execute(object? parameter) => _execute(parameter);
|
||||
|
||||
public event EventHandler? CanExecuteChanged
|
||||
{
|
||||
add { }
|
||||
remove { }
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue