12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /* ==============================================================================
- * 功能描述:ModelCheckConverter
- * 创 建 者:Garrett
- * 创建日期:2019/10/21 16:02:55
- * ==============================================================================*/
- using System;
- using System.Globalization;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Media.Imaging;
- namespace Saga.PlugIn.ModelCheck
- {
- /// <summary>
- /// ModelCheckConverter
- /// </summary>
- class ItemImageVisibleConverter : IValueConverter
- {
- public bool IsEqualCollapsed { get; set; }
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- var state = (ModelCheckState) value;
- Visibility visibility = Visibility.Visible;
- if (IsEqualCollapsed)
- {
- visibility = (state.Equals(parameter) ? Visibility.Collapsed : Visibility.Visible);
- }
- else
- {
- visibility = (!state.Equals(parameter) ? Visibility.Collapsed : Visibility.Visible);
- }
- return visibility;
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- class ItemImageConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- var state = (ModelCheckState)value;
- BitmapSource image = null;
- string imageName = null;
- switch (state)
- {
- case ModelCheckState.Progress:
- imageName = "省略号.png";
- break;
- case ModelCheckState.Ending:
- imageName = "对勾.png";
- break;
- }
-
- if (!string.IsNullOrEmpty(imageName))
- {
- Uri uri = new Uri("pack://application:,,,/Saga.PlugIn;component/ModelCheck/Image/" + imageName);
- image= BitmapFrame.Create(uri, BitmapCreateOptions.None, BitmapCacheOption.OnDemand);
- }
- return image;
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
|