Skip to content

Commit 7c494f3

Browse files
author
tznind
committed
Disable PreserveFilenameOnDirectoryChanges for now and add ability to launch Showcases on demand
1 parent ac19b1c commit 7c494f3

2 files changed

Lines changed: 48 additions & 3 deletions

File tree

Showcase/Program.cs

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,59 @@
11
using Terminal.Gui.App;
2+
using Terminal.Gui.Input;
3+
using Terminal.Gui.ViewBase;
4+
using Terminal.Gui.Views;
25

36
namespace Showcase
47
{
58
internal class Program
69
{
710
static void Main(string[] args)
811
{
9-
using(var app = Application.Create())
12+
Type[] types = [typeof(Menus)];
13+
14+
using (var app = Application.Create())
1015
{
11-
app.Run<Menus>();
16+
var tv = new TableView()
17+
{
18+
Width = Dim.Fill(),
19+
Height = Dim.Fill()
20+
};
21+
22+
tv.Table = new EnumerableTableSource<Type>(types,
23+
new Dictionary<string, Func<Type, object>> { { "Scenario (Enter to open, Esc to close/exit)", (t) => t.Name } }
24+
);
25+
26+
tv.KeyBindings.ReplaceCommands(Key.Enter,Command.Activate);
27+
28+
tv.Activating += (s, e) =>
29+
{
30+
var row = tv.Value.Cursor.Y;
31+
if (row >= 0 && row < types.Length)
32+
{
33+
var toCreate = types[row];
34+
View view = (View)Activator.CreateInstance(toCreate);
35+
36+
if(view is Runnable r)
37+
{
38+
app.Run(r);
39+
}
40+
else
41+
{
42+
var newRunnable = new Runnable();
43+
newRunnable.Add(view);
44+
app.Run(newRunnable);
45+
}
46+
47+
e.Handled = true;
48+
}
49+
};
50+
51+
var r = new Runnable();
52+
r.Add(tv);
53+
54+
app.Init();
55+
app.Run(r);
56+
app.Dispose();
1257
}
1358
}
1459
}

src/UI/Editor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ private void New()
13521352
AllowedTypes = new List<IAllowedType>() { new AllowedType("C# File", ".cs") },
13531353
Path = "MyView.cs",
13541354
};
1355-
ofd.Style.PreserveFilenameOnDirectoryChanges = true;
1355+
// ofd.Style.PreserveFilenameOnDirectoryChanges = true;
13561356

13571357
app.Run(ofd);
13581358

0 commit comments

Comments
 (0)