- Add Progressbar color converter

- Colorized(red) when usage space 90% over
This commit is contained in:
DB p 2022-09-07 00:28:49 +09:00
parent 4bc3367e3f
commit eb8aa77e75
2 changed files with 34 additions and 0 deletions

View file

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;
namespace Flow.Launcher.Converters
{
public class ProgressForegroundConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double progress = (double)value;
string foreground = "#26a0da";
if (progress >= 90)
{
foreground = "#da2626";
}
return foreground;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View file

@ -46,6 +46,7 @@
<Grid.Resources>
<converter:HighlightTextConverter x:Key="HighlightTextConverter" />
<converter:OrdinalConverter x:Key="OrdinalConverter" />
<converter:ProgressForegroundConverter x:Key="ProgressForegroundConverter" />
<converter:OpenResultHotkeyVisibilityConverter x:Key="OpenResultHotkeyVisibilityConverter" />
</Grid.Resources>
<Grid.ColumnDefinitions>
@ -113,6 +114,7 @@
</Grid.RowDefinitions>
<ProgressBar
x:Name="progressbarResult"
Foreground="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Value, Converter={StaticResource ProgressForegroundConverter}}"
Style="{DynamicResource ProgressBarResult}"
Value="{Binding Result.ProgressBar}" />
<TextBlock