Skip to content

Commit eb8aa77

Browse files
committed
- Add Progressbar color converter
- Colorized(red) when usage space 90% over
1 parent 4bc3367 commit eb8aa77

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows.Data;
8+
using System.Windows.Media;
9+
10+
namespace Flow.Launcher.Converters
11+
{
12+
public class ProgressForegroundConverter : IValueConverter
13+
{
14+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15+
{
16+
double progress = (double)value;
17+
string foreground = "#26a0da";
18+
19+
if (progress >= 90)
20+
{
21+
foreground = "#da2626";
22+
}
23+
24+
return foreground;
25+
}
26+
27+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
28+
{
29+
throw new NotImplementedException();
30+
}
31+
}
32+
}

Flow.Launcher/ResultListBox.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<Grid.Resources>
4747
<converter:HighlightTextConverter x:Key="HighlightTextConverter" />
4848
<converter:OrdinalConverter x:Key="OrdinalConverter" />
49+
<converter:ProgressForegroundConverter x:Key="ProgressForegroundConverter" />
4950
<converter:OpenResultHotkeyVisibilityConverter x:Key="OpenResultHotkeyVisibilityConverter" />
5051
</Grid.Resources>
5152
<Grid.ColumnDefinitions>
@@ -113,6 +114,7 @@
113114
</Grid.RowDefinitions>
114115
<ProgressBar
115116
x:Name="progressbarResult"
117+
Foreground="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Value, Converter={StaticResource ProgressForegroundConverter}}"
116118
Style="{DynamicResource ProgressBarResult}"
117119
Value="{Binding Result.ProgressBar}" />
118120
<TextBlock

0 commit comments

Comments
 (0)