Skip to content

Commit 159754a

Browse files
committed
Toast notification; updates
1 parent 20ea043 commit 159754a

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

SmartImage.Lib/Searching/ImageResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ public void UpdateFrom(ImageResult result)
192192

193193
public async Task FindDirectImagesAsync()
194194
{
195-
if (Url is not null) {
195+
if (Url is not null && Direct == null) {
196196

197197
if (ImageHelper.IsDirect(Url.ToString())) {
198198
Direct = Url;
199-
199+
200200
}
201201
else {
202202
try {

SmartImage/Core/MainDialog.cs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using SimpleCore.Net;
1515
using SmartImage.Lib;
1616
using SmartImage.Utilities;
17+
1718
// ReSharper disable PossibleNullReferenceException
1819

1920
namespace SmartImage.Core
@@ -40,9 +41,13 @@ public static class MainDialog
4041

4142
internal static string ToToggleString(this bool b) => b ? Enabled : Disabled;
4243

43-
private static string GetFilterName(bool added) => $"Filter ({(added.ToToggleString())})";
44-
private static string GetName(string s,bool added) => $"{s} ({(added.ToToggleString())})";
45-
private static string GetContextMenuName(bool added) => $"Context menu ({(added.ToToggleString())})";
44+
private static string GetFilterName(bool added) => GetName("Filter", added);
45+
private static string GetNotificationName(bool added) => GetName("Notification", added);
46+
private static string GetNotificationImageName(bool added) => GetName("Notification image", added);
47+
private static string GetName(string s, bool added) => $"{s} ({(added.ToToggleString())})";
48+
49+
50+
private static string GetContextMenuName(bool added) => GetName("Context menu", added);
4651

4752
#endregion
4853

@@ -51,15 +56,15 @@ public static class MainDialog
5156
{
5257
new()
5358
{
54-
Name = ">>> Run <<<",
59+
Name = ">>> Run <<<",
5560
Color = ColorMain,
5661
Function = () =>
5762
{
5863
ImageQuery query = NConsole.ReadInput("Image file or direct URL", x =>
5964
{
6065
(bool url, bool file) = ImageQuery.IsUriOrFile(x);
6166
return !(url || file);
62-
},"Input must be file or direct image link");
67+
}, "Input must be file or direct image link");
6368

6469
Program.Config.Query = query;
6570
return true;
@@ -68,7 +73,7 @@ public static class MainDialog
6873

6974
new()
7075
{
71-
Name = "Engines",
76+
Name = "Engines",
7277
Color = ColorOther,
7378
Function = () =>
7479
{
@@ -109,24 +114,24 @@ public static class MainDialog
109114
},
110115
new()
111116
{
112-
Name = GetName("Notification",Program.Config.Notification),
117+
Name = GetNotificationName(Program.Config.Notification),
113118
Function = () =>
114119
{
115120
Program.Config.Notification = !Program.Config.Notification;
116121

117-
MainMenuOptions[4].Name = GetName("Notification",Program.Config.Notification);
122+
MainMenuOptions[4].Name = GetNotificationName(Program.Config.Notification);
118123
SaveAndUpdateConfig();
119124
return null;
120125
}
121126
},
122127
new()
123128
{
124-
Name = GetName("Notification",Program.Config.NotificationImage),
129+
Name = GetNotificationImageName(Program.Config.NotificationImage),
125130
Function = () =>
126131
{
127132
Program.Config.NotificationImage = !Program.Config.NotificationImage;
128133

129-
MainMenuOptions[5].Name = GetName("Notification",Program.Config.NotificationImage);
134+
MainMenuOptions[5].Name = GetNotificationImageName(Program.Config.NotificationImage);
130135
SaveAndUpdateConfig();
131136
return null;
132137
}
@@ -179,7 +184,7 @@ public static class MainDialog
179184
var di = new DirectoryInfo(Info.ExeLocation);
180185

181186
Console.WriteLine($"Executable location: {di.Parent.Name}");
182-
187+
183188
Console.WriteLine($"In path: {Info.IsAppFolderInPath}");
184189
Console.WriteLine($"Context menu added: {OSIntegration.IsContextMenuAdded}");
185190

@@ -216,7 +221,7 @@ public static class MainDialog
216221
{
217222
WebUtilities.OpenUrl(Info.Wiki);
218223

219-
224+
220225
return null;
221226
}
222227
},

SmartImage/Core/NConsoleFactory.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,16 @@ public static NConsoleOption Create(SearchResult result)
6767

6868
NConsoleProgress.Queue(cts);
6969

70-
result.OtherResults.AsParallel().ForAll(x =>
70+
Task.WaitAll(result.OtherResults.Select(async delegate (ImageResult f)
7171
{
72-
x.FindDirectImagesAsync();
73-
});
72+
await f.FindDirectImagesAsync();
7473

75-
result.PrimaryResult.UpdateFrom(result.OtherResults.First());
74+
}).ToArray());
75+
76+
77+
result.PrimaryResult = result.OtherResults.First();
78+
79+
//result.PrimaryResult.UpdateFrom(result.OtherResults.First());
7680

7781
cts.Cancel();
7882
cts.Dispose();

SmartImage/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ public static void ShowToast()
279279
var bestResult = Client.FindBestResult();
280280

281281
if (Config.NotificationImage) {
282+
Debug.WriteLine("Finding direct");
282283
var direct = Client.FindDirectResult();
283284
Debug.WriteLine(direct);
284285

0 commit comments

Comments
 (0)