|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using BPASmartClient.CustomResource.UserControls.Enum;
- using MahApps.Metro.IconPacks;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
-
- namespace BPASmartClient.CustomResource.Converters
- {
- public class ToastIconConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- object value = values[0];
- object grid = values[1];
- object txt = values[2];
- Grid _grid = grid as Grid;
- TextBlock _txt = txt as TextBlock;
-
- void WithoutIcon()
- {
- if (_grid != null)
- {
- _grid.ColumnDefinitions.RemoveAt(0);
- }
-
- if (_txt != null)
- {
- _txt.HorizontalAlignment = HorizontalAlignment.Center;
- }
- }
-
- if (value == null)
- {
- WithoutIcon();
- return PackIconFontAwesomeKind.None;
- }
-
- ToastIcons _value;
- try
- {
- _value = (ToastIcons)value;
- }
- catch
- {
- WithoutIcon();
- return PackIconFontAwesomeKind.None;
- }
-
- switch (_value)
- {
- case ToastIcons.Information:
- return PackIconFontAwesomeKind.CheckCircleSolid;
- case ToastIcons.Error:
- return PackIconFontAwesomeKind.TimesSolid;
- case ToastIcons.Warning:
- return PackIconFontAwesomeKind.ExclamationSolid;
- case ToastIcons.Busy:
- return PackIconFontAwesomeKind.ClockSolid;
- }
-
- WithoutIcon();
- return PackIconFontAwesomeKind.None;
- }
-
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
|