|
|
@@ -42,13 +42,17 @@ namespace ControlCatalog.Pages
|
|
|
|
|
|
this.FindControl<Button>("OpenFile").Click += async delegate
|
|
|
{
|
|
|
+ // Almost guaranteed to exist
|
|
|
+ var fullPath = Assembly.GetEntryAssembly()?.GetModules().FirstOrDefault()?.FullyQualifiedName;
|
|
|
+ var initialFileName = fullPath == null ? null : System.IO.Path.GetFileName(fullPath);
|
|
|
+ var initialDirectory = fullPath == null ? null : System.IO.Path.GetDirectoryName(fullPath);
|
|
|
+
|
|
|
var result = await new OpenFileDialog()
|
|
|
{
|
|
|
Title = "Open file",
|
|
|
Filters = GetFilters(),
|
|
|
- Directory = lastSelectedDirectory,
|
|
|
- // Almost guaranteed to exist
|
|
|
- InitialFileName = Assembly.GetEntryAssembly()?.GetModules().FirstOrDefault()?.FullyQualifiedName
|
|
|
+ Directory = initialDirectory,
|
|
|
+ InitialFileName = initialFileName
|
|
|
}.ShowAsync(GetWindow());
|
|
|
results.Items = result;
|
|
|
resultsVisible.IsVisible = result?.Any() == true;
|
|
|
@@ -84,7 +88,12 @@ namespace ControlCatalog.Pages
|
|
|
Title = "Select folder",
|
|
|
Directory = lastSelectedDirectory,
|
|
|
}.ShowAsync(GetWindow());
|
|
|
- lastSelectedDirectory = result;
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(result))
|
|
|
+ {
|
|
|
+ lastSelectedDirectory = result;
|
|
|
+ }
|
|
|
+
|
|
|
results.Items = new [] { result };
|
|
|
resultsVisible.IsVisible = result != null;
|
|
|
};
|