using System;
using System.Windows;
using OwlCore.AbstractUI.Models;
using OwlCore.AbstractUI.ViewModels;
using CommunityToolkit.Diagnostics;
using System.Windows.Data;
using System.Globalization;
namespace OwlCore.Wpf.AbstractUI.Themes
{
///
/// Selects the template that is used for an based on the .
///
public class AbstractButtonTemplateSelector : IValueConverter
{
///
/// The data template used to a display an with a generic style.
///
public Style? GenericStyle { get; set; }
///
/// The data template used to a display an with a confirmation style.
///
public Style? ConfirmStyle { get; set; }
///
/// The data template used to a display an with a deletion style.
///
public Style? DeleteStyle { get; set; }
///
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var type = AbstractButtonType.Generic;
if (value is AbstractButtonType vType)
type = vType;
if (value is AbstractButtonViewModel buttonViewModel)
type = buttonViewModel.Type;
else if (value is AbstractButton button)
type = button.Type;
return type switch
{
AbstractButtonType.Generic => GenericStyle ?? ThrowHelper.ThrowArgumentNullException