| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 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;
- 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;
- Management management = app.Container.Resolve<Management>();
- var plc = management.DeviceConfig.Plcs.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;
- }
- }
- }
|