Skip to content

Commit 78129bd

Browse files
committed
Add delete functionality
1 parent 9efc906 commit 78129bd

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

SmartImage 3/App/Integration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public static bool ReadClipboard(out string str)
253253
if (!SearchQuery.IsValidSourceType(str)) {
254254
var o = Clipboard.GetData((uint) ClipboardFormat.CF_TEXT);
255255

256-
if (data is IntPtr { } p2 && p2 == IntPtr.Zero) {
256+
if ((data is IntPtr { } p2 && p2 == IntPtr.Zero) || o is IntPtr data2 && data2 == IntPtr.Zero) {
257257
str = null;
258258
}
259259
else {

SmartImage 3/Shell/UI.Styles.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,14 @@ internal static ColorScheme Make(Attribute norm, Attribute focus = default, Attr
111111
HotFocus = Atr_BrightBlue_Gray,
112112
Focus = Atr_BrightBlue_Gray
113113
};
114-
114+
internal static readonly ColorScheme Cs_Btn4 = new()
115+
{
116+
Normal = Atr_Red_White,
117+
// Disabled = Atr_DarkGray_White,
118+
HotNormal = Atr_Red_White,
119+
HotFocus = Atr_BrightRed_White,
120+
Focus = Atr_BrightRed_White
121+
};
115122
internal static readonly ColorScheme Cs_Elem2 = new()
116123
{
117124
Normal = Atr_White_Cyan,

SmartImage 3/ShellMain.cs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Runtime.Versioning;
1111
using Kantan.Net.Utilities;
1212
using Kantan.Text;
13+
using Microsoft.VisualBasic.FileIO;
1314
using Novus.Win32;
1415
using NStack;
1516
using SmartImage.App;
@@ -198,6 +199,26 @@ public sealed partial class ShellMain : IDisposable, IMain
198199

199200
};
200201

202+
private static readonly Button Btn_Queue = new("Queue")
203+
{
204+
X = Pos.X(Btn_Run),
205+
Y = Pos.Bottom(Btn_Run),
206+
207+
Height = Dim.Height(Btn_Run),
208+
ColorScheme = UI.Cs_Lbl1
209+
210+
};
211+
212+
private static readonly Button Btn_Delete = new("Delete")
213+
{
214+
X = Pos.X(Btn_Cancel),
215+
Y = Pos.Bottom(Btn_Cancel),
216+
217+
Height = Dim.Height(Btn_Cancel),
218+
ColorScheme = UI.Cs_Btn4
219+
220+
};
221+
201222
#endregion
202223

203224
#region Fields/properties
@@ -346,10 +367,23 @@ public ShellMain(string[] args)
346367
HttpUtilities.TryOpenUrl(Query.Upload);
347368
};
348369

370+
Btn_Delete.Clicked += () =>
371+
{
372+
var file = Tf_Input.Text.ToString();
373+
374+
if (!string.IsNullOrWhiteSpace(file)) {
375+
Query.Dispose();
376+
FileSystem.DeleteFile(file, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
377+
Debug.WriteLine($"deleted {file}");
378+
Clear();
379+
}
380+
381+
};
382+
349383
Win.Add(Lbl_Input, Tf_Input, Btn_Run, Lbl_InputOk,
350384
Btn_Clear, Tv_Results, Pbr_Status, Lbl_InputInfo, Lbl_QueryUpload,
351385
Btn_Restart, Btn_Config, Lbl_InputInfo2, Btn_Cancel, Lbl_Status, Btn_Browse,
352-
Lbl_Status2
386+
Lbl_Status2, Btn_Queue, Btn_Delete
353387
);
354388

355389
Top.Add(Win);
@@ -552,9 +586,9 @@ private async Task<bool> SetQuery(ustring text)
552586

553587
}
554588
else {
555-
UI.SetLabelStatus(Lbl_InputOk, false);
589+
Lbl_InputInfo.Text = "Error: invalid input";
556590

557-
Lbl_InputInfo.Text = "Error: invalid input";
591+
UI.SetLabelStatus(Lbl_InputOk, false);
558592
Btn_Run.Enabled = true;
559593
Lbl_QueryUpload.Text = ustring.Empty;
560594
Pbr_Status.Fraction = 0;

0 commit comments

Comments
 (0)