Skip to content

Commit 41d95d3

Browse files
committed
UI adjustments
1 parent dbd318a commit 41d95d3

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

SmartImage/Engines/BasicSearchEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace SmartImage.Engines
66
{
77
public abstract class BasicSearchEngine : ISearchEngine
88
{
9-
protected readonly string BaseUrl;
9+
public string BaseUrl { get; }
1010

1111
protected BasicSearchEngine(string baseUrl)
1212
{

SmartImage/Searching/FullSearchResult.cs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Diagnostics;
6+
using System.Diagnostics.CodeAnalysis;
67
using System.Drawing;
78
using System.IO;
89
using System.Linq;
@@ -25,30 +26,36 @@ namespace SmartImage.Searching
2526
public sealed class FullSearchResult : NConsoleOption, ISearchResult
2627
{
2728
public FullSearchResult(ISearchEngine engine, string url, float? similarity = null)
28-
: this(engine.Engine, engine.Color, engine.Name, url, similarity) { }
29+
: this(engine, engine.Color, engine.Name, url, similarity) { }
2930

30-
public FullSearchResult(SearchEngineOptions src, Color color, string name, string url, float? similarity = null)
31+
public FullSearchResult(ISearchEngine src, Color color, string name, string url, float? similarity = null)
3132
{
32-
Engine = src;
33+
SearchEngine = src;
3334
Url = url;
3435
Name = name;
3536
Color = color;
3637

3738
Similarity = similarity;
3839
ExtendedInfo = new List<string>();
3940
ExtendedResults = new List<FullSearchResult>();
40-
4141
}
4242

43+
44+
private FullSearchResult(Color color, string name, string url, float? similarity = null)
45+
: this(null, color, name, url, similarity) { }
46+
47+
4348
/// <summary>
4449
/// Engine
4550
/// </summary>
46-
public SearchEngineOptions Engine { get; }
51+
public ISearchEngine SearchEngine { get; }
4752

4853
/// <summary>
4954
/// Whether this result is a result from a priority engine (<see cref="SearchConfig.PriorityEngines"/>)
5055
/// </summary>
51-
public bool IsPriority => SearchConfig.Config.PriorityEngines.HasFlag(Engine);
56+
public bool IsPriority => !IsOriginal && SearchConfig.Config.PriorityEngines.HasFlag(SearchEngine.Engine) &&
57+
SearchEngine.Engine != SearchEngineOptions.None;
58+
5259

5360
public bool IsAnalyzed { get; set; }
5461

@@ -91,8 +98,7 @@ public override NConsoleFunction CtrlFunction
9198
NConsole.WriteSuccess("Downloading...");
9299

93100

94-
95-
string? path = Network.DownloadUrl(Url);
101+
string? path = Network.DownloadUrl(Url);
96102

97103
NConsole.WriteSuccess("Downloaded to {0}", path);
98104

@@ -207,6 +213,8 @@ public void AddExtendedResults(ISearchResult[] bestImages)
207213

208214
}
209215

216+
public bool IsOriginal { get; set; }
217+
210218
public override string ToString()
211219
{
212220
var sb = new StringBuilder();
@@ -237,9 +245,15 @@ public override string ToString()
237245
sb.Append($"\tResult: {Url}\n");
238246
}
239247

248+
// var rurl = Engine is BasicSearchEngine bse ? bse.BaseUrl: RawUrl;
249+
//
250+
// if (rurl!=null) {
251+
// sb.Append($"\tRaw: {rurl + Formatting.ELLIPSES}\n");
252+
// }
253+
240254
AddInfoSafe(sb, RawUrl, "Raw");
241255

242-
if (Similarity.HasValue) {
256+
if (Similarity.HasValue && !IsOriginal) {
243257
sb.Append($"\tSimilarity: {Similarity / 100:P}\n");
244258
}
245259

@@ -286,7 +300,7 @@ public void UpdateFrom(ISearchResult result)
286300

287301
private FullSearchResult CreateExtendedResult(ISearchResult result)
288302
{
289-
var sr = new FullSearchResult(Engine, Color, Name, result.Url, result.Similarity)
303+
var sr = new FullSearchResult(SearchEngine, Color, Name, result.Url, result.Similarity)
290304
{
291305
Width = result.Width,
292306
Height = result.Height,
@@ -351,8 +365,9 @@ public static int CompareResults(FullSearchResult x, FullSearchResult y)
351365
/// </summary>
352366
public static FullSearchResult GetOriginalImageResult(string imageUrl, FileInfo imageFile)
353367
{
354-
var result = new FullSearchResult(SearchEngineOptions.None, Color.White, ORIGINAL_IMAGE_NAME, imageUrl)
368+
var result = new FullSearchResult(Color.White, ORIGINAL_IMAGE_NAME, imageUrl)
355369
{
370+
IsOriginal = true,
356371
Similarity = 100.0f,
357372
IsAnalyzed = true,
358373
};

0 commit comments

Comments
 (0)