LayoutRecipeMonitor1Converter.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using FurnaceUI.Views.Editors;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Data;
  9. namespace FurnaceUI.Converter
  10. {
  11. public class LayoutRecipeMonitor1Converter : IValueConverter
  12. {
  13. private static Dictionary<MonitorTransferType, string> keyValuePairs = new Dictionary<MonitorTransferType, string>();
  14. private static void CreateDict()
  15. {
  16. if (keyValuePairs.Count == 0)
  17. {
  18. keyValuePairs.Add(MonitorTransferType.AutoLayout, "Automatic Equal Layout");
  19. keyValuePairs.Add(MonitorTransferType.BoatSlot, "Appoint Boat SlotNo");
  20. keyValuePairs.Add(MonitorTransferType.DirectCarrier, "Appoint between Carriers");
  21. keyValuePairs.Add(MonitorTransferType.AutoCarrier, "Automatic Insert between Carriers");
  22. }
  23. }
  24. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  25. {
  26. CreateDict();
  27. if (value == null)
  28. return keyValuePairs[MonitorTransferType.AutoLayout];
  29. if (value is MonitorTransferType)
  30. {
  31. return keyValuePairs[(MonitorTransferType)value];
  32. }
  33. return keyValuePairs[MonitorTransferType.AutoLayout];
  34. }
  35. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  36. {
  37. return parameter.ToString();
  38. }
  39. }
  40. }