forked from Misaki/GhostEngine
Updating ProjectBrowser
This commit is contained in:
23
Ghost.Editor/View/Controls/ProjectBrowser.Menu.cs
Normal file
23
Ghost.Editor/View/Controls/ProjectBrowser.Menu.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Ghost.Editor.Core;
|
||||
|
||||
namespace Ghost.Editor.View.Controls;
|
||||
|
||||
internal partial class ProjectBrowser
|
||||
{
|
||||
[ContextMenuItem("project-browser", "Show in Explorer")]
|
||||
private static void ShowInExplorer()
|
||||
{
|
||||
var path = LastFocused?.ViewModel.CurrentDirectoryPath;
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
|
||||
{
|
||||
FileName = path,
|
||||
UseShellExecute = true,
|
||||
Verb = "open"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UserControl
|
||||
x:Class="Ghost.Editor.Controls.ProjectBrowser"
|
||||
x:Class="Ghost.Editor.View.Controls.ProjectBrowser"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:community="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:converter="using:Ghost.Editor.Utilities.Converters"
|
||||
xmlns:ctc="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:Ghost.Editor.Controls"
|
||||
xmlns:ghost="using:Ghost.Editor.Core.Controls"
|
||||
xmlns:local="using:Ghost.Editor.View.Controls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:model="using:Ghost.Editor.Models"
|
||||
xmlns:sys="using:System"
|
||||
@@ -164,13 +165,13 @@
|
||||
</MenuFlyout>
|
||||
</Grid.ContextFlyout>
|
||||
|
||||
<ctc:ConstrainedBox Grid.Row="0" AspectRatio="1:1">
|
||||
<community:ConstrainedBox Grid.Row="0" AspectRatio="1:1">
|
||||
<Image HorizontalAlignment="Center">
|
||||
<Image.Source>
|
||||
<BitmapImage DecodePixelWidth="48" UriSource="{x:Bind Converter={StaticResource ExplorerItemToIconUriConverter}}" />
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</ctc:ConstrainedBox>
|
||||
</community:ConstrainedBox>
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Center"
|
||||
@@ -190,7 +191,7 @@
|
||||
MinRowSpacing="4" />
|
||||
</ItemsView.Layout>
|
||||
<ItemsView.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<ghost:ContextFlyout Tag="project-browser">
|
||||
<MenuFlyoutSubItem Text="Create">
|
||||
<MenuFlyoutItem Text="Folder" />
|
||||
<MenuFlyoutItem Text="Script" />
|
||||
@@ -199,11 +200,8 @@
|
||||
<MenuFlyoutItem Text="Volume Profile" />
|
||||
</MenuFlyoutSubItem>
|
||||
</MenuFlyoutSubItem>
|
||||
<MenuFlyoutItem Text="Show in Explorer" />
|
||||
<MenuFlyoutSeparator />
|
||||
<MenuFlyoutItem Text="Refresh" />
|
||||
<MenuFlyoutItem Text="Reimport All" />
|
||||
</MenuFlyout>
|
||||
</ghost:ContextFlyout>
|
||||
</ItemsView.ContextFlyout>
|
||||
</ItemsView>
|
||||
|
||||
|
||||
@@ -3,11 +3,18 @@ using Ghost.Editor.Models;
|
||||
using Ghost.Editor.ViewModels.Controls;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
|
||||
namespace Ghost.Editor.Controls;
|
||||
namespace Ghost.Editor.View.Controls;
|
||||
|
||||
internal sealed partial class ProjectBrowser : UserControl
|
||||
{
|
||||
public static ProjectBrowser? LastFocused
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private readonly IInspectorService _inspectorService;
|
||||
private bool _isUpdatingSelection = false;
|
||||
|
||||
@@ -25,6 +32,18 @@ internal sealed partial class ProjectBrowser : UserControl
|
||||
|
||||
Loaded += ProjectBrowser_Loaded;
|
||||
Unloaded += ProjectBrowser_Unloaded;
|
||||
|
||||
GettingFocus += ProjectBrowser_GettingFocus;
|
||||
}
|
||||
|
||||
private void ProjectBrowser_GettingFocus(UIElement sender, GettingFocusEventArgs args)
|
||||
{
|
||||
if (_isUpdatingSelection)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LastFocused = this;
|
||||
}
|
||||
|
||||
private void ProjectBrowser_Loaded(object sender, RoutedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user