Skip to content

Commit 0baf04e

Browse files
committed
Merge branch 'dev' into QuickSizeAdjust & Work around dotnet/wpf#6792
1 parent 01c9be3 commit 0baf04e

File tree

9 files changed

+141
-9
lines changed

9 files changed

+141
-9
lines changed

Flow.Launcher.Plugin/Result.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,16 @@ public ValueTask<bool> ExecuteAsync(ActionContext context)
197197
{
198198
return AsyncAction?.Invoke(context) ?? ValueTask.FromResult(Action?.Invoke(context) ?? false);
199199
}
200+
201+
/// <summary>
202+
/// Progress bar display. Providing an int value between 0-100 will trigger the progress bar to be displayed on the result
203+
/// </summary>
204+
public int? ProgressBar { get; set; }
205+
206+
/// <summary>
207+
/// Optionally set the color of the progress bar
208+
/// </summary>
209+
/// <default>#26a0da (blue)</default>
210+
public string ProgressBarColor { get; set; } = "#26a0da";
200211
}
201212
}

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,14 @@
115115
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
116116
<Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" />
117117
</Target>
118+
119+
<Target Name="RemoveDuplicateAnalyzers" BeforeTargets="CoreCompile">
120+
<!-- Work around https://github.com/dotnet/wpf/issues/6792 -->
121+
122+
<ItemGroup>
123+
<FilteredAnalyzer Include="@(Analyzer->Distinct())" />
124+
<Analyzer Remove="@(Analyzer)" />
125+
<Analyzer Include="@(FilteredAnalyzer)" />
126+
</ItemGroup>
127+
</Target>
118128
</Project>

Flow.Launcher/ReportWindow.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ private Paragraph Hyperlink(string textBeforeUrl, string url)
7777
};
7878
link.Inlines.Add(url);
7979
link.NavigateUri = new Uri(url);
80-
link.RequestNavigate += (s, e) => SearchWeb.OpenInBrowserTab(e.Uri.ToString());
8180
link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url);
8281

8382
paragraph.Inlines.Add(textBeforeUrl);

Flow.Launcher/ResultListBox.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@
111111
<RowDefinition />
112112
<RowDefinition x:Name="SubTitleRowDefinition" Height="Auto" />
113113
</Grid.RowDefinitions>
114-
114+
<ProgressBar
115+
x:Name="progressbarResult"
116+
Foreground="{Binding Result.ProgressBarColor}"
117+
Style="{DynamicResource ProgressBarResult}"
118+
Value="{Binding Result.ProgressBar}" />
115119
<TextBlock
116120
x:Name="Title"
117121
VerticalAlignment="Center"

Flow.Launcher/Themes/Base.xaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,21 @@
8181

8282

8383
<!-- Item Style -->
84+
<Style x:Key="ProgressBarResult" TargetType="{x:Type ProgressBar}">
85+
<Setter Property="Height" Value="18" />
86+
<Setter Property="Margin" Value="0,0,0,4" />
87+
<Setter Property="VerticalAlignment" Value="Center" />
88+
<Setter Property="Maximum" Value="100" />
89+
<Setter Property="Minimum" Value="0" />
90+
<Setter Property="Visibility" Value="Visible" />
91+
<Setter Property="Foreground" Value="#26a0da " />
92+
<Style.Triggers>
93+
<DataTrigger Binding="{Binding Result.ProgressBar}" Value="{x:Null}">
94+
<Setter Property="Visibility" Value="Collapsed" />
95+
</DataTrigger>
96+
</Style.Triggers>
97+
</Style>
98+
8499
<Style x:Key="BaseItemTitleStyle" TargetType="{x:Type TextBlock}">
85100
<Setter Property="Foreground" Value="#FFFFF8" />
86101
<Setter Property="FontSize" Value="16" />

Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,92 @@ internal static Result CreateFolderResult(string title, string subtitle, string
7777
};
7878
}
7979

80+
internal static Result CreateDriveSpaceDisplayResult(string path, bool windowsIndexed = false)
81+
{
82+
var progressBarColor = "#26a0da";
83+
int? progressValue = null;
84+
var title = string.Empty; // hide title when use progress bar,
85+
var driveLetter = path.Substring(0, 1).ToUpper();
86+
var driveName = driveLetter + ":\\";
87+
DriveInfo drv = new DriveInfo(driveLetter);
88+
var subtitle = toReadableSize(drv.AvailableFreeSpace, 2) + " free of " + toReadableSize(drv.TotalSize, 2);
89+
double UsingSize = (Convert.ToDouble(drv.TotalSize) - Convert.ToDouble(drv.AvailableFreeSpace)) / Convert.ToDouble(drv.TotalSize) * 100;
90+
91+
progressValue = Convert.ToInt32(UsingSize);
92+
93+
if (progressValue >= 90)
94+
progressBarColor = "#da2626";
95+
96+
return new Result
97+
{
98+
Title = title,
99+
SubTitle = subtitle,
100+
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder),
101+
IcoPath = path,
102+
Score = 500,
103+
ProgressBar = progressValue,
104+
ProgressBarColor = progressBarColor,
105+
Action = c =>
106+
{
107+
Context.API.OpenDirectory(path);
108+
return true;
109+
},
110+
TitleToolTip = path,
111+
SubTitleToolTip = path,
112+
ContextData = new SearchResult
113+
{
114+
Type = ResultType.Folder,
115+
FullPath = path,
116+
ShowIndexState = true,
117+
WindowsIndexed = windowsIndexed
118+
}
119+
};
120+
}
121+
122+
private static string toReadableSize(long pDrvSize, int pi)
123+
{
124+
int mok = 0;
125+
double drvSize = pDrvSize;
126+
string Space = "Byte";
127+
128+
while (drvSize > 1024.0)
129+
{
130+
drvSize /= 1024.0;
131+
mok++;
132+
}
133+
134+
if (mok == 1)
135+
Space = "KB";
136+
else if (mok == 2)
137+
Space = " MB";
138+
else if (mok == 3)
139+
Space = " GB";
140+
else if (mok == 4)
141+
Space = " TB";
142+
143+
var returnStr = string.Format("{0}{1}", Convert.ToInt32(drvSize), Space);
144+
if (mok != 0)
145+
{
146+
switch (pi)
147+
{
148+
case 1:
149+
returnStr = string.Format("{0:F1}{1}", drvSize, Space);
150+
break;
151+
case 2:
152+
returnStr = string.Format("{0:F2}{1}", drvSize, Space);
153+
break;
154+
case 3:
155+
returnStr = string.Format("{0:F3}{1}", drvSize, Space);
156+
break;
157+
default:
158+
returnStr = string.Format("{0}{1}", Convert.ToInt32(drvSize), Space);
159+
break;
160+
}
161+
}
162+
163+
return returnStr;
164+
}
165+
80166
internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIndexed = false)
81167
{
82168
var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path);
@@ -208,4 +294,4 @@ public enum ResultType
208294
Folder,
209295
File
210296
}
211-
}
297+
}

Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,14 @@ public async Task<List<Result>> PathSearchAsync(Query query, CancellationToken t
123123

124124
var useIndexSearch = UseWindowsIndexForDirectorySearch(locationPath);
125125

126-
results.Add(ResultManager.CreateOpenCurrentFolderResult(locationPath, useIndexSearch));
126+
if (locationPath.EndsWith(":\\"))
127+
{
128+
results.Add(ResultManager.CreateDriveSpaceDisplayResult(locationPath, useIndexSearch));
129+
}
130+
else
131+
{
132+
results.Add(ResultManager.CreateOpenCurrentFolderResult(locationPath, useIndexSearch));
133+
}
127134

128135
token.ThrowIfCancellationRequested();
129136

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Flow.Launcher.Infrastructure.Logger;
1+
using Flow.Launcher.Infrastructure.Logger;
22
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
33
using Microsoft.Search.Interop;
44
using System;
@@ -17,7 +17,7 @@ internal static class IndexSearch
1717
{
1818

1919
// Reserved keywords in oleDB
20-
private const string reservedStringPattern = @"^[`\@\#\^,\&\/\\\$\%_;\[\]]+$";
20+
private const string reservedStringPattern = @"^[`\@\@\#\#\*\^,\&\&\/\\\$\%_;\[\]]+$";
2121

2222
internal static async Task<List<Result>> ExecuteWindowsIndexSearchAsync(string indexQueryString, string connectionString, Query query, CancellationToken token)
2323
{
@@ -29,7 +29,7 @@ internal static async Task<List<Result>> ExecuteWindowsIndexSearchAsync(string i
2929
await using var conn = new OleDbConnection(connectionString);
3030
await conn.OpenAsync(token);
3131
token.ThrowIfCancellationRequested();
32-
32+
3333
await using var command = new OleDbCommand(indexQueryString, conn);
3434
// Results return as an OleDbDataReader.
3535
await using var dataReaderResults = await command.ExecuteReaderAsync(token) as OleDbDataReader;

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "6.0.100",
4-
"rollForward": "latestFeature"
3+
"version": "6.0.*",
4+
"rollForward": "latestPatch"
55
}
66
}

0 commit comments

Comments
 (0)