using Prism; using Prism.Ioc; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; using System.Windows.Forms.Design; using TeamAAS_VP.Core; using TeamAAS_VP.Interfaces; namespace TeamAAS_VP.ValueConverter { public class PlcIdToNameConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value!=null && value is Guid id && id!=Guid.Empty) { var app = (PrismApplicationBase)App.Current; IConfigService configService = app.Container.Resolve(); var plc = configService.GetAllPlcs().FirstOrDefault(p => p.Id == id); if (plc!=null) { return plc.Name; } else { return string.Empty; } } else { return string.Empty; } } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return Binding.DoNothing; } } }