VideoConcat/Models/MainWindowModel.cs
2025-08-12 00:13:45 +08:00

57 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace VideoConcat.Models
{
class MainWindowModel : INotifyPropertyChanged
{
public enum OptionType { none, video, extract }
private OptionType _selectedOption;
public OptionType SelectedOption
{
get => _selectedOption;
set
{
_selectedOption = value;
OnPropertyChanged();
// 状态变化时执行逻辑
HandleSelection(value);
}
}
private void HandleSelection(OptionType option)
{
Console.WriteLine($"选中了: {option}");
}
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public class EnumToBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value?.Equals(parameter) ?? false;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? parameter : System.Windows.Data.Binding.DoNothing;
}
}
}