Dispose -> Destroy, windows icon color fix
This commit is contained in:
@@ -287,7 +287,7 @@ namespace FileTime.Core.Components
|
|||||||
|
|
||||||
foreach (var lastLocationItem in currentLocationItems.OfType<IContainer>())
|
foreach (var lastLocationItem in currentLocationItems.OfType<IContainer>())
|
||||||
{
|
{
|
||||||
lastLocationItem.Dispose();
|
lastLocationItem.Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,16 @@ using FileTime.Core.Providers;
|
|||||||
|
|
||||||
namespace FileTime.Core.Models
|
namespace FileTime.Core.Models
|
||||||
{
|
{
|
||||||
public interface IItem : IDisposable
|
public interface IItem
|
||||||
{
|
{
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
string? FullName { get; }
|
string? FullName { get; }
|
||||||
bool IsHidden { get; }
|
bool IsHidden { get; }
|
||||||
bool IsDisposed { get; }
|
bool IsDestroyed { get; }
|
||||||
SupportsDelete CanDelete { get; }
|
SupportsDelete CanDelete { get; }
|
||||||
bool CanRename { get; }
|
bool CanRename { get; }
|
||||||
IContentProvider Provider { get; }
|
IContentProvider Provider { get; }
|
||||||
|
void Destroy();
|
||||||
Task Delete(bool hardDelete = false);
|
Task Delete(bool hardDelete = false);
|
||||||
Task Rename(string newName);
|
Task Rename(string newName);
|
||||||
IContainer? GetParent();
|
IContainer? GetParent();
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace FileTime.Core.Models
|
|||||||
|
|
||||||
public AsyncEventHandler Refreshed { get; }
|
public AsyncEventHandler Refreshed { get; }
|
||||||
|
|
||||||
public bool IsDisposed => BaseContainer.IsDisposed;
|
public bool IsDestroyed => BaseContainer.IsDestroyed;
|
||||||
|
|
||||||
private void RefreshAddBase(Func<object?, AsyncEventArgs, CancellationToken, Task> handler)
|
private void RefreshAddBase(Func<object?, AsyncEventArgs, CancellationToken, Task> handler)
|
||||||
{
|
{
|
||||||
@@ -171,9 +171,9 @@ namespace FileTime.Core.Models
|
|||||||
public async Task Rename(string newName) => await BaseContainer.Rename(newName);
|
public async Task Rename(string newName) => await BaseContainer.Rename(newName);
|
||||||
public async Task<bool> CanOpen() => await BaseContainer.CanOpen();
|
public async Task<bool> CanOpen() => await BaseContainer.CanOpen();
|
||||||
|
|
||||||
public void Dispose()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
BaseContainer.Dispose();
|
BaseContainer.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unload()
|
public void Unload()
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace FileTime.Core.Providers
|
|||||||
|
|
||||||
public bool SupportsDirectoryLevelSoftDelete => false;
|
public bool SupportsDirectoryLevelSoftDelete => false;
|
||||||
|
|
||||||
public bool IsDisposed => false;
|
public bool IsDestroyed => false;
|
||||||
|
|
||||||
public TopContainer(IEnumerable<IContentProvider> contentProviders)
|
public TopContainer(IEnumerable<IContentProvider> contentProviders)
|
||||||
{
|
{
|
||||||
@@ -71,7 +71,7 @@ namespace FileTime.Core.Providers
|
|||||||
|
|
||||||
public Task<bool> CanOpen() => Task.FromResult(true);
|
public Task<bool> CanOpen() => Task.FromResult(true);
|
||||||
|
|
||||||
public void Dispose() { }
|
public void Destroy() { }
|
||||||
|
|
||||||
public void Unload() { }
|
public void Unload() { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace FileTime.Core.Timeline
|
|||||||
|
|
||||||
public bool SupportsDirectoryLevelSoftDelete => false;
|
public bool SupportsDirectoryLevelSoftDelete => false;
|
||||||
|
|
||||||
public bool IsDisposed { get; private set; }
|
public bool IsDestroyed { get; private set; }
|
||||||
|
|
||||||
public TimeContainer(string name, IContainer parent, IContentProvider contentProvider, IContentProvider virtualContentProvider, PointInTime pointInTime)
|
public TimeContainer(string name, IContainer parent, IContentProvider contentProvider, IContentProvider virtualContentProvider, PointInTime pointInTime)
|
||||||
{
|
{
|
||||||
@@ -124,7 +124,7 @@ namespace FileTime.Core.Timeline
|
|||||||
}
|
}
|
||||||
public Task<bool> CanOpen() => Task.FromResult(true);
|
public Task<bool> CanOpen() => Task.FromResult(true);
|
||||||
|
|
||||||
public void Dispose() => IsDisposed = true;
|
public void Destroy() => IsDestroyed = true;
|
||||||
public void Unload() { }
|
public void Unload() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ namespace FileTime.Core.Timeline
|
|||||||
public IContentProvider Provider { get; }
|
public IContentProvider Provider { get; }
|
||||||
public IContentProvider VirtualProvider { get; }
|
public IContentProvider VirtualProvider { get; }
|
||||||
|
|
||||||
public bool IsDisposed { get; private set; }
|
public bool IsDestroyed { get; private set; }
|
||||||
|
|
||||||
public Task Delete(bool hardDelete = false) => Task.CompletedTask;
|
public Task Delete(bool hardDelete = false) => Task.CompletedTask;
|
||||||
|
|
||||||
@@ -44,6 +44,6 @@ namespace FileTime.Core.Timeline
|
|||||||
public Task<string> GetContent(CancellationToken token = default) => Task.FromResult("");
|
public Task<string> GetContent(CancellationToken token = default) => Task.FromResult("");
|
||||||
public Task<long> GetElementSize(CancellationToken token = default) => Task.FromResult(-1L);
|
public Task<long> GetElementSize(CancellationToken token = default) => Task.FromResult(-1L);
|
||||||
|
|
||||||
public void Dispose() => IsDisposed = true;
|
public void Destroy() => IsDestroyed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ namespace FileTime.Core.Timeline
|
|||||||
|
|
||||||
public bool SupportsDirectoryLevelSoftDelete => false;
|
public bool SupportsDirectoryLevelSoftDelete => false;
|
||||||
|
|
||||||
public bool IsDisposed => false;
|
public bool IsDestroyed => false;
|
||||||
|
|
||||||
public TimeProvider(PointInTime pointInTime)
|
public TimeProvider(PointInTime pointInTime)
|
||||||
{
|
{
|
||||||
@@ -93,7 +93,7 @@ namespace FileTime.Core.Timeline
|
|||||||
public void SetParent(IContainer container) { }
|
public void SetParent(IContainer container) { }
|
||||||
public Task<bool> CanOpen() => Task.FromResult(true);
|
public Task<bool> CanOpen() => Task.FromResult(true);
|
||||||
|
|
||||||
public void Dispose() { }
|
public void Destroy() { }
|
||||||
|
|
||||||
public void Unload() { }
|
public void Unload() { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,8 @@
|
|||||||
<GradientStop Offset="0.5" Color="#93a1a1" />
|
<GradientStop Offset="0.5" Color="#93a1a1" />
|
||||||
<GradientStop Offset="1" Color="#0093a1a1" />
|
<GradientStop Offset="1" Color="#0093a1a1" />
|
||||||
</LinearGradientBrush>
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<SolidColorBrush
|
<SolidColorBrush
|
||||||
x:Key="AppBackgroundBrush"
|
x:Key="AppBackgroundBrush"
|
||||||
@@ -105,8 +105,8 @@
|
|||||||
<converters:CompareConverter x:Key="EqualityConverter"/>
|
<converters:CompareConverter x:Key="EqualityConverter"/>
|
||||||
<converters:CompareConverter x:Key="NotEqualsConverter" ComparisonCondition="{x:Static converters:ComparisonCondition.NotEqual}"/>
|
<converters:CompareConverter x:Key="NotEqualsConverter" ComparisonCondition="{x:Static converters:ComparisonCondition.NotEqual}"/>
|
||||||
<converters:SplitStringConverter x:Key="SplitStringConverter" />
|
<converters:SplitStringConverter x:Key="SplitStringConverter" />
|
||||||
<converters:ItemViewModeToBrushConverter
|
<converters:ItemViewModeToBrushConverter
|
||||||
x:Key="ItemViewModeToForegroundConverter"
|
x:Key="ItemViewModeToForegroundConverter"
|
||||||
DefaultBrush="{StaticResource ForegroundBrush}"
|
DefaultBrush="{StaticResource ForegroundBrush}"
|
||||||
AlternativeBrush="{StaticResource AlternativeItemForegroundBrush}"
|
AlternativeBrush="{StaticResource AlternativeItemForegroundBrush}"
|
||||||
SelectedBrush="{StaticResource SelectedItemForegroundBrush}"
|
SelectedBrush="{StaticResource SelectedItemForegroundBrush}"
|
||||||
@@ -182,9 +182,19 @@
|
|||||||
<Style Selector="Grid.PlacesItem:pointerover">
|
<Style Selector="Grid.PlacesItem:pointerover">
|
||||||
<Setter Property="Background" Value="{DynamicResource AppBackgroundColor}"/>
|
<Setter Property="Background" Value="{DynamicResource AppBackgroundColor}"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="Border.SelectedTimelineCommand">
|
<Style Selector="Border.SelectedTimelineCommand">
|
||||||
<Setter Property="BorderBrush" Value="{DynamicResource ForegroundBrush}"/>
|
<Setter Property="BorderBrush" Value="{DynamicResource ForegroundBrush}"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<!--Style Selector="MenuItem">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<DataTemplate>
|
||||||
|
<Grid ColumnDefinitions="20,*">
|
||||||
|
<TextBlock Grid.Column="1" Text="{Binding Header}" />
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</Setter>
|
||||||
|
</Style-->
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
</Application>
|
</Application>
|
||||||
|
|||||||
@@ -33,6 +33,10 @@
|
|||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.12" />
|
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.12" />
|
||||||
<PackageReference Include="Avalonia.Svg.Skia" Version="0.10.12" />
|
<PackageReference Include="Avalonia.Svg.Skia" Version="0.10.12" />
|
||||||
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="0.10.12" />
|
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="0.10.12" />
|
||||||
|
<PackageReference Include="IDisposableAnalyzers" Version="4.0.1">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Avalonia.Media.Imaging;
|
using Avalonia.Media.Imaging;
|
||||||
using FileTime.Avalonia.Misc;
|
using FileTime.Avalonia.Misc;
|
||||||
@@ -18,32 +19,64 @@ namespace FileTime.Avalonia.IconProviders
|
|||||||
if (Array.Find(lines, l => l.StartsWith("iconresource", StringComparison.OrdinalIgnoreCase)) is string iconLine)
|
if (Array.Find(lines, l => l.StartsWith("iconresource", StringComparison.OrdinalIgnoreCase)) is string iconLine)
|
||||||
{
|
{
|
||||||
var nameLineValue = string.Join('=', iconLine.Split('=')[1..]);
|
var nameLineValue = string.Join('=', iconLine.Split('=')[1..]);
|
||||||
var environemntVariables = Environment.GetEnvironmentVariables();
|
return GetImagePathByIconPath(nameLineValue);
|
||||||
foreach (var keyo in environemntVariables.Keys)
|
|
||||||
{
|
|
||||||
if (keyo is string key && environemntVariables[key] is string value)
|
|
||||||
{
|
|
||||||
nameLineValue = nameLineValue.Replace($"%{key}%", value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var parts = nameLineValue.Split(',');
|
|
||||||
if (parts.Length >= 2 && long.TryParse(parts[^1], out var parsedResourceId))
|
|
||||||
{
|
|
||||||
if (parsedResourceId < 0) parsedResourceId *= -1;
|
|
||||||
|
|
||||||
var extractedIcon = NativeMethodHelpers.GetIconResource(string.Join(',', parts[..^1]), (uint)parsedResourceId);
|
|
||||||
|
|
||||||
var extractedIconAsStream = new MemoryStream();
|
|
||||||
extractedIcon.Save(extractedIconAsStream);
|
|
||||||
extractedIconAsStream.Position = 0;
|
|
||||||
|
|
||||||
return new ImagePath(ImagePathType.Raw, new Bitmap(extractedIconAsStream));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ImagePath GetImagePathByIconPath(string path)
|
||||||
|
{
|
||||||
|
var environemntVariables = Environment.GetEnvironmentVariables();
|
||||||
|
foreach (var keyo in environemntVariables.Keys)
|
||||||
|
{
|
||||||
|
if (keyo is string key && environemntVariables[key] is string value)
|
||||||
|
{
|
||||||
|
path = path.Replace($"%{key}%", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var parts = path.Split(',');
|
||||||
|
(var parsedResourceId, var path2) = parts.Length >= 2 && long.TryParse(parts[^1], out var id)
|
||||||
|
? (id, NormalizePath(string.Join(',', parts[..^1])))
|
||||||
|
: (0, NormalizePath(path));
|
||||||
|
|
||||||
|
if (parsedResourceId == 0)
|
||||||
|
{
|
||||||
|
using var extractedIconAsStream = new MemoryStream();
|
||||||
|
using var extractedIcon = System.Drawing.Icon.ExtractAssociatedIcon(path2).ToBitmap();
|
||||||
|
extractedIcon.Save(extractedIconAsStream, ImageFormat.Png);
|
||||||
|
extractedIconAsStream.Position = 0;
|
||||||
|
#pragma warning disable IDISP004 // Don't ignore created IDisposable
|
||||||
|
return new ImagePath(ImagePathType.Raw, new Bitmap(extractedIconAsStream));
|
||||||
|
#pragma warning restore IDISP004 // Don't ignore created IDisposable
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (parsedResourceId < 0) parsedResourceId *= -1;
|
||||||
|
|
||||||
|
using var extractedIcon = NativeMethodHelpers.GetIconResource(path2, (uint)parsedResourceId).ToBitmap();
|
||||||
|
|
||||||
|
using var extractedIconAsStream = new MemoryStream();
|
||||||
|
extractedIcon.Save(extractedIconAsStream, ImageFormat.Png);
|
||||||
|
extractedIconAsStream.Position = 0;
|
||||||
|
|
||||||
|
#pragma warning disable IDISP004 // Don't ignore created IDisposable
|
||||||
|
return new ImagePath(ImagePathType.Raw, new Bitmap(extractedIconAsStream));
|
||||||
|
#pragma warning restore IDISP004 // Don't ignore created IDisposable
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string NormalizePath(string path)
|
||||||
|
{
|
||||||
|
if (path.StartsWith('\"') && path.EndsWith('\"'))
|
||||||
|
{
|
||||||
|
return path[1..^1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,10 +61,7 @@ namespace FileTime.Avalonia
|
|||||||
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||||
}
|
}
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
catch
|
finally { }
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ using FileTime.Providers.Local;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using FileTime.Avalonia.Misc;
|
using FileTime.Avalonia.Misc;
|
||||||
|
using FileTime.Avalonia.IconProviders;
|
||||||
|
using Avalonia.Svg.Skia;
|
||||||
|
using Avalonia.Media;
|
||||||
|
|
||||||
#pragma warning disable CA1416
|
#pragma warning disable CA1416
|
||||||
namespace FileTime.Avalonia.Services
|
namespace FileTime.Avalonia.Services
|
||||||
@@ -24,15 +26,16 @@ namespace FileTime.Avalonia.Services
|
|||||||
|
|
||||||
if (container is LocalFolder localFolder)
|
if (container is LocalFolder localFolder)
|
||||||
{
|
{
|
||||||
ProcessKey(Registry.ClassesRoot.OpenSubKey("Directory"), menuItems, localFolder.Directory.FullName);
|
using var directoryKey = Registry.ClassesRoot.OpenSubKey("Directory");
|
||||||
|
ProcessRegistryKey(directoryKey, menuItems, localFolder.Directory.FullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return menuItems;
|
return menuItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessKey(RegistryKey? contextMenuContainer, List<object> menuItems, string folderPath)
|
private void ProcessRegistryKey(RegistryKey? contextMenuContainer, List<object> menuItems, string folderPath)
|
||||||
{
|
{
|
||||||
var shell = contextMenuContainer?.OpenSubKey("shell");
|
using var shell = contextMenuContainer?.OpenSubKey("shell");
|
||||||
if (shell == null) return;
|
if (shell == null) return;
|
||||||
|
|
||||||
var shellSubKeys = shell.GetSubKeyNames();
|
var shellSubKeys = shell.GetSubKeyNames();
|
||||||
@@ -63,18 +66,36 @@ namespace FileTime.Avalonia.Services
|
|||||||
{
|
{
|
||||||
text = text.Replace("&", "");
|
text = text.Replace("&", "");
|
||||||
|
|
||||||
if (shellKey.GetSubKeyNames().Contains("command") && shellKey.OpenSubKey("command")?.GetValue(null) is string commandString)
|
object? image = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var item = new MenuItem() { Header = text };
|
if (shellKey.GetValue("Icon") is string iconPath)
|
||||||
|
{
|
||||||
|
var imagePath = WindowsSystemIconHelper.GetImagePathByIconPath(iconPath);
|
||||||
|
if (imagePath.Type == Models.ImagePathType.Raw)
|
||||||
|
{
|
||||||
|
image = new Image()
|
||||||
|
{
|
||||||
|
Source = (IImage)imagePath.Image!
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
using var commandKey = shellKey.OpenSubKey("command");
|
||||||
|
if (shellKey.GetSubKeyNames().Contains("command") && commandKey?.GetValue(null) is string commandString)
|
||||||
|
{
|
||||||
|
var item = new MenuItem() { Header = text, Icon = image };
|
||||||
item.Click += (o, e) => MenuItemClick(folderPath, commandString);
|
item.Click += (o, e) => MenuItemClick(folderPath, commandString);
|
||||||
menuItems.Add(item);
|
menuItems.Add(item);
|
||||||
}
|
}
|
||||||
else if (shellKey.GetValue("ExtendedSubCommandsKey") is string extendedCommands)
|
else if (shellKey.GetValue("ExtendedSubCommandsKey") is string extendedCommands)
|
||||||
{
|
{
|
||||||
var rootMenu = new MenuItem() { Header = text };
|
var rootMenu = new MenuItem() { Header = text, Icon = image };
|
||||||
var rootMenuItems = new List<object>();
|
var rootMenuItems = new List<object>();
|
||||||
|
|
||||||
ProcessKey(Registry.ClassesRoot.OpenSubKey(extendedCommands), rootMenuItems, folderPath);
|
ProcessRegistryKey(Registry.ClassesRoot.OpenSubKey(extendedCommands), rootMenuItems, folderPath);
|
||||||
|
|
||||||
rootMenu.Items = rootMenuItems.ToArray();
|
rootMenu.Items = rootMenuItems.ToArray();
|
||||||
menuItems.Add(rootMenu);
|
menuItems.Add(rootMenu);
|
||||||
@@ -104,10 +125,6 @@ namespace FileTime.Avalonia.Services
|
|||||||
{
|
{
|
||||||
for (var i2 = 0; i2 < commandParts[i].Count; i2++)
|
for (var i2 = 0; i2 < commandParts[i].Count; i2++)
|
||||||
{
|
{
|
||||||
/*var commandPart = commandParts[i][i2];
|
|
||||||
|
|
||||||
if (commandPart == "%1" || commandPart == "%V") commandParts[i][i2] = folderPath;*/
|
|
||||||
|
|
||||||
commandParts[i][i2] = commandParts[i][i2].Replace("%1", folderPath).Replace("%V", folderPath);
|
commandParts[i][i2] = commandParts[i][i2].Replace("%1", folderPath).Replace("%V", folderPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +162,7 @@ namespace FileTime.Avalonia.Services
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var process = new Process();
|
using var process = new Process();
|
||||||
process.StartInfo.FileName = commandPartsWithoutEmpty[0];
|
process.StartInfo.FileName = commandPartsWithoutEmpty[0];
|
||||||
process.StartInfo.Arguments = arguments;
|
process.StartInfo.Arguments = arguments;
|
||||||
process.Start();
|
process.Start();
|
||||||
@@ -170,7 +187,7 @@ namespace FileTime.Avalonia.Services
|
|||||||
var (paramStartX, paramStartY) = GetCoordinatesFrom(commandParts, 1, 0, lastExecutablePart);
|
var (paramStartX, paramStartY) = GetCoordinatesFrom(commandParts, 1, 0, lastExecutablePart);
|
||||||
arguments = SumList(commandParts, paramStartX, paramStartY);
|
arguments = SumList(commandParts, paramStartX, paramStartY);
|
||||||
|
|
||||||
var process = new Process();
|
using var process = new Process();
|
||||||
process.StartInfo.FileName = executable;
|
process.StartInfo.FileName = executable;
|
||||||
process.StartInfo.Arguments = arguments;
|
process.StartInfo.Arguments = arguments;
|
||||||
process.Start();
|
process.Start();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace FileTime.Avalonia.ViewModels
|
|||||||
{
|
{
|
||||||
[ViewModel]
|
[ViewModel]
|
||||||
[Inject(typeof(ItemNameConverterService))]
|
[Inject(typeof(ItemNameConverterService))]
|
||||||
public partial class ContainerViewModel : IItemViewModel, IDisposable
|
public partial class ContainerViewModel : IItemViewModel
|
||||||
{
|
{
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
private bool _isRefreshing;
|
private bool _isRefreshing;
|
||||||
@@ -321,20 +321,9 @@ namespace FileTime.Avalonia.ViewModels
|
|||||||
return _items;
|
return _items;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ContainerViewModel()
|
private void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(false);
|
if (!_disposed)
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (!_disposed && disposing)
|
|
||||||
{
|
{
|
||||||
Container.Refreshed.Remove(Container_Refreshed);
|
Container.Refreshed.Remove(Container_Refreshed);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ namespace FileTime.Avalonia.ViewModels
|
|||||||
|
|
||||||
for (var i = 0; i < itemsToRemove.Count; i++)
|
for (var i = 0; i < itemsToRemove.Count; i++)
|
||||||
{
|
{
|
||||||
itemsToRemove[i].Dispose();
|
itemsToRemove[i].Destroy();
|
||||||
TimelineCommands.Remove(itemsToRemove[i]);
|
TimelineCommands.Remove(itemsToRemove[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ namespace FileTime.Avalonia.ViewModels
|
|||||||
|
|
||||||
for (var i = 0; i < commandVMsToRemove.Count; i++)
|
for (var i = 0; i < commandVMsToRemove.Count; i++)
|
||||||
{
|
{
|
||||||
commandVMsToRemove[i].Dispose();
|
commandVMsToRemove[i].Destroy();
|
||||||
parallelCommandsVM.ParallelCommands.Remove(commandVMsToRemove[i]);
|
parallelCommandsVM.ParallelCommands.Remove(commandVMsToRemove[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System;
|
|
||||||
using FileTime.Core.Timeline;
|
using FileTime.Core.Timeline;
|
||||||
using MvvmGen;
|
using MvvmGen;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@@ -8,7 +6,7 @@ using System.Collections.ObjectModel;
|
|||||||
namespace FileTime.Avalonia.ViewModels
|
namespace FileTime.Avalonia.ViewModels
|
||||||
{
|
{
|
||||||
[ViewModel]
|
[ViewModel]
|
||||||
public partial class ParallelCommandsViewModel : IDisposable
|
public partial class ParallelCommandsViewModel
|
||||||
{
|
{
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
@@ -22,24 +20,13 @@ namespace FileTime.Avalonia.ViewModels
|
|||||||
Id = parallelCommands.Id;
|
Id = parallelCommands.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ParallelCommandsViewModel()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
Dispose(false);
|
if (!_disposed)
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (!_disposed && disposing)
|
|
||||||
{
|
{
|
||||||
foreach(var commandVm in ParallelCommands)
|
foreach(var commandVm in ParallelCommands)
|
||||||
{
|
{
|
||||||
commandVm.Dispose();
|
commandVm.Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using MvvmGen;
|
|||||||
namespace FileTime.Avalonia.ViewModels
|
namespace FileTime.Avalonia.ViewModels
|
||||||
{
|
{
|
||||||
[ViewModel]
|
[ViewModel]
|
||||||
public partial class ParallelCommandViewModel : IDisposable
|
public partial class ParallelCommandViewModel
|
||||||
{
|
{
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
@@ -39,20 +39,9 @@ namespace FileTime.Avalonia.ViewModels
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ParallelCommandViewModel()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
Dispose(false);
|
if (!_disposed)
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (!_disposed && disposing)
|
|
||||||
{
|
{
|
||||||
_commandTimeState.Command.ProgressChanged.Remove(HandleProgressChange);
|
_commandTimeState.Command.ProgressChanged.Remove(HandleProgressChange);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace FileTime.Providers.Local
|
|||||||
|
|
||||||
public bool SupportsDirectoryLevelSoftDelete => false;
|
public bool SupportsDirectoryLevelSoftDelete => false;
|
||||||
|
|
||||||
public bool IsDisposed => false;
|
public bool IsDestroyed => false;
|
||||||
|
|
||||||
public LocalContentProvider(ILogger<LocalContentProvider> logger)
|
public LocalContentProvider(ILogger<LocalContentProvider> logger)
|
||||||
{
|
{
|
||||||
@@ -103,7 +103,7 @@ namespace FileTime.Providers.Local
|
|||||||
public Task Rename(string newName) => throw new NotSupportedException();
|
public Task Rename(string newName) => throw new NotSupportedException();
|
||||||
public Task<bool> CanOpen() => Task.FromResult(true);
|
public Task<bool> CanOpen() => Task.FromResult(true);
|
||||||
|
|
||||||
public void Dispose()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
foreach (var c in _rootContainers)
|
foreach (var c in _rootContainers)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace FileTime.Providers.Local
|
|||||||
|
|
||||||
private readonly LocalFolder _parent;
|
private readonly LocalFolder _parent;
|
||||||
|
|
||||||
public bool IsDisposed { get; private set; }
|
public bool IsDestroyed { get; private set; }
|
||||||
|
|
||||||
public LocalFile(FileInfo file, LocalFolder parent, IContentProvider contentProvider)
|
public LocalFile(FileInfo file, LocalFolder parent, IContentProvider contentProvider)
|
||||||
{
|
{
|
||||||
@@ -86,6 +86,6 @@ namespace FileTime.Providers.Local
|
|||||||
public async Task<string> GetContent(CancellationToken token = default) => await System.IO.File.ReadAllTextAsync(File.FullName, token);
|
public async Task<string> GetContent(CancellationToken token = default) => await System.IO.File.ReadAllTextAsync(File.FullName, token);
|
||||||
public Task<long> GetElementSize(CancellationToken token = default) => Task.FromResult(File.Length);
|
public Task<long> GetElementSize(CancellationToken token = default) => Task.FromResult(File.Length);
|
||||||
|
|
||||||
public void Dispose() => IsDisposed = true;
|
public void Destroy() => IsDestroyed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ namespace FileTime.Providers.Local
|
|||||||
public DateTime CreatedAt => Directory.CreationTime;
|
public DateTime CreatedAt => Directory.CreationTime;
|
||||||
public IReadOnlyList<Exception> Exceptions { get; }
|
public IReadOnlyList<Exception> Exceptions { get; }
|
||||||
|
|
||||||
public bool IsDisposed { get; private set; }
|
public bool IsDestroyed { get; private set; }
|
||||||
|
|
||||||
public bool SupportsDirectoryLevelSoftDelete { get; }
|
public bool SupportsDirectoryLevelSoftDelete { get; }
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ namespace FileTime.Providers.Local
|
|||||||
{
|
{
|
||||||
foreach (var item in _items)
|
foreach (var item in _items)
|
||||||
{
|
{
|
||||||
item.Dispose();
|
item.Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,12 +185,12 @@ namespace FileTime.Providers.Local
|
|||||||
}
|
}
|
||||||
public Task<bool> CanOpen() => Task.FromResult(true);
|
public Task<bool> CanOpen() => Task.FromResult(true);
|
||||||
|
|
||||||
public void Dispose()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
_items = null;
|
_items = null;
|
||||||
_containers = null;
|
_containers = null;
|
||||||
_elements = null;
|
_elements = null;
|
||||||
IsDisposed = true;
|
IsDestroyed = true;
|
||||||
Refreshed = new AsyncEventHandler();
|
Refreshed = new AsyncEventHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace FileTime.Providers.Smb
|
|||||||
|
|
||||||
public bool SupportsDirectoryLevelSoftDelete => false;
|
public bool SupportsDirectoryLevelSoftDelete => false;
|
||||||
|
|
||||||
public bool IsDisposed => false;
|
public bool IsDestroyed => false;
|
||||||
|
|
||||||
public SmbContentProvider(IInputInterface inputInterface)
|
public SmbContentProvider(IInputInterface inputInterface)
|
||||||
{
|
{
|
||||||
@@ -105,7 +105,7 @@ namespace FileTime.Providers.Smb
|
|||||||
public Task Rename(string newName) => throw new NotSupportedException();
|
public Task Rename(string newName) => throw new NotSupportedException();
|
||||||
public Task<bool> CanOpen() => Task.FromResult(true);
|
public Task<bool> CanOpen() => Task.FromResult(true);
|
||||||
|
|
||||||
public void Dispose() { }
|
public void Destroy() { }
|
||||||
|
|
||||||
public void Unload() { }
|
public void Unload() { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace FileTime.Providers.Smb
|
|||||||
public IContentProvider Provider { get; }
|
public IContentProvider Provider { get; }
|
||||||
private IContainer _parent;
|
private IContainer _parent;
|
||||||
|
|
||||||
public bool IsDisposed { get; private set; }
|
public bool IsDestroyed { get; private set; }
|
||||||
|
|
||||||
public SmbFile(string name, SmbContentProvider provider, IContainer parent)
|
public SmbFile(string name, SmbContentProvider provider, IContainer parent)
|
||||||
{
|
{
|
||||||
@@ -48,6 +48,6 @@ namespace FileTime.Providers.Smb
|
|||||||
public Task<string> GetContent(CancellationToken token = default) => Task.FromResult("NotImplemented");
|
public Task<string> GetContent(CancellationToken token = default) => Task.FromResult("NotImplemented");
|
||||||
public Task<long> GetElementSize(CancellationToken token = default) => Task.FromResult(-1L);
|
public Task<long> GetElementSize(CancellationToken token = default) => Task.FromResult(-1L);
|
||||||
|
|
||||||
public void Dispose() => IsDisposed = true;
|
public void Destroy() => IsDestroyed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ namespace FileTime.Providers.Smb
|
|||||||
public AsyncEventHandler Refreshed { get; } = new();
|
public AsyncEventHandler Refreshed { get; } = new();
|
||||||
public IReadOnlyList<Exception> Exceptions { get; } = new List<Exception>().AsReadOnly();
|
public IReadOnlyList<Exception> Exceptions { get; } = new List<Exception>().AsReadOnly();
|
||||||
|
|
||||||
public bool IsDisposed { get; private set; }
|
public bool IsDestroyed { get; private set; }
|
||||||
|
|
||||||
public bool SupportsDirectoryLevelSoftDelete => false;
|
public bool SupportsDirectoryLevelSoftDelete => false;
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ namespace FileTime.Providers.Smb
|
|||||||
{
|
{
|
||||||
foreach (var item in _items)
|
foreach (var item in _items)
|
||||||
{
|
{
|
||||||
item.Dispose();
|
item.Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ namespace FileTime.Providers.Smb
|
|||||||
}
|
}
|
||||||
public Task<bool> CanOpen() => Task.FromResult(true);
|
public Task<bool> CanOpen() => Task.FromResult(true);
|
||||||
|
|
||||||
public void Dispose() => IsDisposed = true;
|
public void Destroy() => IsDestroyed = true;
|
||||||
|
|
||||||
public void Unload()
|
public void Unload()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace FileTime.Providers.Smb
|
|||||||
|
|
||||||
public bool SupportsDirectoryLevelSoftDelete => false;
|
public bool SupportsDirectoryLevelSoftDelete => false;
|
||||||
|
|
||||||
public bool IsDisposed => false;
|
public bool IsDestroyed => false;
|
||||||
|
|
||||||
public SmbServer(string path, SmbContentProvider contentProvider, IInputInterface inputInterface)
|
public SmbServer(string path, SmbContentProvider contentProvider, IInputInterface inputInterface)
|
||||||
{
|
{
|
||||||
@@ -193,7 +193,7 @@ namespace FileTime.Providers.Smb
|
|||||||
public Task Rename(string newName) => throw new NotSupportedException();
|
public Task Rename(string newName) => throw new NotSupportedException();
|
||||||
public Task<bool> CanOpen() => Task.FromResult(true);
|
public Task<bool> CanOpen() => Task.FromResult(true);
|
||||||
|
|
||||||
public void Dispose() { }
|
public void Destroy() { }
|
||||||
|
|
||||||
public void Unload() { }
|
public void Unload() { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace FileTime.Providers.Smb
|
|||||||
public AsyncEventHandler Refreshed { get; } = new();
|
public AsyncEventHandler Refreshed { get; } = new();
|
||||||
public IReadOnlyList<Exception> Exceptions { get; } = new List<Exception>().AsReadOnly();
|
public IReadOnlyList<Exception> Exceptions { get; } = new List<Exception>().AsReadOnly();
|
||||||
|
|
||||||
public bool IsDisposed => false;
|
public bool IsDestroyed => false;
|
||||||
|
|
||||||
public bool SupportsDirectoryLevelSoftDelete => false;
|
public bool SupportsDirectoryLevelSoftDelete => false;
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ namespace FileTime.Providers.Smb
|
|||||||
{
|
{
|
||||||
foreach (var item in _items)
|
foreach (var item in _items)
|
||||||
{
|
{
|
||||||
item.Dispose();
|
item.Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ namespace FileTime.Providers.Smb
|
|||||||
public Task Rename(string newName) => throw new NotSupportedException();
|
public Task Rename(string newName) => throw new NotSupportedException();
|
||||||
public Task<bool> CanOpen() => Task.FromResult(true);
|
public Task<bool> CanOpen() => Task.FromResult(true);
|
||||||
|
|
||||||
public void Dispose() { }
|
public void Destroy() { }
|
||||||
|
|
||||||
public void Unload()
|
public void Unload()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user