using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Data; using System.Windows.Media.Imaging; namespace PipeGallery.Converter { public class SNRImageConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { try { string snr = value.ToString(); double dsnr = double.Parse(snr.Substring(0, snr.IndexOf(":"))); if (dsnr <= 3 && dsnr > 0) { return new BitmapImage(new Uri("/PipeGallery;component/Image/homepage_icon8.png", UriKind.Relative)); } else if (dsnr <= 8 && dsnr > 3) { return new BitmapImage(new Uri("/PipeGallery;component/Image/homepage_icon9.png", UriKind.Relative)); } else if (dsnr > 8) { return new BitmapImage(new Uri("/PipeGallery;component/Image/homepage_icon10.png", UriKind.Relative)); } else { return null; } } catch { return null; } } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } }