Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions AssetEditor/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ protected override void OnStartup(StartupEventArgs e)

var localizationManager = _serviceProvider.GetRequiredService<LocalizationManager>();
localizationManager.GetPossibleLanguages();
localizationManager.LoadLanguage("en");

// 读取保存的语言,如果为空则默认使用 "en"
var savedLanguage = settingsService.CurrentSettings.SelectedLangauge;
if (string.IsNullOrWhiteSpace(savedLanguage) || savedLanguage == "Not set")
{
savedLanguage = "en";
}
localizationManager.LoadLanguage(savedLanguage);
// Show the settings window if its the first time the tool is ran
if (settingsService.CurrentSettings.IsFirstTimeStartingApplication)
HandleFirstTimeSettings(uiCommandFactory, settingsService);
Expand Down
641 changes: 640 additions & 1 deletion AssetEditor/Language_Cn.json

Large diffs are not rendered by default.

637 changes: 635 additions & 2 deletions AssetEditor/Language_En.json

Large diffs are not rendered by default.

637 changes: 635 additions & 2 deletions AssetEditor/Language_Fr.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions AssetEditor/Themes/Controls.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<ResourceDictionary
<ResourceDictionary
x:Class="AssetEditor.Themes.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:loc="clr-namespace:Shared.Ui.Common;assembly=Shared.Ui"
xmlns:ap="clr-namespace:AssetEditor.Themes.Attached"
xmlns:themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2"
xmlns:windowstitlemenu="clr-namespace:AssetEditor.WindowsTitleMenu"
Expand Down Expand Up @@ -5589,7 +5590,7 @@
Grid.Column="2"
Width="46"
Style="{StaticResource TitleBarButtonStyle}"
ToolTip="Minimise"
ToolTip="{loc:Loc MainWindow.Titlebar.Minimise}"
VerticalAlignment="Stretch"
Height="Auto"
WindowChrome.IsHitTestVisibleInChrome="True"
Expand All @@ -5606,7 +5607,7 @@
Grid.Column="3"
Width="46"
Style="{StaticResource TitleBarButtonStyle}"
ToolTip="Maximise"
ToolTip="{loc:Loc MainWindow.Titlebar.Maximise}"
VerticalAlignment="Stretch"
Height="Auto"
WindowChrome.IsHitTestVisibleInChrome="True"
Expand All @@ -5623,7 +5624,7 @@
Grid.Column="4"
Width="46"
Style="{StaticResource TitleBarCloseButtonStyle}"
ToolTip="Close"
ToolTip="{loc:Loc MainWindow.Titlebar.Close}"
VerticalAlignment="Stretch"
Height="Auto"
WindowChrome.IsHitTestVisibleInChrome="True"
Expand Down
2 changes: 1 addition & 1 deletion AssetEditor/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public SettingsViewModel(ApplicationSettingsService settingsService, Localizatio
_localizationManager = localizationManager;

AvailableLangauges = new ObservableCollection<string>(_localizationManager.GetPossibleLanguages());
SelectedLanguage = _localizationManager.SelectedLangauge;
SelectedLanguage = _settingsService.CurrentSettings.SelectedLangauge;

AvailableThemes = new ObservableCollection<ThemeType>((ThemeType[])Enum.GetValues(typeof(ThemeType)));
CurrentTheme = _settingsService.CurrentSettings.Theme;
Expand Down
85 changes: 85 additions & 0 deletions AssetEditor/Views/CachedTabControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;

namespace AssetEditor.Views
{
[TemplatePart(Name = "PART_ItemsHolder", Type = typeof(Panel))]
public class CachedTabControl : TabControl
{
private Panel _itemsHolderPanel = null;

public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_itemsHolderPanel = GetTemplateChild("PART_ItemsHolder") as Panel;
UpdateSelectedItem();
}

protected override void OnSelectionChanged(SelectionChangedEventArgs e)
{
base.OnSelectionChanged(e);
UpdateSelectedItem();
}

private void UpdateSelectedItem()
{
if (_itemsHolderPanel == null) return;

object selectedItem = this.SelectedItem;
if (selectedItem == null) return;

ContentPresenter cp = FindChildContentPresenter(selectedItem);
if (cp == null)
{
cp = new ContentPresenter
{
Content = selectedItem,
ContentTemplate = this.SelectedContentTemplate,
ContentTemplateSelector = this.ContentTemplateSelector,
ContentStringFormat = this.SelectedContentStringFormat,
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch
};
_itemsHolderPanel.Children.Add(cp);
}

foreach (ContentPresenter child in _itemsHolderPanel.Children)
{
child.Visibility = (child.Content == selectedItem) ? Visibility.Visible : Visibility.Collapsed;
}
}

protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
{
base.OnItemsChanged(e);
if (_itemsHolderPanel == null) return;

if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Replace)
{
if (e.OldItems != null)
{
foreach (var item in e.OldItems)
{
var cp = FindChildContentPresenter(item);
if (cp != null) _itemsHolderPanel.Children.Remove(cp);
}
}
}
else if (e.Action == NotifyCollectionChangedAction.Reset)
{
_itemsHolderPanel.Children.Clear();
}
}

private ContentPresenter FindChildContentPresenter(object data)
{
if (_itemsHolderPanel == null) return null;
foreach (ContentPresenter cp in _itemsHolderPanel.Children)
{
if (cp.Content == data) return cp;
}
return null;
}
}
}
99 changes: 52 additions & 47 deletions AssetEditor/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Window x:Class="AssetEditor.Views.MainWindow"
<Window x:Class="AssetEditor.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand All @@ -12,7 +12,8 @@
xmlns:materialIcons="clr-namespace:Material.Icons.WPF;assembly=Material.Icons.WPF"
xmlns:viewmodels="clr-namespace:AssetEditor.ViewModels"
d:DataContext="{d:DesignInstance Type=viewmodels:MainViewModel}"
mc:Ignorable="d"
xmlns:loc="clr-namespace:Shared.Ui.Common;assembly=Shared.Ui"
mc:Ignorable="d"
behaviors:WindowCancellableClosingBehavior.Closing="{Binding ClosingCommand}"
behaviors:WindowCancellableClosingBehavior.IsClosingWithoutPrompt="{Binding IsClosingWithoutPrompt}"
Style="{StaticResource CustomWindowStyle}"
Expand Down Expand Up @@ -92,7 +93,7 @@
Width="46"
Click="OnMinimizeButtonClick"
Style="{StaticResource TitleBarButtonStyle}"
ToolTip="Minimise"
ToolTip="{loc:Loc MainWindow.Titlebar.Minimise}"
VerticalAlignment="Stretch"
Height="Auto">
<Path
Expand All @@ -109,7 +110,7 @@
Width="46"
Click="OnMaximizeRestoreButtonClick"
Style="{StaticResource TitleBarButtonStyle}"
ToolTip="Maximise"
ToolTip="{loc:Loc MainWindow.Titlebar.Maximise}"
ToolTipOpening="MaximizeRestoreButton_ToolTipOpening"
VerticalAlignment="Stretch"
Height="Auto">
Expand All @@ -126,7 +127,7 @@
Width="46"
Click="OnCloseButtonClick"
Style="{StaticResource TitleBarCloseButtonStyle}"
ToolTip="Close"
ToolTip="{loc:Loc MainWindow.Titlebar.Close}"
VerticalAlignment="Stretch"
Height="Auto">
<Path
Expand Down Expand Up @@ -158,28 +159,48 @@
<GridSplitter Grid.Row="1" Grid.RowSpan="1" Grid.Column="1" Width="2.9" HorizontalAlignment="Stretch" Background="{DynamicResource App.Border}"
Visibility="{Binding IsPackFileExplorerVisible, Converter={StaticResource BoolToVisibilityConverter}}"/>

<TabControl Grid.Row="1" Grid.Column="2" ItemsSource="{Binding EditorManager.CurrentEditorsList, UpdateSourceTrigger=PropertyChanged}"
<views:CachedTabControl Grid.Row="1" Grid.Column="2" ItemsSource="{Binding EditorManager.CurrentEditorsList, UpdateSourceTrigger=PropertyChanged}"
SelectedIndex="{Binding EditorManager.SelectedEditorIndex, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
ContentTemplateSelector="{StaticResource EditorSelector}" viewFactory:ToolFactoryParameter.ViewFactory="{Binding ToolsFactory}"
Name="EditorsTabControl" BorderThickness="1, 1, 0, 0" >
x:Name="EditorsTabControl" BorderThickness="1, 1, 0, 0" >

<TabControl.Resources>
<common:BindingProxy x:Key="Proxy" Data="{Binding}" />
</TabControl.Resources>
<views:CachedTabControl.Template>
<ControlTemplate TargetType="{x:Type views:CachedTabControl}">
<Grid KeyboardNavigation.TabNavigation="Local">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TabPanel x:Name="HeaderPanel" Panel.ZIndex="1" Margin="0,2,2,0" IsItemsHost="True" KeyboardNavigation.TabIndex="1" Background="Transparent" />
<Border x:Name="Border" Grid.Row="1"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{DynamicResource App.Border}"
Background="{DynamicResource TabItem.Static.Background}"
KeyboardNavigation.DirectionalNavigation="Contained"
KeyboardNavigation.TabIndex="2">
<Grid x:Name="PART_ItemsHolder" />
</Border>
</Grid>
</ControlTemplate>
</views:CachedTabControl.Template>

<views:CachedTabControl.Resources>
<common:BindingProxy x:Key="Proxy" Data="{Binding}" />
</views:CachedTabControl.Resources>

<TabControl.ItemContainerStyle>
<Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
<EventSetter Event="Drop" Handler="TabItem_Drop"/>
<EventSetter Event="PreviewMouseMove" Handler="TabItem_MouseMove"/>
<EventSetter Event="PreviewMouseDown" Handler="TabItem_MouseDown"/>
<Setter Property="AllowDrop" Value="True"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="behaviors:MouseMiddleClick.Command" Value="{Binding Source={StaticResource Proxy}, Path=Data.CloseToolCommand}"/>
<Setter Property="behaviors:MouseMiddleClick.CommandParameter" Value="{Binding}"/>
</Style>
</TabControl.ItemContainerStyle>
<views:CachedTabControl.ItemContainerStyle>
<Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
<EventSetter Event="Drop" Handler="TabItem_Drop"/>
<EventSetter Event="PreviewMouseMove" Handler="TabItem_MouseMove"/>
<EventSetter Event="PreviewMouseDown" Handler="TabItem_MouseDown"/>
<Setter Property="AllowDrop" Value="True"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="behaviors:MouseMiddleClick.Command" Value="{Binding Source={StaticResource Proxy}, Path=Data.CloseToolCommand}"/>
<Setter Property="behaviors:MouseMiddleClick.CommandParameter" Value="{Binding}"/>
</Style>
</views:CachedTabControl.ItemContainerStyle>

<TabControl.ItemTemplate>
<views:CachedTabControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.Resources>
Expand All @@ -193,22 +214,12 @@

<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="Close"
Command="{Binding Source={StaticResource Proxy}, Path=Data.CloseToolCommand}"
CommandParameter="{Binding Source={StaticResource GridProxy}, Path=Data}" />
<MenuItem Header="Close Multiple">
<MenuItem Header="Close Other Tabs"
Command="{Binding Source={StaticResource Proxy}, Path=Data.CloseOtherToolsCommand}"
CommandParameter="{Binding Source={StaticResource GridProxy}, Path=Data}"/>
<MenuItem Header="Close All Tabs"
Command="{Binding Source={StaticResource Proxy}, Path=Data.CloseAllToolsCommand}"
CommandParameter="{Binding Source={StaticResource GridProxy}, Path=Data}"/>
<MenuItem Header="Close Tabs To Left"
Command="{Binding Source={StaticResource Proxy}, Path=Data.CloseToolsToLeftCommand}"
CommandParameter="{Binding Source={StaticResource GridProxy}, Path=Data}"/>
<MenuItem Header="Close Tabs To Right"
Command="{Binding Source={StaticResource Proxy}, Path=Data.CloseToolsToRightCommand}"
CommandParameter="{Binding Source={StaticResource GridProxy}, Path=Data}"/>
<MenuItem Header="{loc:Loc MainWindow.Tabs.ContextMenu.Close}" Command="{Binding Source={StaticResource Proxy}, Path=Data.CloseToolCommand}" CommandParameter="{Binding Source={StaticResource GridProxy}, Path=Data}" />
<MenuItem Header="{loc:Loc MainWindow.Tabs.ContextMenu.CloseMultiple}">
<MenuItem Header="{loc:Loc MainWindow.Tabs.ContextMenu.CloseOtherTabs}" Command="{Binding Source={StaticResource Proxy}, Path=Data.CloseOtherToolsCommand}" CommandParameter="{Binding Source={StaticResource GridProxy}, Path=Data}"/>
<MenuItem Header="{loc:Loc MainWindow.Tabs.ContextMenu.CloseAllTabs}" Command="{Binding Source={StaticResource Proxy}, Path=Data.CloseAllToolsCommand}" CommandParameter="{Binding Source={StaticResource GridProxy}, Path=Data}"/>
<MenuItem Header="{loc:Loc MainWindow.Tabs.ContextMenu.CloseTabsToLeft}" Command="{Binding Source={StaticResource Proxy}, Path=Data.CloseToolsToLeftCommand}" CommandParameter="{Binding Source={StaticResource GridProxy}, Path=Data}"/>
<MenuItem Header="{loc:Loc MainWindow.Tabs.ContextMenu.CloseTabsToRight}" Command="{Binding Source={StaticResource Proxy}, Path=Data.CloseToolsToRightCommand}" CommandParameter="{Binding Source={StaticResource GridProxy}, Path=Data}"/>
</MenuItem>
</ContextMenu>
</Grid.ContextMenu>
Expand All @@ -224,18 +235,12 @@
</Style>
</TextBlock.Style>
</TextBlock>
<Button
Margin="4,0,-4,0"
Grid.Column="1"
Command="{Binding DataContext.CloseToolCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=TabControl}}"
CommandParameter="{Binding}"
HorizontalContentAlignment="Right"
Content="{materialIcons:MaterialIconExt Kind=CloseThick, Size=13 }">
<Button Margin="4,0,-4,0" Grid.Column="1" Command="{Binding DataContext.CloseToolCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=TabControl}}" CommandParameter="{Binding}" HorizontalContentAlignment="Right" Content="{materialIcons:MaterialIconExt Kind=CloseThick, Size=13 }">
</Button>
</Grid>
</DataTemplate>
</TabControl.ItemTemplate>
</TabControl>
</views:CachedTabControl.ItemTemplate>
</views:CachedTabControl>
</Grid>
</Border>

Expand Down
Loading
Loading