| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System;
- using System.Globalization;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Media;
- namespace TeamAAS.Converters
- {
- public class BoolToArrowConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is bool collapsed && collapsed)
- return "▶";
- return "◀";
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- public class BoolToWidthConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is bool collapsed && collapsed)
- return new GridLength(48);
- return new GridLength(280);
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- public class InvertBoolToVisibilityConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is bool boolValue && boolValue)
- return Visibility.Collapsed;
- return Visibility.Visible;
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- /// <summary>
- /// 运行状态圆点颜色:true(运行中)=绿色,false=灰色。
- /// </summary>
- public class RunDotConverter : IValueConverter
- {
- private static readonly Brush Running = new SolidColorBrush(
- (Color)ColorConverter.ConvertFromString("#4CAF50"));
- private static readonly Brush Stopped = new SolidColorBrush(
- (Color)ColorConverter.ConvertFromString("#888888"));
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return (value is bool b && b) ? Running : Stopped;
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
|