mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix up styling, naming header and show icons
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:wj="clr-namespace:Wabbajack"
|
||||
xmlns:ic="clr-namespace:FluentIcons.WPF;assembly=FluentIcons.WPF"
|
||||
xmlns:math="http://hexinnovation.com/math"
|
||||
mc:Ignorable="d">
|
||||
@ -2274,6 +2275,97 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type wj:FileTreeViewItemVM}">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="MinHeight" Value="21" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
|
||||
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
|
||||
<Setter Property="Padding" Value="4,6,4,6" />
|
||||
<Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
|
||||
<Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TreeViewItem}">
|
||||
<ControlTemplate.Resources>
|
||||
<darkBlendTheme:LeftMarginMultiplierConverter x:Key="LengthConverter" Length="30" />
|
||||
</ControlTemplate.Resources>
|
||||
<StackPanel>
|
||||
<Border
|
||||
Name="Bd"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}">
|
||||
<Grid Margin="{Binding Converter={StaticResource LengthConverter}, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="15" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ToggleButton Grid.Column="0"
|
||||
x:Name="Expander"
|
||||
ClickMode="Press"
|
||||
IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Style="{DynamicResource TreeViewToggleButtonStyle}" />
|
||||
|
||||
<StackPanel Orientation="Horizontal" Grid.Column="1">
|
||||
<ic:SymbolIcon IsFilled="True" Symbol="{Binding Path=Symbol, RelativeSource={RelativeSource TemplatedParent}}" Margin="0, 0, 4, 0" Foreground="{StaticResource PrimaryBrush}"/>
|
||||
<ContentPresenter
|
||||
x:Name="PART_Header"
|
||||
Margin="4, 0, 0, 0"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
ContentSource="Header" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ItemsPresenter x:Name="ItemsHost" />
|
||||
</StackPanel>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsExpanded" Value="false">
|
||||
<Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed" />
|
||||
</Trigger>
|
||||
<Trigger Property="HasItems" Value="false">
|
||||
<Setter TargetName="Expander" Property="Visibility" Value="Hidden" />
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="HasHeader" Value="false" />
|
||||
<Condition Property="Width" Value="Auto" />
|
||||
</MultiTrigger.Conditions>
|
||||
|
||||
</MultiTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="HasHeader" Value="false" />
|
||||
<Condition Property="Height" Value="Auto" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter TargetName="PART_Header" Property="MinHeight" Value="21" />
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter TargetName="Bd" Property="Background" Value="{StaticResource SelectedListItem}" />
|
||||
<Setter Property="Foreground" Value="{StaticResource SelectedListItemForeground}" />
|
||||
<Setter TargetName="Expander" Property="Style" Value="{DynamicResource TreeViewSelectedToggleButtonStyle}" />
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition SourceName="Bd" Property="IsMouseOver" Value="true" />
|
||||
<Condition Property="IsSelected" Value="false" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter TargetName="Bd" Property="Background" Value="{StaticResource MouseOverListItem}" />
|
||||
</MultiTrigger>
|
||||
<!--<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsSelected" Value="true"/>
|
||||
<Condition Property="IsSelectionActive" Value="false"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
||||
</MultiTrigger>-->
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{StaticResource TreeViewDisabledForeground}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="TreeViewToggleButtonStyle" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="Template">
|
||||
|
@ -30,9 +30,37 @@ using Wabbajack.RateLimiter;
|
||||
using Wabbajack.Services.OSIntegrated;
|
||||
using NexusMods.Paths.FileTree;
|
||||
using System.Windows.Controls;
|
||||
using FluentIcons.Common;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public class FileTreeViewItemVM : TreeViewItem
|
||||
{
|
||||
public FileSystemInfo Info { get; set; }
|
||||
public bool IsDirectory { get; set; }
|
||||
public Symbol Symbol { get; set; }
|
||||
public FileTreeViewItemVM(DirectoryInfo info)
|
||||
{
|
||||
Info = info;
|
||||
IsDirectory = true;
|
||||
Header = info.Name;
|
||||
Symbol = Symbol.Folder;
|
||||
}
|
||||
public FileTreeViewItemVM(FileInfo info)
|
||||
{
|
||||
Info = info;
|
||||
Header = info.Name;
|
||||
Symbol = info.Extension.ToLower() switch {
|
||||
".exe" or ".sh" => Symbol.DocumentLightning,
|
||||
".7z" or ".zip" or ".rar" or ".bsa" => Symbol.Archive,
|
||||
".toml" or ".ini" or ".cfg" or ".json" => Symbol.DocumentSettings,
|
||||
".txt" or ".md" => Symbol.DocumentText,
|
||||
".nif" => Symbol.DocumentCube,
|
||||
_ => Symbol.Document
|
||||
};
|
||||
}
|
||||
public override string ToString() => Info.FullName;
|
||||
}
|
||||
public class CompilerFileManagerVM : BackNavigatingVM
|
||||
{
|
||||
private readonly DTOSerializer _dtos;
|
||||
@ -76,9 +104,8 @@ namespace Wabbajack
|
||||
|
||||
private IEnumerable<TreeViewItem> LoadFiles(DirectoryInfo parent)
|
||||
{
|
||||
var parentTreeItem = new TreeViewItem()
|
||||
var parentTreeItem = new FileTreeViewItemVM(parent)
|
||||
{
|
||||
Header = parent,
|
||||
IsExpanded = true,
|
||||
ItemsSource = LoadDirectoryContents(parent)
|
||||
};
|
||||
@ -90,22 +117,22 @@ namespace Wabbajack
|
||||
{
|
||||
return parent.EnumerateDirectories()
|
||||
.OrderBy(dir => dir.Name)
|
||||
.Select(dir => new TreeViewItem() { Header = dir, ItemsSource = (dir.EnumerateDirectories().Any() || dir.EnumerateFiles().Any()) ? new ObservableCollection<TreeViewItem>([new TreeViewItem() { Header = "Loading..." }]) : null}).Select(item => {
|
||||
.Select(dir => new FileTreeViewItemVM(dir) { ItemsSource = (dir.EnumerateDirectories().Any() || dir.EnumerateFiles().Any()) ? new ObservableCollection<TreeViewItem>([new TreeViewItem() { Header = "Loading..." }]) : null}).Select(item => {
|
||||
item.Expanded += LoadingItem_Expanded;
|
||||
return item;
|
||||
})
|
||||
.Concat(parent.EnumerateFiles()
|
||||
.OrderBy(file => file.Name)
|
||||
.Select(file => new TreeViewItem() { Header = file }));
|
||||
.Select(file => new FileTreeViewItemVM(file)));
|
||||
}
|
||||
|
||||
private void LoadingItem_Expanded(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
var parent = (TreeViewItem)e.OriginalSource;
|
||||
var parent = (FileTreeViewItemVM)e.OriginalSource;
|
||||
var children = parent.ItemsSource.OfType<TreeViewItem>();
|
||||
var firstChild = children.Any() ? children.First().Header : null;
|
||||
if (firstChild != null && firstChild is string firstString && firstString == "Loading...")
|
||||
parent.ItemsSource = LoadDirectoryContents((DirectoryInfo)parent.Header);
|
||||
parent.ItemsSource = LoadDirectoryContents((DirectoryInfo)parent.Info);
|
||||
}
|
||||
|
||||
private IEnumerable<FileSystemInfo> GetDirectoryContents(DirectoryInfo dir)
|
||||
|
Reference in New Issue
Block a user