using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; using Tango.Integration.Operation; namespace Tango.PPC.UI.Converters { public class MidTankLevelToElementRectConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { try { double actualHeight = (double)values[0]; double actualWidth = (double)values[1]; double maxLiters = (double)values[3]; double midTankLevel = Math.Min((double)values[2], maxLiters); var offset = actualHeight - (midTankLevel / maxLiters) * actualHeight; return new System.Windows.Rect(1, offset, actualWidth, actualHeight); } catch { return 0d; } } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }