Skip to content

Commit 412f179

Browse files
committed
v3.0.3 RC
1 parent dbbb3c1 commit 412f179

File tree

6 files changed

+221
-133
lines changed

6 files changed

+221
-133
lines changed

SmartImage 3/App/Integration.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public static bool ReadClipboard(out string str)
316316
return b;
317317
}
318318

319-
public static string[] OpenFile(OFN flags = 0)
319+
public static string[] OpenFile(OpenFileNameFlags flags = 0)
320320
{
321321
// Span<char> p1 = stackalloc char[1024];
322322
// Span<char> p2 = stackalloc char[512];
@@ -329,9 +329,9 @@ public static string[] OpenFile(OFN flags = 0)
329329
var p1p = p1.Pin();
330330
var p2p = p2.Pin();
331331

332-
var ofn = new OPENFILENAME
332+
var ofn = new OpenFileName
333333
{
334-
lStructSize = Marshal.SizeOf<OPENFILENAME>(),
334+
lStructSize = Marshal.SizeOf<OpenFileName>(),
335335
lpstrFilter = "All Files\0*.*\0\0",
336336
// lpstrFile = new string(p1),
337337
// lpstrFileTitle = new string(p2),
@@ -358,7 +358,7 @@ public static string[] OpenFile(OFN flags = 0)
358358

359359
var pd = Marshal.PtrToStringAuto((nint) p1p.Pointer);
360360

361-
if (!(flags.HasFlag(OFN.OFN_ALLOWMULTISELECT)) /*!Directory.Exists(pd)&&File.Exists(pd)*/) {
361+
if (!(flags.HasFlag(OpenFileNameFlags.OFN_ALLOWMULTISELECT)) /*!Directory.Exists(pd)&&File.Exists(pd)*/) {
362362
files.Add(pd);
363363
goto ret;
364364
}

SmartImage 3/Mode/Shell/Assets/UI.Styles.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,22 @@ internal static partial class UI
173173
Effect3D = true,
174174
};
175175

176+
internal static readonly ColorScheme Cs_Lbl1_Neutral = new ColorScheme()
177+
{
178+
Normal = Atr_BrightYellow_Black,
179+
HotNormal = Atr_BrightYellow_Black,
180+
Disabled = Cs_Lbl1.Disabled,
181+
Focus = Cs_Lbl1.Focus,
182+
HotFocus = Cs_Lbl1.HotFocus
183+
};
184+
internal static readonly ColorScheme Cs_Lbl1_Success = new ColorScheme()
185+
{
186+
Normal = Atr_BrightGreen_Black,
187+
HotNormal = Atr_BrightGreen_Black,
188+
Disabled = Cs_Lbl1.Disabled,
189+
Focus = Cs_Lbl1.Focus,
190+
HotFocus = Cs_Lbl1.HotFocus
191+
};
176192
internal static readonly Dim Dim_30_Pct = Dim.Percent(30);
177193
internal static readonly Dim Dim_80_Pct = Dim.Percent(80);
178194

@@ -198,4 +214,12 @@ internal static ColorScheme Make(Attribute norm, Attribute focus = default, Attr
198214
Disabled = disabled
199215
};
200216
}
217+
218+
internal static void WithScheme(this View v, Action<View> f, ColorScheme cs)
219+
{
220+
var buf = v.ColorScheme;
221+
v.ColorScheme = cs;
222+
f(v);
223+
v.ColorScheme = buf;
224+
}
201225
}

SmartImage 3/Mode/Shell/ShellMode.Dialog.cs

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#region
55

66
using System.Collections;
7+
using System.Collections.Concurrent;
78
using System.Data;
89
using System.Diagnostics;
910
using System.Runtime.CompilerServices;
@@ -396,4 +397,139 @@ void OnAction(ListView lv, Action<SearchEngineOptions> f)
396397
Tf_Input.SetFocus();
397398
Tf_Input.EnsureFocus();
398399
}
400+
401+
private void Queue_Dialog()
402+
{
403+
var d = new Dialog()
404+
{
405+
Title = $"Queue ({Queue.Count} items)",
406+
AutoSize = false,
407+
Width = Dim.Percent(60),
408+
Height = Dim.Percent(55),
409+
// Height = UI.Dim_80_Pct,
410+
};
411+
412+
var cpy = Queue.ToList();
413+
414+
var tf = new TextField()
415+
{
416+
Width = Dim.Fill(),
417+
Height = 2,
418+
};
419+
420+
var lv = new ListView(cpy)
421+
{
422+
Width = Dim.Fill(),
423+
Height = Dim.Fill(),
424+
Y = Pos.Bottom(tf),
425+
Border = new Border()
426+
{
427+
BorderStyle = BorderStyle.Rounded,
428+
BorderThickness = new Thickness(2)
429+
}
430+
};
431+
432+
/*var btnAdd = new Button("Add")
433+
{
434+
X = Pos.Right(tf),
435+
Y = Pos.Y(tf)
436+
};
437+
btnAdd.Clicked += () =>
438+
{
439+
var s = tf.Text.ToString();
440+
Queue.Enqueue(s);
441+
lv.Source = new ListWrapper(Queue.ToList());
442+
443+
};*/
444+
445+
var btnRm = new Button("Remove")
446+
{
447+
ColorScheme = UI.Cs_Btn3
448+
};
449+
450+
btnRm.Clicked += () =>
451+
{
452+
var cpy2 = lv.Source.ToList();
453+
454+
if (lv.SelectedItem < cpy2.Count && lv.SelectedItem >= 0) {
455+
var i = (string) cpy2[lv.SelectedItem];
456+
// Debug.WriteLine($"{i}");
457+
cpy.Remove(i);
458+
// Queue.Clear();
459+
Queue = new ConcurrentQueue<string>(cpy);
460+
lv.SetFocus();
461+
462+
}
463+
};
464+
465+
var btnRmAll = new Button("Clear")
466+
{
467+
ColorScheme = UI.Cs_Btn3
468+
};
469+
470+
btnRmAll.Clicked += () =>
471+
{
472+
lv.Source = new ListWrapper(Array.Empty<string>());
473+
Queue.Clear();
474+
lv.SetFocus();
475+
};
476+
477+
tf.TextChanged += delegate(ustring ustring)
478+
{
479+
Debug.WriteLine($"{ustring}");
480+
};
481+
482+
tf.TextChanging += a =>
483+
{
484+
485+
var s = a.NewText.ToString().CleanString().Trim('\"');
486+
487+
// Application.MainLoop.Invoke(() => Task.Delay(TimeSpan.FromSeconds(1)));
488+
if (SearchQuery.IsValidSourceType(s)) {
489+
Queue.Enqueue(s);
490+
lv.Source = new ListWrapper(Queue.ToList());
491+
/*tf.DeleteAll();
492+
tf.Text = ustring.Empty;
493+
a.Cancel = false;
494+
a.NewText = ustring.Empty;
495+
tf.DeleteAll();*/
496+
tf.DeleteAll();
497+
Debug.WriteLine($"{tf.Text} {s}");
498+
// tf.Text = ustring.Empty;
499+
// a.NewText = ustring.Empty;
500+
// tf.SetFocus();
501+
// tf.SetNeedsDisplay();
502+
Application.MainLoop.Invoke(() => Action(tf));
503+
tf.Text = ustring.Empty;
504+
505+
Debug.WriteLine($"{tf.Text} {a.NewText}");
506+
}
507+
};
508+
509+
static void Action(TextField tf)
510+
{
511+
Debug.WriteLine($"clearing");
512+
// Task.Delay(TimeSpan.FromSeconds(3));
513+
// tf.Text = ustring.Empty;
514+
// tf.CursorPosition = 0;
515+
tf.DeleteAll();
516+
tf.ClearHistoryChanges();
517+
tf.ClearAllSelection();
518+
tf.SetNeedsDisplay();
519+
Debug.WriteLine($"cleared");
520+
}
521+
522+
var btnOk = new Button("Ok")
523+
{
524+
ColorScheme = UI.Cs_Btn3
525+
};
526+
btnOk.Clicked += () => { Application.RequestStop(); };
527+
528+
d.Add(tf, lv);
529+
d.AddButton(btnRm);
530+
d.AddButton(btnRmAll);
531+
d.AddButton(btnOk);
532+
533+
Application.Run(d);
534+
}
399535
}

0 commit comments

Comments
 (0)