终端一体化运控平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

77 行
2.2 KiB

  1. using BPASmartClient.CustomResource.UserControls.Enum;
  2. using MahApps.Metro.IconPacks;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Globalization;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. namespace BPASmartClient.CustomResource.Converters
  13. {
  14. public class ToastIconConverter : IMultiValueConverter
  15. {
  16. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  17. {
  18. object value = values[0];
  19. object grid = values[1];
  20. object txt = values[2];
  21. Grid _grid = grid as Grid;
  22. TextBlock _txt = txt as TextBlock;
  23. void WithoutIcon()
  24. {
  25. if (_grid != null)
  26. {
  27. _grid.ColumnDefinitions.RemoveAt(0);
  28. }
  29. if (_txt != null)
  30. {
  31. _txt.HorizontalAlignment = HorizontalAlignment.Center;
  32. }
  33. }
  34. if (value == null)
  35. {
  36. WithoutIcon();
  37. return PackIconFontAwesomeKind.None;
  38. }
  39. ToastIcons _value;
  40. try
  41. {
  42. _value = (ToastIcons)value;
  43. }
  44. catch
  45. {
  46. WithoutIcon();
  47. return PackIconFontAwesomeKind.None;
  48. }
  49. switch (_value)
  50. {
  51. case ToastIcons.Information:
  52. return PackIconFontAwesomeKind.CheckCircleSolid;
  53. case ToastIcons.Error:
  54. return PackIconFontAwesomeKind.TimesSolid;
  55. case ToastIcons.Warning:
  56. return PackIconFontAwesomeKind.ExclamationSolid;
  57. case ToastIcons.Busy:
  58. return PackIconFontAwesomeKind.ClockSolid;
  59. }
  60. WithoutIcon();
  61. return PackIconFontAwesomeKind.None;
  62. }
  63. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  64. {
  65. throw new NotImplementedException();
  66. }
  67. }
  68. }