using System.Windows.Data;
using System.Windows;

namespace CtrEditor
{
    public class UnsavedChangesConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is string path)
            {
                var viewModel = Application.Current.MainWindow?.DataContext as MainViewModel;
                if (viewModel?.HasUnsavedChanges == true)
                {
                    return $"{path} *";
                }
                return path;
            }
            return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
