using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Aitex.Core.Common.DeviceData.IoDevice;

namespace MECF.Framework.UI.Client.Ctrlib.Controls
{
    /// <summary>
    /// Interaction logic for HeaterResistanceOverview.xaml
    /// </summary>
    public partial class HeaterResPresenter : UserControl
    {
        public HeaterResPresenter()
        {
            InitializeComponent();
        }

        #region Dps

        public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register(
            nameof(Caption), typeof(string), typeof(HeaterResPresenter), new PropertyMetadata(default(string)));

        public string Caption
        {
            get => (string)GetValue(CaptionProperty);
            set => SetValue(CaptionProperty, value);
        }       

        #endregion
    }

    internal class IoPsuResistanceSummaryConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is IoPsuData data)
            {
                return $"Realtime: {data.Resistance:F1}Ω" +
                       $"\r\nLimit High: {data.ResistanceLimitMax:F1}Ω" +
                       $"\r\nVoltage: {data.OutputVoltageFeedback:F1}V" +
                       $"\r\nAmps: {data.OutputArmsFeedBack:F1}A";
            }
            else
            {
                return "";
            }
        }

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