using Ocr.Tesseract.Interface;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Ocr.Tesseract.Screenshots.Configuration;

/// <summary>
/// Configuration for the <see cref="ScreenshotProcessor"/>
/// </summary>
public class ScreenshotProcessorConfiguration : IImageProcessorConfiguration, INotifyPropertyChanged
{
  #region Implementation of IMagickImageValueProcessorSettings

  private int _border = 10;
  private bool _enableResizing = true;
  private bool _enableThresholding = true;
  private bool _filterConnectedComponents;
  private int _thresholdWidth = 15, _thresholdHeight = 17;

  /// <inheritdoc/>
  public int Border
  {
    get => _border;
    set
    {
      if (value == _border)
      {
        return;
      }

      _border = value;
      OnPropertyChanged();
    }
  }

  /// <inheritdoc/>
  public bool EnableResizing
  {
    get => _enableResizing;
    set
    {
      if (value == _enableResizing)
      {
        return;
      }

      _enableResizing = value;
      OnPropertyChanged();
    }
  }

  /// <inheritdoc/>
  public bool EnableThresholding
  {
    get => _enableThresholding;
    set
    {
      if (value == _enableThresholding)
      {
        return;
      }

      _enableThresholding = value;
      OnPropertyChanged();
    }
  }

  /// <inheritdoc/>
  public bool FilterConnectedComponents
  {
    get => _filterConnectedComponents;
    set
    {
      if (value == _filterConnectedComponents)
      {
        return;
      }

      _filterConnectedComponents = value;
      OnPropertyChanged();
    }
  }

  /// <inheritdoc/>
  public int ThresholdHeight
  {
    get => _thresholdHeight;
    set
    {
      if (value == _thresholdHeight)
      {
        return;
      }

      _thresholdHeight = value;
      OnPropertyChanged();
    }
  }

  /// <inheritdoc/>
  public int ThresholdWidth
  {
    get => _thresholdWidth;
    set
    {
      if (value == _thresholdWidth)
      {
        return;
      }

      _thresholdWidth = value;
      OnPropertyChanged();
    }
  }

  #endregion Implementation of IMagickImageValueProcessorSettings

  #region Implementation of INotifyPropertyChanged

  public event PropertyChangedEventHandler? PropertyChanged;

  protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
  {
    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  }

  #endregion Implementation of INotifyPropertyChanged
}
