Modern UI, Loading screen CanRunMessages

This commit is contained in:
2022-02-03 16:49:45 +01:00
parent 1319d0bb98
commit 2ff1aa366e
34 changed files with 913 additions and 563 deletions

Binary file not shown.

View File

@@ -9,7 +9,7 @@
<Application.Resources>
<ResourceDictionary>
<Color x:Key="AppBackgroundColor">#073642</Color>
<Color x:Key="AppBackgroundColor">#E7073642</Color>
<Color x:Key="ContainerBackgroundColor">#083e4c</Color>
<Color x:Key="TransparentContainerBackgroundColor">#D0083e4c</Color>
@@ -36,8 +36,8 @@
<GradientStop Offset="0.5" Color="#93a1a1" />
<GradientStop Offset="1" Color="#0093a1a1" />
</LinearGradientBrush>
<SolidColorBrush
x:Key="AppBackgroundBrush"
@@ -127,12 +127,13 @@
<converters:IsEmptyConverter x:Key="IsEmptyConverter"/>
<converters:IsEmptyConverter x:Key="IsNotEmptyConverter" Inverse="true"/>
<converters:ExceptionToStringConverter x:Key="ExceptionToStringConverter"/>
<converters:BoolInverter x:Key="BoolInverter"/>
</ResourceDictionary>
</Application.Resources>
<Application.Styles>
<FluentTheme Mode="Light"/>
<FluentTheme Mode="Dark"/>
<Style Selector="TextBlock">
<Setter Property="Foreground" Value="{DynamicResource ForegroundBrush}"/>

View File

@@ -34,7 +34,7 @@ namespace FileTime.Avalonia
{
desktop.MainWindow = new MainWindow
{
ViewModel = ServiceProvider.GetService<MainPageViewModel>(),
DataContext = new MainPageLoadingViewModel(),
};
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Globalization;
using Avalonia.Data.Converters;
namespace FileTime.Avalonia.Converters
{
public class BoolInverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value is bool b ? !b : value;
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -46,15 +46,19 @@ namespace FileTime.Avalonia.Services
{
if (!File.Exists(_settingsPath)) return;
using var stateReader = File.OpenRead(_settingsPath);
var state = await JsonSerializer.DeserializeAsync<PersistenceRoot>(stateReader);
if (state != null)
try
{
await RestoreTabs(state.TabStates);
using var stateReader = File.OpenRead(_settingsPath);
var state = await JsonSerializer.DeserializeAsync<PersistenceRoot>(stateReader);
if (state != null)
{
await RestoreTabs(state.TabStates);
}
}
catch { }
}
public async Task SaveStatesAsync()
public void SaveStatesAsync()
{
var state = new PersistenceRoot
{
@@ -62,8 +66,8 @@ namespace FileTime.Avalonia.Services
};
var settingsDirectory = new DirectoryInfo(string.Join(Path.DirectorySeparatorChar, _settingsPath.Split(Path.DirectorySeparatorChar)[0..^1]));
if (!settingsDirectory.Exists) settingsDirectory.Create();
using var stateWriter = File.OpenWrite(_settingsPath);
await JsonSerializer.SerializeAsync(stateWriter, state, _jsonOptions);
var serializedData = JsonSerializer.Serialize(state, _jsonOptions);
File.WriteAllText(_settingsPath, serializedData);
}
private TabStates SerializeTabStates()
@@ -83,49 +87,54 @@ namespace FileTime.Avalonia.Services
private async Task<bool> RestoreTabs(TabStates? tabStates)
{
if (tabStates == null
|| tabStates.Tabs == null)
try
{
return false;
}
foreach (var tab in tabStates.Tabs)
{
if (tab.Path == null) continue;
IItem? pathItem = null;
foreach (var contentProvider in _contentProviders)
if (tabStates == null
|| tabStates.Tabs == null)
{
if (contentProvider.CanHandlePath(tab.Path))
{
pathItem = await contentProvider.GetByPath(tab.Path, true);
if (pathItem != null) break;
}
return false;
}
var container = pathItem switch
foreach (var tab in tabStates.Tabs)
{
IContainer c => c,
IElement e => e.GetParent(),
_ => null
};
if (container == null) continue;
if (tab.Path == null) continue;
var newTab = new Tab();
await newTab.Init(container);
IItem? pathItem = null;
foreach (var contentProvider in _contentProviders)
{
if (contentProvider.CanHandlePath(tab.Path))
{
pathItem = await contentProvider.GetByPath(tab.Path, true);
if (pathItem != null) break;
}
}
var newTabContainer = new TabContainer(newTab, _localContentProvider, _itemNameConverterService);
await newTabContainer.Init(tab.Number);
_appState.Tabs.Add(newTabContainer);
var container = pathItem switch
{
IContainer c => c,
IElement e => e.GetParent(),
_ => null
};
if (container == null) continue;
var newTab = new Tab();
await newTab.Init(container);
var newTabContainer = new TabContainer(newTab, _localContentProvider, _itemNameConverterService);
await newTabContainer.Init(tab.Number);
_appState.Tabs.Add(newTabContainer);
}
if (_appState.Tabs.FirstOrDefault(t => t.TabNumber == tabStates.ActiveTabNumber) is TabContainer tabContainer)
{
_appState.SelectedTab = tabContainer;
}
return true;
}
if (_appState.Tabs.FirstOrDefault(t => t.TabNumber == tabStates.ActiveTabNumber) is TabContainer tabContainer)
{
_appState.SelectedTab = tabContainer;
}
return true;
catch { }
return false;
}
}
}

View File

@@ -0,0 +1,7 @@
namespace FileTime.Avalonia.ViewModels
{
public interface IMainPageViewModelBase
{
bool Loading { get; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileTime.Avalonia.ViewModels
{
public class MainPageLoadingViewModel : IMainPageViewModelBase
{
public bool Loading => true;
}
}

View File

@@ -34,14 +34,14 @@ namespace FileTime.Avalonia.ViewModels
[Inject(typeof(AppState), PropertyAccessModifier = AccessModifier.Public)]
[Inject(typeof(StatePersistenceService), PropertyName = "StatePersistence", PropertyAccessModifier = AccessModifier.Public)]
[Inject(typeof(ItemNameConverterService))]
public partial class MainPageViewModel
public partial class MainPageViewModel : IMainPageViewModelBase
{
const string RAPIDTRAVEL = "rapidTravel";
private readonly List<KeyWithModifiers> _previousKeys = new List<KeyWithModifiers>();
private readonly List<KeyWithModifiers[]> _keysToSkip = new List<KeyWithModifiers[]>();
private List<CommandBinding> _commandBindings = new();
private List<CommandBinding> _universalCommandBindings = new();
private readonly List<KeyWithModifiers> _previousKeys = new();
private readonly List<KeyWithModifiers[]> _keysToSkip = new();
private readonly List<CommandBinding> _commandBindings = new();
private readonly List<CommandBinding> _universalCommandBindings = new();
private IClipboard _clipboard;
private TimeRunner _timeRunner;
@@ -80,6 +80,9 @@ namespace FileTime.Avalonia.ViewModels
[Property]
private List<CommandBinding> _allShortcut;
[Property]
private bool _loading = true;
public ObservableCollection<ParallelCommandsViewModel> TimelineCommands { get; } = new();
async partial void OnInitialize()
@@ -192,6 +195,8 @@ namespace FileTime.Avalonia.ViewModels
throw new Exception("TODO linux places");
}
Places = places;
await Task.Delay(100);
Loading = false;
}
private void UpdateParalellCommands(object? sender, EventArgs e)
@@ -229,7 +234,7 @@ namespace FileTime.Avalonia.ViewModels
return await LocalContentProvider.GetByPath(drive.Name) as IContainer;
}
public async Task OpenContainer()
private async Task OpenContainer()
{
AppState.RapidTravelText = "";
await AppState.SelectedTab.Open();
@@ -241,7 +246,7 @@ namespace FileTime.Avalonia.ViewModels
await AppState.SelectedTab.OpenContainer(container);
}
public async Task OpenOrRun()
private async Task OpenOrRun()
{
if (AppState.SelectedTab.SelectedItem is ContainerViewModel)
{
@@ -258,57 +263,57 @@ namespace FileTime.Avalonia.ViewModels
}
}
public async Task GoUp()
private async Task GoUp()
{
await AppState.SelectedTab.GoUp();
}
public async Task MoveCursorUp()
private async Task MoveCursorUp()
{
await AppState.SelectedTab.MoveCursorUp();
}
public async Task MoveCursorDown()
private async Task MoveCursorDown()
{
await AppState.SelectedTab.MoveCursorDown();
}
public async Task MoveCursorUpPage()
private async Task MoveCursorUpPage()
{
await AppState.SelectedTab.MoveCursorUpPage();
}
public async Task MoveCursorDownPage()
private async Task MoveCursorDownPage()
{
await AppState.SelectedTab.MoveCursorDownPage();
}
public async Task MoveToFirst()
private async Task MoveToFirst()
{
await AppState.SelectedTab.MoveCursorToFirst();
}
public async Task MoveToLast()
private async Task MoveToLast()
{
await AppState.SelectedTab.MoveCursorToLast();
}
public async Task GotToProvider()
private async Task GotToProvider()
{
await AppState.SelectedTab.GotToProvider();
}
public async Task GotToRoot()
private async Task GotToRoot()
{
await AppState.SelectedTab.GotToRoot();
}
public async Task GotToHome()
private async Task GotToHome()
{
await AppState.SelectedTab.GotToHome();
}
public Task EnterRapidTravelMode()
private Task EnterRapidTravelMode()
{
AppState.ViewMode = ViewMode.RapidTravel;
@@ -318,7 +323,7 @@ namespace FileTime.Avalonia.ViewModels
return Task.CompletedTask;
}
public async Task ExitRapidTravelMode()
private async Task ExitRapidTravelMode()
{
AppState.ViewMode = ViewMode.Default;
@@ -329,7 +334,7 @@ namespace FileTime.Avalonia.ViewModels
await AppState.SelectedTab.OpenContainer(await AppState.SelectedTab.CurrentLocation.Container.WithoutVirtualContainer(RAPIDTRAVEL));
}
public async Task SwitchToTab(int number)
private async Task SwitchToTab(int number)
{
var tabContainer = AppState.Tabs.FirstOrDefault(t => t.TabNumber == number);
@@ -364,7 +369,7 @@ namespace FileTime.Avalonia.ViewModels
AppState.SelectedTab = tabContainer;
}
public async Task CloseTab()
private async Task CloseTab()
{
var tabs = AppState.Tabs;
if (tabs.Count > 1)
@@ -385,7 +390,7 @@ namespace FileTime.Avalonia.ViewModels
}
}
public Task CreateContainer()
private Task CreateContainer()
{
var handler = async () =>
{
@@ -403,7 +408,7 @@ namespace FileTime.Avalonia.ViewModels
return Task.CompletedTask;
}
public Task CreateElement()
private Task CreateElement()
{
var handler = async () =>
{
@@ -421,12 +426,12 @@ namespace FileTime.Avalonia.ViewModels
return Task.CompletedTask;
}
public async Task MarkCurrentItem()
private async Task MarkCurrentItem()
{
await AppState.SelectedTab.MarkCurrentItem();
}
public async Task Copy()
private async Task Copy()
{
_clipboard.Clear();
_clipboard.SetCommand<CopyCommand>();
@@ -450,7 +455,7 @@ namespace FileTime.Avalonia.ViewModels
}
}
public Task Cut()
private Task Cut()
{
_clipboard.Clear();
_clipboard.SetCommand<MoveCommand>();
@@ -458,7 +463,11 @@ namespace FileTime.Avalonia.ViewModels
return Task.CompletedTask;
}
public async Task Delete()
private async Task SoftDelete() => await Delete(false);
private async Task HardDelete() => await Delete(true);
public async Task Delete(bool hardDelete = false)
{
IList<AbsolutePath>? itemsToDelete = null;
var askForDelete = false;
@@ -524,6 +533,7 @@ namespace FileTime.Avalonia.ViewModels
async Task HandleDelete()
{
var deleteCommand = new DeleteCommand();
deleteCommand.HardDelete = hardDelete;
foreach (var itemToDelete in itemsToDelete!)
{
@@ -535,16 +545,16 @@ namespace FileTime.Avalonia.ViewModels
}
}
public async Task PasteMerge()
private async Task PasteMerge()
{
await Paste(TransportMode.Merge);
}
public async Task PasteOverwrite()
private async Task PasteOverwrite()
{
await Paste(TransportMode.Overwrite);
}
public async Task PasteSkip()
private async Task PasteSkip()
{
await Paste(TransportMode.Skip);
}
@@ -688,7 +698,7 @@ namespace FileTime.Avalonia.ViewModels
textToCopy = fullName;
}
if(textToCopy != null && global::Avalonia.Application.Current?.Clipboard is not null)
if (textToCopy != null && global::Avalonia.Application.Current?.Clipboard is not null)
{
await global::Avalonia.Application.Current.Clipboard.SetTextAsync(textToCopy);
}
@@ -1053,7 +1063,12 @@ namespace FileTime.Avalonia.ViewModels
"delete",
FileTime.App.Core.Command.Commands.Delete,
new KeyWithModifiers[]{new KeyWithModifiers(Key.D),new KeyWithModifiers(Key.D, shift: true)},
Delete),
SoftDelete),
new CommandBinding(
"hard delete",
FileTime.App.Core.Command.Commands.Delete,
new KeyWithModifiers[]{new KeyWithModifiers(Key.D, shift: true),new KeyWithModifiers(Key.D, shift: true)},
HardDelete),
new CommandBinding(
"paste merge",
FileTime.App.Core.Command.Commands.PasteMerge,

View File

@@ -12,169 +12,163 @@
Icon="/Assets/filetime.ico"
InputElement.KeyDown="OnKeyDown"
InputElement.KeyUp="OnKeyUp"
TransparencyLevelHint="Blur"
Background="Transparent"
ExtendClientAreaToDecorationsHint="True"
Opened="OnWindowOpened"
Closed="OnWindowClosed"
mc:Ignorable="d">
<Grid
x:Name="RootContainer"
Background="{DynamicResource AppBackgroundBrush}">
<Grid Background="{DynamicResource AppBackgroundBrush}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid ColumnDefinitions="250,*" RowDefinitions="Auto,*" IsVisible="{Binding Loading, Converter={StaticResource BoolInverter}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border CornerRadius="10" Background="{DynamicResource ContainerBackgroundBrush}" Padding="10" Margin="10">
<Grid RowDefinitions="Auto,Auto">
<TextBlock
Margin="0,0,0,10"
Text="Drives" />
<ItemsRepeater
Grid.Row="1"
Items="{Binding RootDriveInfos}">
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<Grid Margin="0,5" ColumnDefinitions="20,*,Auto" RowDefinitions="Auto,Auto">
<Image
Grid.RowSpan="2"
Width="20"
Height="20"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Source="{SvgImage /Assets/material/folder.svg}" />
<StackPanel
Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
Text="{Binding FullName}" />
<TextBlock
Margin="5,0,0,0"
VerticalAlignment="Center"
Classes="SmallText"
Text="{Binding Label}" IsVisible="{Binding Label,Converter={StaticResource IsNotEmptyConverter}}" />
</StackPanel>
<StackPanel HorizontalAlignment="Right"
Grid.Column="2"
Orientation="Horizontal"
VerticalAlignment="Center">
<TextBlock Classes="SmallText" VerticalAlignment="Center" Text="{Binding Free, Converter={StaticResource FormatSizeConverter}, ConverterParameter=0}">
</TextBlock>
<TextBlock Classes="SmallText" VerticalAlignment="Center" Text=" / ">
</TextBlock>
<TextBlock Classes="SmallText" VerticalAlignment="Center" Text="{Binding Size, Converter={StaticResource FormatSizeConverter}, ConverterParameter=0}">
</TextBlock>
</StackPanel>
<ProgressBar
Grid.Column="1"
Grid.ColumnSpan="2"
Grid.Row="2"
Maximum="100"
Value="{Binding UsedPercentage}" />
</Grid>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</Grid>
</Border>
<Border Grid.Row="1" CornerRadius="10" Background="{DynamicResource ContainerBackgroundBrush}" Padding="0,10" Margin="10">
<Grid RowDefinitions="Auto,Auto">
<TextBlock
Margin="10,0,10,10"
Text="Places" />
<ItemsRepeater
Grid.Row="1"
Items="{Binding Places}">
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<Grid Classes="PlacesItem" PointerPressed="OnPlacePointerPressed" Cursor="Hand">
<StackPanel Orientation="Horizontal" Margin="10,5" HorizontalAlignment="Stretch">
<Image
Width="20"
Height="20"
VerticalAlignment="Center"
Source="{Binding Container,Converter={StaticResource ItemToImageConverter}}" />
<TextBlock
Margin="5,0,0,0"
VerticalAlignment="Center"
Text="{Binding Name}" />
</StackPanel>
</Grid>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</Grid>
</Border>
</Grid>
<Grid Grid.Column="2" RowDefinitions="Auto,40,*,Auto">
<Grid>
<ItemsControl Items="{Binding TimelineCommands}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Background="{DynamicResource ContainerBackgroundColor}" Padding="5">
<ItemsControl Items="{Binding ParallelCommands}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}"/>
<ProgressBar Margin="0,5,0,0" Maximum="100" Value="{Binding Progress}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Grid PointerPressed="HeaderPointerPressed">
<Rectangle Fill="#01000000"/>
<TextBlock Margin="15,10" Text="FileTime"/>
</Grid>
<Grid Grid.Column="1" PointerPressed="HeaderPointerPressed">
<Rectangle Fill="#01000000"/>
<Grid Grid.Row="1" ColumnDefinitions="*,Auto">
<StackPanel Orientation="Horizontal">
<StackPanel Margin="20,10" Orientation="Horizontal">
<!--TextBlock Text="{Binding AppState.SelectedTab.TabNumber,StringFormat=({0})}" /-->
<local:PathPresenter DataContext="{Binding AppState.SelectedTab.CurrentLocation.Container.FullName}"/>
<TextBlock
Margin="10,5"
Text="{Binding AppState.SelectedTab.TabNumber,StringFormat=({0})}" />
<local:PathPresenter Margin="10,5,0,5" DataContext="{Binding AppState.SelectedTab.CurrentLocation.Container.FullName}"/>
<TextBlock
Margin="0,5,10,5"
Text="{Binding AppState.SelectedTab.SelectedItem.Item.Name}" Foreground="{StaticResource AccentForegroundBrush}" />
</StackPanel>
</Grid>
<Grid Grid.Row="1" RowDefinitions="Auto,Auto">
<Border CornerRadius="10" Background="{DynamicResource ContainerBackgroundBrush}" Padding="10" Margin="10">
<Grid RowDefinitions="Auto,Auto">
<TextBlock
Margin="0,0,0,10"
Text="Drives" />
<ItemsRepeater
Grid.Row="1"
Items="{Binding RootDriveInfos}">
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<Grid Margin="0,5" ColumnDefinitions="20,*,Auto" RowDefinitions="Auto,Auto">
<Image
Grid.RowSpan="2"
Width="20"
Height="20"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Source="{SvgImage /Assets/material/folder.svg}" />
<StackPanel
Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
Text="{Binding FullName}" />
<TextBlock
Margin="5,0,0,0"
VerticalAlignment="Center"
Classes="SmallText"
Text="{Binding Label}" IsVisible="{Binding Label,Converter={StaticResource IsNotEmptyConverter}}" />
</StackPanel>
<StackPanel HorizontalAlignment="Right"
Grid.Column="2"
Orientation="Horizontal"
VerticalAlignment="Center">
<TextBlock Classes="SmallText" VerticalAlignment="Center" Text="{Binding Free, Converter={StaticResource FormatSizeConverter}, ConverterParameter=0}">
</TextBlock>
<TextBlock Classes="SmallText" VerticalAlignment="Center" Text=" / ">
</TextBlock>
<TextBlock Classes="SmallText" VerticalAlignment="Center" Text="{Binding Size, Converter={StaticResource FormatSizeConverter}, ConverterParameter=0}">
</TextBlock>
</StackPanel>
<ProgressBar
Grid.Column="1"
Grid.ColumnSpan="2"
Grid.Row="2"
Maximum="100"
Value="{Binding UsedPercentage}" />
</Grid>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</Grid>
</Border>
<Border Grid.Row="1" CornerRadius="10" Background="{DynamicResource ContainerBackgroundBrush}" Padding="0,10" Margin="10">
<Grid RowDefinitions="Auto,Auto">
<TextBlock
Margin="10,0,10,10"
Text="Places" />
<ItemsRepeater
Grid.Row="1"
Items="{Binding Places}">
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<Grid Classes="PlacesItem" PointerPressed="OnPlacePointerPressed" Cursor="Hand">
<StackPanel Orientation="Horizontal" Margin="10,5" HorizontalAlignment="Stretch">
<Image
Width="20"
Height="20"
VerticalAlignment="Center"
Source="{Binding Container,Converter={StaticResource ItemToImageConverter}}" />
<TextBlock
Margin="5,0,0,0"
VerticalAlignment="Center"
Text="{Binding Name}" />
</StackPanel>
</Grid>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</Grid>
</Border>
</Grid>
<Grid Grid.Column="1" Grid.Row="1" RowDefinitions="Auto,40,*,Auto">
<Grid>
<ItemsControl Items="{Binding TimelineCommands}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Background="{DynamicResource ContainerBackgroundColor}" Padding="5">
<ItemsControl Items="{Binding ParallelCommands}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}"/>
<ProgressBar Margin="0,5,0,0" Maximum="100" Value="{Binding Progress}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<ItemsControl
Grid.Column="1"
HorizontalAlignment="Right"
Grid.Row="1"
Items="{Binding AppState.Tabs}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
@@ -200,287 +194,313 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<Grid
Grid.Row="2"
Margin="20,0,0,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="40*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="45*" />
</Grid.ColumnDefinitions>
<Grid
Grid.Row="2"
Margin="20,0,0,0">
<Grid>
<ListBox
Classes="ContentListView"
IsEnabled="False"
Items="{Binding AppState.SelectedTab.Parent.Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<local:ItemView ShowAttributes="False"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="40*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="45*" />
</Grid.ColumnDefinitions>
<Rectangle
Grid.Column="1"
Width="1"
Margin="0,10,0,10"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Fill="{DynamicResource ContentSeparatorBrush}" />
<Grid>
<ListBox
Classes="ContentListView"
IsEnabled="False"
Items="{Binding AppState.SelectedTab.Parent.Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<local:ItemView ShowAttributes="False"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
<Grid Grid.Column="2">
<ListBox
x:Name="CurrentItems"
IsTabStop="True"
Items="{Binding AppState.SelectedTab.CurrentLocation.Items}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
SelectedItem="{Binding AppState.SelectedTab.SelectedItem, Mode=TwoWay}"
Classes="ContentListView">
<ListBox.ItemTemplate>
<DataTemplate>
<local:ItemView/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock
x:Name="CurrentEmpty"
Margin="10"
<Rectangle
Grid.Column="1"
Width="1"
Margin="0,10,0,10"
HorizontalAlignment="Center"
FontWeight="Bold"
Foreground="{DynamicResource ErrorBrush}"
IsVisible="{Binding AppState.SelectedTab.CurrentLocation.Items.Count, Converter={StaticResource EqualityConverter}, ConverterParameter=0}">
Empty
</TextBlock>
</Grid>
VerticalAlignment="Stretch"
Fill="{DynamicResource ContentSeparatorBrush}" />
<Rectangle
Grid.Column="3"
Width="1"
Margin="0,10,0,10"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Fill="{DynamicResource ContentSeparatorBrush}" />
<Grid Grid.Column="4" IsVisible="{Binding AppState.SelectedTab.ChildContainer,Converter={StaticResource IsNotNullConverter}}">
<ListBox
Classes="ContentListView"
IsEnabled="False"
x:Name="ChildItems"
Items="{Binding AppState.SelectedTab.ChildContainer.Items}"
IsVisible="{Binding AppState.SelectedTab.ChildContainer.Items.Count, Converter={StaticResource NotEqualsConverter}, ConverterParameter=0}">
<ListBox.ItemTemplate>
<DataTemplate>
<local:ItemView/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Grid
IsVisible="{Binding AppState.SelectedTab.ChildContainer.Items.Count, Converter={StaticResource EqualityConverter}, ConverterParameter=0}">
<Grid Grid.Column="2">
<ListBox
x:Name="CurrentItems"
IsTabStop="True"
Items="{Binding AppState.SelectedTab.CurrentLocation.Items}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
SelectedItem="{Binding AppState.SelectedTab.SelectedItem, Mode=TwoWay}"
Classes="ContentListView">
<ListBox.ItemTemplate>
<DataTemplate>
<local:ItemView/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock
x:Name="ChildEmpty"
x:Name="CurrentEmpty"
Margin="10"
HorizontalAlignment="Center"
FontWeight="Bold"
Foreground="{DynamicResource ErrorBrush}"
IsVisible="{Binding AppState.SelectedTab.ChildContainer.Exceptions.Count, Converter={StaticResource EqualityConverter}, ConverterParameter=0}">
IsVisible="{Binding AppState.SelectedTab.CurrentLocation.Items.Count, Converter={StaticResource EqualityConverter}, ConverterParameter=0}">
Empty
</TextBlock>
</Grid>
<Rectangle
Grid.Column="3"
Width="1"
Margin="0,10,0,10"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Fill="{DynamicResource ContentSeparatorBrush}" />
<Grid Grid.Column="4" IsVisible="{Binding AppState.SelectedTab.ChildContainer,Converter={StaticResource IsNotNullConverter}}">
<ListBox
Classes="ContentListView"
IsEnabled="False"
x:Name="ChildItems"
Items="{Binding AppState.SelectedTab.ChildContainer.Items}"
IsVisible="{Binding AppState.SelectedTab.ChildContainer.Items.Count, Converter={StaticResource NotEqualsConverter}, ConverterParameter=0}">
<ListBox.ItemTemplate>
<DataTemplate>
<local:ItemView/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Grid
RowDefinitions="Auto, Auto"
IsVisible="{Binding AppState.SelectedTab.ChildContainer.Exceptions.Count, Converter={StaticResource NotEqualsConverter}, ConverterParameter=0}">
IsVisible="{Binding AppState.SelectedTab.ChildContainer.Items.Count, Converter={StaticResource EqualityConverter}, ConverterParameter=0}">
<TextBlock
Margin="0,0,0,10"
x:Name="ChildEmpty"
Margin="10"
HorizontalAlignment="Center"
TextWrapping="Wrap"
Text="There were some errors while opening container."
Foreground="{DynamicResource ErrorBrush}" />
FontWeight="Bold"
Foreground="{DynamicResource ErrorBrush}"
IsVisible="{Binding AppState.SelectedTab.ChildContainer.Exceptions.Count, Converter={StaticResource EqualityConverter}, ConverterParameter=0}">
Empty
</TextBlock>
<ItemsRepeater Grid.Row="1" Items="{Binding AppState.SelectedTab.ChildContainer.Exceptions}">
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding, Converter={StaticResource ExceptionToStringConverter}}"/>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
<Grid
RowDefinitions="Auto, Auto"
IsVisible="{Binding AppState.SelectedTab.ChildContainer.Exceptions.Count, Converter={StaticResource NotEqualsConverter}, ConverterParameter=0}">
<TextBlock
Margin="0,0,0,10"
HorizontalAlignment="Center"
TextWrapping="Wrap"
Text="There were some errors while opening container."
Foreground="{DynamicResource ErrorBrush}" />
<ItemsRepeater Grid.Row="1" Items="{Binding AppState.SelectedTab.ChildContainer.Exceptions}">
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding, Converter={StaticResource ExceptionToStringConverter}}"/>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</Grid>
</Grid>
</Grid>
</Grid>
</Grid>
<Grid
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsVisible="{Binding Inputs, Converter={StaticResource IsNotNullConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ItemsControl
x:Name="InputList"
Items="{Binding Inputs}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid MinWidth="400">
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="200" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding InputElement.Text}" />
<TextBox
AttachedToVisualTree="InputText_AttachedToVisualTree"
Grid.Column="1"
GotFocus="InputText_GotFocus"
LostFocus="InputText_LostFocus"
KeyDown="InputText_KeyDown"
Text="{Binding Value, Mode=TwoWay}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<StackPanel
Grid.Row="1"
Orientation="Horizontal">
<Button
Command="{Binding ProcessInputsCommand}"
Content="Ok" />
<Button
Command="{Binding CancelInputsCommand}"
Content="Cancel" />
</StackPanel>
</Grid>
<Grid
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsVisible="{Binding MessageBoxText, Converter={StaticResource IsNotNullConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding MessageBoxText}"/>
<StackPanel
Grid.Row="1"
Orientation="Horizontal">
<Button
Command="{Binding ProcessMessageBoxCommand}"
Content="Yes" />
<Button
Command="{Binding CancelMessageBoxCommand}"
Content="No" />
</StackPanel>
</Grid>
<ItemsRepeater Items="{Binding PopupTexts}" Margin="0,0,0,20" HorizontalAlignment="Center" VerticalAlignment="Bottom" IsVisible="{Binding PopupTexts.Count,Converter={StaticResource NotEqualsConverter}, ConverterParameter=0}">
<ItemsRepeater.Styles>
<Style Selector="TextBlock">
<Style.Animations>
<Animation Duration="0:0:1">
<KeyFrame Cue="0%">
<Setter Property="Opacity" Value="0.0"/>
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="Opacity" Value="1.0"/>
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
</ItemsRepeater.Styles>
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" HorizontalAlignment="Center"/>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</Grid>
<Grid Grid.Row="3">
<Grid IsVisible="{Binding AppState.ViewMode, Converter={StaticResource EqualityConverter}, ConverterParameter=RapidTravel}">
<Grid.RowDefinitions>
<RowDefinition Height="1" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Rectangle
Height="1"
Margin="10,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Fill="{DynamicResource ContentSeparatorBrush}" />
<StackPanel
Grid.Row="1"
Margin="30,10,10,10"
Orientation="Horizontal">
<TextBlock
Margin="0,0,30,0"
Text="Rapid travel mode" />
<TextBlock Text="Filter " />
<TextBlock Text="{Binding AppState.RapidTravelText}" />
</StackPanel>
</Grid>
<Grid IsVisible="{Binding NoCommandFound}">
<Grid.RowDefinitions>
<RowDefinition Height="1" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Rectangle
Height="1"
Margin="10,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Fill="{DynamicResource ContentSeparatorBrush}" />
<TextBlock
Grid.Row="1"
Margin="10"
<Grid
HorizontalAlignment="Center"
Foreground="{DynamicResource ErrorBrush}"
Text="No command found" />
</Grid>
<Grid IsVisible="{Binding PossibleCommands.Count, Converter={StaticResource NotEqualsConverter}, ConverterParameter=0}">
<Grid.RowDefinitions>
<RowDefinition Height="1" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Rectangle
Height="1"
Margin="10,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Fill="{DynamicResource ContentSeparatorBrush}" />
IsVisible="{Binding Inputs, Converter={StaticResource IsNotNullConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ItemsRepeater
Grid.Row="1"
Items="{Binding PossibleCommands}">
<ItemsControl
x:Name="InputList"
Items="{Binding Inputs}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid MinWidth="400">
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="200" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding InputElement.Text}" />
<TextBox
AttachedToVisualTree="InputText_AttachedToVisualTree"
Grid.Column="1"
GotFocus="InputText_GotFocus"
LostFocus="InputText_LostFocus"
KeyDown="InputText_KeyDown"
Text="{Binding Value, Mode=TwoWay}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<StackPanel
Grid.Row="1"
Orientation="Horizontal">
<Button
Command="{Binding ProcessInputsCommand}"
Content="Ok" />
<Button
Command="{Binding CancelInputsCommand}"
Content="Cancel" />
</StackPanel>
</Grid>
<Grid
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsVisible="{Binding MessageBoxText, Converter={StaticResource IsNotNullConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding MessageBoxText}"/>
<StackPanel
Grid.Row="1"
Orientation="Horizontal">
<Button
Command="{Binding ProcessMessageBoxCommand}"
Content="Yes" />
<Button
Command="{Binding CancelMessageBoxCommand}"
Content="No" />
</StackPanel>
</Grid>
<ItemsRepeater Items="{Binding PopupTexts}" Margin="0,0,0,20" HorizontalAlignment="Center" VerticalAlignment="Bottom" IsVisible="{Binding PopupTexts.Count,Converter={StaticResource NotEqualsConverter}, ConverterParameter=0}">
<ItemsRepeater.Styles>
<Style Selector="TextBlock">
<Style.Animations>
<Animation Duration="0:0:1">
<KeyFrame Cue="0%">
<Setter Property="Opacity" Value="0.0"/>
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="Opacity" Value="1.0"/>
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
</ItemsRepeater.Styles>
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding}" HorizontalAlignment="Center"/>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</Grid>
<Grid Grid.Row="3">
<Grid IsVisible="{Binding AppState.ViewMode, Converter={StaticResource EqualityConverter}, ConverterParameter=RapidTravel}">
<Grid.RowDefinitions>
<RowDefinition Height="1" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Rectangle
Height="1"
Margin="10,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Fill="{DynamicResource ContentSeparatorBrush}" />
<StackPanel
Grid.Row="1"
Margin="30,10,10,10"
Orientation="Horizontal">
<TextBlock
Margin="0,0,30,0"
Text="Rapid travel mode" />
<TextBlock Text="Filter " />
<TextBlock Text="{Binding AppState.RapidTravelText}" />
</StackPanel>
</Grid>
<Grid IsVisible="{Binding NoCommandFound}">
<Grid.RowDefinitions>
<RowDefinition Height="1" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Rectangle
Height="1"
Margin="10,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Fill="{DynamicResource ContentSeparatorBrush}" />
<TextBlock
Grid.Row="1"
Margin="10"
HorizontalAlignment="Center"
Foreground="{DynamicResource ErrorBrush}"
Text="No command found" />
</Grid>
<Grid IsVisible="{Binding PossibleCommands.Count, Converter={StaticResource NotEqualsConverter}, ConverterParameter=0}">
<Grid.RowDefinitions>
<RowDefinition Height="1" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Rectangle
Height="1"
Margin="10,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Fill="{DynamicResource ContentSeparatorBrush}" />
<ItemsRepeater
Grid.Row="1"
Items="{Binding PossibleCommands}">
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding KeysDisplayText}" />
<TextBlock Grid.Column="1" Text="{Binding Name}" />
</Grid>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</Grid>
</Grid>
</Grid>
</Grid>
<Border Background="{DynamicResource TransparentContainerBackgroundBrush}" Margin="20" HorizontalAlignment="Center" IsVisible="{Binding ShowAllShortcut}">
<Grid RowDefinitions="Auto, *" Margin="30,10">
<TextBlock Text="Shortcuts" Margin="0,0,0,20"/>
<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Disabled">
<ItemsControl
Items="{Binding AllShortcut}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,5,10,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
@@ -490,37 +510,18 @@
<TextBlock Grid.Column="1" Text="{Binding Name}" />
</Grid>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</Grid>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
</Border>
</Grid>
<Border Background="{DynamicResource TransparentContainerBackgroundBrush}" Margin="20" HorizontalAlignment="Center" IsVisible="{Binding ShowAllShortcut}">
<Grid RowDefinitions="Auto, *" Margin="30,10">
<TextBlock Text="Shortcuts" Margin="0,0,0,20"/>
<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Disabled">
<ItemsControl
Items="{Binding AllShortcut}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,5,10,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding KeysDisplayText}" />
<TextBlock Grid.Column="1" Text="{Binding Name}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Border>
<Grid IsVisible="{Binding Loading}">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Image Source="/Assets/filetime.ico" Width="128" Height="128"/>
<TextBlock Text="Loading..." HorizontalAlignment="Center" Margin="50"/>
</StackPanel>
</Grid>
</Grid>
</Window>

View File

@@ -6,6 +6,7 @@ using Avalonia.Markup.Xaml;
using FileTime.Avalonia.Misc;
using FileTime.Avalonia.Models;
using FileTime.Avalonia.ViewModels;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Linq;
@@ -98,10 +99,10 @@ namespace FileTime.Avalonia.Views
private void OnPlacePointerPressed(object sender, PointerPressedEventArgs e)
{
if(!e.Handled
if (!e.Handled
&& ViewModel != null
&& e.GetCurrentPoint(this).Properties.IsLeftButtonPressed
&& sender is StyledElement control
&& e.GetCurrentPoint(this).Properties.IsLeftButtonPressed
&& sender is StyledElement control
&& control.DataContext is PlaceInfo placeInfo)
{
ViewModel.OpenContainer(placeInfo.Container).Wait();
@@ -111,7 +112,38 @@ namespace FileTime.Avalonia.Views
private void OnWindowClosed(object sender, EventArgs e)
{
ViewModel?.StatePersistence.SaveStatesAsync().Wait();
try
{
ViewModel?.StatePersistence.SaveStatesAsync();
}
catch { }
}
private void OnWindowOpened(object sender, EventArgs e)
{
if (ViewModel is not MainPageViewModel)
{
ViewModel = App.ServiceProvider.GetService<MainPageViewModel>();
}
}
private void HeaderPointerPressed(object sender, PointerPressedEventArgs e)
{
if (e.ClickCount == 2)
{
if (WindowState == WindowState.Maximized)
{
WindowState = WindowState.Normal;
}
else
{
WindowState = WindowState.Maximized;
}
}
else
{
BeginMoveDrag(e);
}
}
}
}