Update ContextFlyout
This commit is contained in:
@@ -20,4 +20,34 @@ internal partial class ProjectBrowser
|
||||
Verb = "open"
|
||||
});
|
||||
}
|
||||
|
||||
[ContextMenuItem("project-browser", "Create/Folder")]
|
||||
private static void CreateFolder()
|
||||
{
|
||||
// TODO: Use AssetService
|
||||
|
||||
var viewModel = LastFocused?.ViewModel;
|
||||
if (viewModel is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var currentDir = viewModel.CurrentDirectoryPath;
|
||||
if (!Directory.Exists(currentDir))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var newFolderPath = Path.Combine(currentDir, "New Folder");
|
||||
var folderIndex = 1;
|
||||
while (Directory.Exists(newFolderPath))
|
||||
{
|
||||
newFolderPath = Path.Combine(currentDir, $"New Folder ({folderIndex})");
|
||||
folderIndex++;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(newFolderPath);
|
||||
// Refresh the view model to show the new folder
|
||||
viewModel.NavigateToDirectory(currentDir);
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,8 @@
|
||||
Padding="8"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
RowSpacing="4">
|
||||
RowSpacing="4"
|
||||
ToolTipService.ToolTip="{x:Bind Name}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
@@ -191,17 +192,7 @@
|
||||
MinRowSpacing="4" />
|
||||
</ItemsView.Layout>
|
||||
<ItemsView.ContextFlyout>
|
||||
<ghost:ContextFlyout Tag="project-browser">
|
||||
<MenuFlyoutSubItem Text="Create">
|
||||
<MenuFlyoutItem Text="Folder" />
|
||||
<MenuFlyoutItem Text="Script" />
|
||||
<MenuFlyoutSubItem Text="Rendering">
|
||||
<MenuFlyoutItem Text="Material" />
|
||||
<MenuFlyoutItem Text="Volume Profile" />
|
||||
</MenuFlyoutSubItem>
|
||||
</MenuFlyoutSubItem>
|
||||
<MenuFlyoutSeparator />
|
||||
</ghost:ContextFlyout>
|
||||
<ghost:ContextFlyout Tag="project-browser" />
|
||||
</ItemsView.ContextFlyout>
|
||||
</ItemsView>
|
||||
|
||||
|
||||
@@ -54,6 +54,11 @@ internal sealed partial class ProjectBrowser : UserControl
|
||||
private void ProjectBrowser_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_inspectorService.OnSelectionChanged -= _inspectorService_OnSelectionChanged;
|
||||
|
||||
if (LastFocused == this)
|
||||
{
|
||||
LastFocused = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void _inspectorService_OnSelectionChanged(object? sender, InspectorSelectionChangedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user