Converter error was fixed

This commit is contained in:
Evgeny Redikultsev
2022-11-27 20:46:15 +05:00
parent 96b331f14c
commit e820f3522d
17 changed files with 250 additions and 38 deletions

View File

@@ -7,22 +7,33 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal abstract class UnitBase : IValueConverter
{
public abstract UnitTypes unitType { get; }
public abstract IUnit currentUnit { get; }
public abstract string unitName { get;}
public abstract UnitTypes UnitType { get; }
public abstract IUnit CurrentUnit { get; }
public abstract string UnitName { get;}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return CommonOperation.Convert(currentUnit, unitName, value);
return CommonOperation.Convert(CurrentUnit, UnitName, value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return CommonOperation.ConvertBack(unitType, currentUnit, value);
try
{
return CommonOperation.ConvertBack(UnitType, CurrentUnit, value);
}
catch (Exception)
{
MessageBox.Show($"Value of {UnitName}={(string)value} is not correct", "Error of conversion", MessageBoxButtons.OK);
return 0;
}
}
}
}