Change ProgressBar Value to Nullable.

This commit is contained in:
Sparrkle 2022-09-30 09:58:33 +09:00
parent 8f7e6611af
commit ab1ddbb6c5
4 changed files with 24 additions and 15 deletions

View file

@ -201,12 +201,7 @@ namespace Flow.Launcher.Plugin
/// <summary>
/// Progress bar display. Providing an int value between 0-100 will trigger the progress bar to be displayed on the result
/// </summary>
public int ProgressBarValue { get; set; }
/// <summary>
/// Progress bar visibility Check
/// </summary>
public bool IsProgressBarVisible { get; set; } = false;
public int? ProgressBar { get; set; }
/// <summary>
/// Optionally set the color of the progress bar

View file

@ -28,10 +28,6 @@
mc:Ignorable="d">
<!-- IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083 -->
<ListBox.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<Button HorizontalAlignment="Stretch">
@ -118,9 +114,18 @@
<ProgressBar
x:Name="progressbarResult"
Foreground="{Binding Result.ProgressBarColor}"
Style="{DynamicResource ProgressBarResult}"
Value="{Binding Result.ProgressBarValue}"
Visibility="{Binding Result.IsProgressBarVisible, Converter={StaticResource BooleanToVisibilityConverter}}"/>
Value="{Binding ResultProgress, Mode=OneWay}">
<ProgressBar.Style>
<Style TargetType="ProgressBar" BasedOn="{StaticResource ProgressBarResult}">
<Setter Property="Visibility" Value="Visible"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Result.ProgressBar}" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ProgressBar.Style>
</ProgressBar>
<TextBlock
x:Name="Title"
VerticalAlignment="Center"

View file

@ -162,6 +162,16 @@ namespace Flow.Launcher.ViewModel
}
public Result Result { get; }
public int ResultProgress
{
get
{
if (Result.ProgressBar == null)
return 0;
return Result.ProgressBar.Value;
}
}
public string QuerySuggestionText { get; set; }

View file

@ -100,8 +100,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder),
IcoPath = path,
Score = 500,
ProgressBarValue = progressValue,
IsProgressBarVisible = true,
ProgressBar = progressValue,
ProgressBarColor = progressBarColor,
Action = c =>
{