Rename GuiApp.App <-> GuiApp
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<UserControl
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d"
|
||||
x:Class="FileTime.GuiApp.App.Views.CommandPalette"
|
||||
x:CompileBindings="True"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="clr-namespace:FileTime.App.CommandPalette.ViewModels;assembly=FileTime.App.CommandPalette.Abstractions"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<UserControl.Styles>
|
||||
<StyleInclude Source="avares://FileTime.GuiApp.App/Resources/Styles.axaml" />
|
||||
</UserControl.Styles>
|
||||
<Grid RowDefinitions="Auto,*" x:DataType="vm:ICommandPaletteViewModel">
|
||||
<TextBox
|
||||
KeyDown="Search_OnKeyDown"
|
||||
KeyUp="Search_OnKeyUp"
|
||||
Text="{Binding SearchText, Mode=TwoWay}"
|
||||
x:Name="SearchTextBox" />
|
||||
<ListBox
|
||||
Classes="CommandPalette"
|
||||
Grid.Row="1"
|
||||
ItemsSource="{Binding FilteredMatches}"
|
||||
SelectedItem="{Binding SelectedItem}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:ICommandPaletteEntryViewModel">
|
||||
<Grid ColumnDefinitions="*, Auto" Margin="5">
|
||||
<TextBlock Text="{Binding Title}" />
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
Margin="0,0,10,0"
|
||||
Text="{Binding Shortcuts}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,49 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
using FileTime.App.CommandPalette.ViewModels;
|
||||
|
||||
namespace FileTime.GuiApp.App.Views;
|
||||
|
||||
public partial class CommandPalette : UserControl
|
||||
{
|
||||
public CommandPalette()
|
||||
{
|
||||
InitializeComponent();
|
||||
PropertyChanged += CommandPalette_PropertyChanged;
|
||||
}
|
||||
|
||||
private async void CommandPalette_PropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.Property.Name == nameof(IsVisible) && IsVisible)
|
||||
{
|
||||
await Task.Delay(10);
|
||||
SearchTextBox.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void Search_OnKeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Handled) return;
|
||||
if (DataContext is not ICommandPaletteViewModel viewModel) return;
|
||||
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
e.Handled = true;
|
||||
viewModel.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
viewModel.HandleKeyDown(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void Search_OnKeyUp(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Handled) return;
|
||||
if (DataContext is not ICommandPaletteViewModel viewModel) return;
|
||||
viewModel.HandleKeyUp(e);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<UserControl
|
||||
Background="{DynamicResource ContainerBackgroundColor}"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d"
|
||||
x:Class="FileTime.GuiApp.App.Views.FrequencyNavigation"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="viewModels:IFrequencyNavigationViewModel"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModels="clr-namespace:FileTime.App.FrequencyNavigation.ViewModels;assembly=FileTime.App.FrequencyNavigation.Abstractions"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<UserControl.Styles>
|
||||
<StyleInclude Source="avares://FileTime.GuiApp.App/Resources/Styles.axaml" />
|
||||
</UserControl.Styles>
|
||||
<Grid RowDefinitions="Auto,*">
|
||||
<TextBox
|
||||
KeyDown="Search_OnKeyDown"
|
||||
KeyUp="Search_OnKeyUp"
|
||||
Text="{Binding SearchText, Mode=TwoWay}"
|
||||
x:Name="SearchTextBox" />
|
||||
<ListBox
|
||||
Classes="CommandPalette"
|
||||
Grid.Row="1"
|
||||
ItemsSource="{Binding FilteredMatches}"
|
||||
SelectedItem="{Binding SelectedItem}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="x:String">
|
||||
<Grid Margin="5">
|
||||
<TextBlock Text="{Binding}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,47 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using FileTime.App.FrequencyNavigation.ViewModels;
|
||||
|
||||
namespace FileTime.GuiApp.App.Views;
|
||||
|
||||
public partial class FrequencyNavigation : UserControl
|
||||
{
|
||||
public FrequencyNavigation()
|
||||
{
|
||||
InitializeComponent();
|
||||
PropertyChanged += FrequencyNavigation_PropertyChanged;
|
||||
}
|
||||
|
||||
private async void FrequencyNavigation_PropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.Property.Name == nameof(IsVisible) && IsVisible)
|
||||
{
|
||||
await Task.Delay(100);
|
||||
SearchTextBox.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void Search_OnKeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Handled) return;
|
||||
|
||||
if (DataContext is not IFrequencyNavigationViewModel viewModel) return;
|
||||
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
viewModel.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
viewModel.HandleKeyDown(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void Search_OnKeyUp(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Handled) return;
|
||||
if (DataContext is not IFrequencyNavigationViewModel viewModel) return;
|
||||
viewModel.HandleKeyUp(e);
|
||||
}
|
||||
}
|
||||
108
src/GuiApp/Avalonia/FileTime.GuiApp.App/Views/ItemView.axaml
Normal file
108
src/GuiApp/Avalonia/FileTime.GuiApp.App/Views/ItemView.axaml
Normal file
@@ -0,0 +1,108 @@
|
||||
<UserControl
|
||||
Background="{Binding ViewMode.Value, Converter={StaticResource ItemViewModeToBackgroundConverter}}"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d"
|
||||
x:Class="FileTime.GuiApp.App.Views.ItemView"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="appcore:IItemViewModel"
|
||||
x:Name="ItemRoot"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:appcore="using:FileTime.App.Core.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:guiappvm="using:FileTime.GuiApp.App.ViewModels"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:traits="clr-namespace:FileTime.App.Core.Models.Traits;assembly=FileTime.App.Core.Abstraction"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Grid
|
||||
ColumnDefinitions="20,*,Auto"
|
||||
Margin="3"
|
||||
x:Name="RootGrid">
|
||||
<Grid.Styles>
|
||||
<Style Selector="TextBlock">
|
||||
<Setter Property="Foreground" Value="{Binding DataContext.ViewMode.Value, Converter={StaticResource ItemViewModeToForegroundConverter}, ElementName=ItemRoot}" x:CompileBindings="False" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
<Image
|
||||
Height="18"
|
||||
HorizontalAlignment="Left"
|
||||
Source="{Binding Converter={StaticResource ItemToImageConverter}}"
|
||||
VerticalAlignment="Center"
|
||||
Width="18" />
|
||||
|
||||
<ItemsControl
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
Margin="5,0,0,0"
|
||||
VerticalAlignment="Center">
|
||||
<ItemsControl.ItemsSource>
|
||||
<MultiBinding Converter="{StaticResource NamePartShrinkerConverter}">
|
||||
<MultiBinding.Bindings>
|
||||
<Binding Path="DisplayName^" />
|
||||
<Binding ElementName="RootGrid" Path="Bounds.Width" />
|
||||
<Binding ElementName="ItemRoot" Path="ShowAttributes" />
|
||||
</MultiBinding.Bindings>
|
||||
</MultiBinding>
|
||||
</ItemsControl.ItemsSource>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="guiappvm:ItemNamePartViewModel">
|
||||
<Grid>
|
||||
<TextBlock Text="{Binding Text}" TextDecorations="{Binding TextDecorations}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<Grid Grid.Column="2" IsVisible="{Binding ShowAttributes, ElementName=ItemRoot}">
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Classes="SmallText"
|
||||
IsVisible="{Binding Converter={StaticResource IsTypeConverter}, ConverterParameter={x:Type appcore:IElementViewModel}}"
|
||||
Text="{Binding BaseItem.DisplayName, Converter={StaticResource GetFileExtensionConverter}}"
|
||||
Width="50" />
|
||||
<Grid DataContext="{Binding BaseItem}" IsVisible="{Binding Converter={StaticResource IsTypeConverter}, ConverterParameter={x:Type traits:ISizeProvider}}">
|
||||
<TextBlock
|
||||
Classes="SmallText"
|
||||
Text="{Binding Size.Value, Converter={StaticResource FormatSizeConverter}}"
|
||||
TextAlignment="Right"
|
||||
Width="60"
|
||||
x:DataType="traits:ISizeProvider" />
|
||||
</Grid>
|
||||
<Grid IsVisible="{Binding BaseItem, Converter={StaticResource IsNotTypeConverter}, ConverterParameter={x:Type traits:ISizeProvider}}">
|
||||
|
||||
<TextBlock
|
||||
Classes="SmallText"
|
||||
IsVisible="{Binding Converter={StaticResource IsTypeConverter}, ConverterParameter={x:Type traits:ISizeProvider}}"
|
||||
Text="{Binding Size.Value, Converter={StaticResource FormatSizeConverter}}"
|
||||
TextAlignment="Right"
|
||||
Width="60"
|
||||
x:DataType="traits:ISizeProvider" />
|
||||
</Grid>
|
||||
<TextBlock
|
||||
Classes="SmallText"
|
||||
Text="{Binding ModifiedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter=yyyy-MM-dd}"
|
||||
TextAlignment="Right"
|
||||
Width="95" />
|
||||
<TextBlock
|
||||
Classes="SmallText"
|
||||
Text="{Binding ModifiedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter=hh:mm}"
|
||||
TextAlignment="Right"
|
||||
Width="35" />
|
||||
<TextBlock
|
||||
Classes="SmallText"
|
||||
Text="{Binding BaseItem.Attributes}"
|
||||
TextAlignment="Right"
|
||||
Width="45" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,20 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace FileTime.GuiApp.App.Views;
|
||||
|
||||
public partial class ItemView : UserControl
|
||||
{
|
||||
public static readonly StyledProperty<bool> ShowAttributesProperty = AvaloniaProperty.Register<ItemView, bool>(nameof(ShowAttributes), true);
|
||||
|
||||
public bool ShowAttributes
|
||||
{
|
||||
get => GetValue(ShowAttributesProperty);
|
||||
set => SetValue(ShowAttributesProperty, value);
|
||||
}
|
||||
|
||||
public ItemView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
1011
src/GuiApp/Avalonia/FileTime.GuiApp.App/Views/MainWindow.axaml
Normal file
1011
src/GuiApp/Avalonia/FileTime.GuiApp.App/Views/MainWindow.axaml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,267 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
using DynamicData;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.GuiApp.App.Models;
|
||||
using FileTime.GuiApp.App.Services;
|
||||
using FileTime.GuiApp.App.ViewModels;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FileTime.GuiApp.App.Views;
|
||||
|
||||
public partial class MainWindow : Window, IUiAccessor
|
||||
{
|
||||
private readonly Action? _initializer;
|
||||
private ILogger<MainWindow>? _logger;
|
||||
private IModalService? _modalService;
|
||||
private IReadOnlyCollection<IModalViewModel>? _openModals;
|
||||
private ReadInputsViewModel? _inputViewModel;
|
||||
private IDisposable? _inputViewModelSubscription;
|
||||
private bool _isShuttingDown;
|
||||
private bool _shutdownCompleted;
|
||||
private readonly object _isClosingLock = new();
|
||||
|
||||
public MainWindowViewModel? ViewModel
|
||||
{
|
||||
get => DataContext as MainWindowViewModel;
|
||||
set
|
||||
{
|
||||
if (value != DataContext)
|
||||
{
|
||||
DataContext = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
if (Design.IsDesignMode)
|
||||
{
|
||||
DataContext = new MainWindowDesignViewModel();
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindow(Action initializer) : this()
|
||||
{
|
||||
_initializer = initializer;
|
||||
}
|
||||
|
||||
private void OnWindowOpened(object sender, EventArgs e)
|
||||
{
|
||||
if (DataContext is not MainWindowViewModel && !Design.IsDesignMode)
|
||||
{
|
||||
_initializer?.Invoke();
|
||||
|
||||
_logger = DI.ServiceProvider.GetService<ILogger<MainWindow>>();
|
||||
_modalService = DI.ServiceProvider.GetRequiredService<IModalService>();
|
||||
_modalService.OpenModals.ToCollection().Subscribe(m => _openModals = m);
|
||||
DI.ServiceProvider.GetRequiredService<Services.SystemClipboardService>().UiAccessor = this;
|
||||
|
||||
ReadInputContainer.PropertyChanged += ReadInputContainerOnPropertyChanged;
|
||||
DataContextChanged += (_, _) =>
|
||||
{
|
||||
if (DataContext is not MainWindowViewModel mainWindowViewModel) return;
|
||||
|
||||
_inputViewModelSubscription?.Dispose();
|
||||
_inputViewModelSubscription = mainWindowViewModel.DialogService.ReadInput.Subscribe(
|
||||
inputViewModel => _inputViewModel = inputViewModel
|
||||
);
|
||||
};
|
||||
|
||||
_logger?.LogInformation(
|
||||
$"{nameof(MainWindow)} opened, starting {nameof(MainWindowViewModel)} initialization...");
|
||||
|
||||
try
|
||||
{
|
||||
var viewModel = DI.ServiceProvider.GetRequiredService<MainWindowViewModel>();
|
||||
viewModel.FocusDefaultElement = () => Focus();
|
||||
ViewModel = viewModel;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger?.LogError(ex, "Error initializing {ViewModel}", nameof(MainWindowViewModel));
|
||||
if (DataContext is IMainWindowViewModelBase mainWindowViewModelBase)
|
||||
{
|
||||
mainWindowViewModelBase.FatalError.SetValueSafe(
|
||||
$"Error initializing {nameof(MainWindowViewModel)}: " + ex.Message
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if ((_openModals?.Count ?? 0) > 0) return;
|
||||
ViewModel?.ProcessKeyDown(e.Key, e.KeyModifiers, h => e.Handled = h);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnHasContainerPointerPressed(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (!e.Handled
|
||||
&& ViewModel != null
|
||||
&& e.GetCurrentPoint(this).Properties.IsLeftButtonPressed
|
||||
&& sender is StyledElement control)
|
||||
{
|
||||
FullName? path = null;
|
||||
if (control.DataContext is IHaveFullPath {Path: { }} hasFullPath)
|
||||
{
|
||||
path = hasFullPath.Path;
|
||||
}
|
||||
else if (control.DataContext is FullName p)
|
||||
{
|
||||
path = p;
|
||||
}
|
||||
/*else if (control.DataContext is IElement element && element.GetParent() is IContainer parentContainer)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
await ViewModel.AppState.SelectedTab.OpenContainer(parentContainer);
|
||||
await ViewModel.AppState.SelectedTab.SetCurrentSelectedItem(element);
|
||||
});
|
||||
});
|
||||
}*/
|
||||
|
||||
if (path is null) return;
|
||||
|
||||
await ViewModel.OpenContainerByFullName(path);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private async void ReadInputContainerOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.Property.Name == nameof(ReadInputContainer.IsVisible) && ReadInputContainer.IsVisible)
|
||||
{
|
||||
await Task.Delay(100);
|
||||
var inputElement = InputList
|
||||
.GetVisualDescendants()
|
||||
.OfType<Control>()
|
||||
.FirstOrDefault(i => i.Tag as string == "InputItem" && i.IsVisible);
|
||||
inputElement?.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Window_OnClosed(object? sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void InputList_OnKeyUp(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
_inputViewModel?.Cancel();
|
||||
_inputViewModel = null;
|
||||
}
|
||||
else if (e.Key == Key.Enter)
|
||||
{
|
||||
_inputViewModel?.Process();
|
||||
_inputViewModel = null;
|
||||
}
|
||||
}
|
||||
|
||||
public TopLevel? GetTopLevel() => GetTopLevel(this);
|
||||
|
||||
public async Task InvokeOnUIThread(Func<Task> func) => await Dispatcher.UIThread.InvokeAsync(func);
|
||||
|
||||
public async Task<T> InvokeOnUIThread<T>(Func<Task<T>> func) => await Dispatcher.UIThread.InvokeAsync(func);
|
||||
|
||||
private async void Child_OnPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (e is {Handled: false, ClickCount: 2}
|
||||
&& ViewModel != null
|
||||
&& e.GetCurrentPoint(this).Properties.IsLeftButtonPressed
|
||||
&& sender is StyledElement {DataContext: IItemViewModel itemViewModel})
|
||||
{
|
||||
try
|
||||
{
|
||||
await ViewModel.RunOrOpenItem(itemViewModel);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger?.LogError(
|
||||
ex,
|
||||
"Error while opening item {Item}",
|
||||
itemViewModel.BaseItem?.FullName?.Path ?? itemViewModel.DisplayNameText
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_OnClosing(object? sender, WindowClosingEventArgs e)
|
||||
{
|
||||
lock (_isClosingLock)
|
||||
{
|
||||
if (_isShuttingDown)
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_shutdownCompleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isShuttingDown = true;
|
||||
e.Cancel = true;
|
||||
|
||||
var vm = ViewModel;
|
||||
var exitVm = new MainWindowLoadingViewModel();
|
||||
exitVm.Title.SetValueSafe("Shutting down...");
|
||||
DataContext = exitVm;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(200);
|
||||
try
|
||||
{
|
||||
if (vm is not null)
|
||||
{
|
||||
await vm.OnExit();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
lock (_isClosingLock)
|
||||
{
|
||||
_isShuttingDown = false;
|
||||
_shutdownCompleted = true;
|
||||
}
|
||||
|
||||
Dispatcher.UIThread.Invoke(Close);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<UserControl
|
||||
x:Class="FileTime.GuiApp.App.Views.PathPresenter"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:coremodels="using:FileTime.Core.Models"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<ItemsControl ItemsSource="{Binding Converter={StaticResource SplitStringConverter}, ConverterParameter={x:Static coremodels:Constants.SeparatorChar}}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding}" />
|
||||
<TextBlock
|
||||
Margin="5,0,5,0"
|
||||
Foreground="{DynamicResource LightForegroundBrush}"
|
||||
Text="/" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,11 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace FileTime.GuiApp.App.Views;
|
||||
|
||||
public partial class PathPresenter : UserControl
|
||||
{
|
||||
public PathPresenter()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user