MFCListConverter.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Windows.Data;
  7. using System.Windows.Media;
  8. using System.Windows;
  9. using Aitex.Core.RT.Log;
  10. using System.Collections.ObjectModel;
  11. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  12. namespace FurnaceUI.Converter
  13. {
  14. public class MFCListConverter : IValueConverter
  15. {
  16. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  17. {
  18. try
  19. {
  20. var mfcList = value as ObservableCollection<MFCData>;
  21. while (mfcList.Count > 10)
  22. {
  23. mfcList.Remove(mfcList.LastOrDefault());
  24. }
  25. while (mfcList.Count < 10)
  26. {
  27. mfcList.Add(new MFCData()
  28. {
  29. Name = "",
  30. DisplayName = "",
  31. // SetValueParam = ""
  32. });
  33. }
  34. return mfcList;
  35. }
  36. catch (Exception ex)
  37. {
  38. LOG.Write(ex);
  39. }
  40. return value;
  41. }
  42. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  43. {
  44. throw new NotImplementedException();
  45. }
  46. }
  47. }