Linux GUI preparations
This commit is contained in:
@@ -16,6 +16,9 @@ namespace FileTime.Uno.Models
|
||||
[Property]
|
||||
private string _name;
|
||||
|
||||
[Property]
|
||||
private string _fullName;
|
||||
|
||||
[Property]
|
||||
private long _size;
|
||||
|
||||
@@ -35,6 +38,7 @@ namespace FileTime.Uno.Models
|
||||
_container = container;
|
||||
|
||||
Name = container.Name;
|
||||
FullName = container.FullName;
|
||||
Size = driveInfo.TotalSize;
|
||||
Free = driveInfo.AvailableFreeSpace;
|
||||
Used = driveInfo.TotalSize - driveInfo.AvailableFreeSpace;
|
||||
|
||||
@@ -15,6 +15,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.System;
|
||||
|
||||
@@ -81,9 +82,11 @@ namespace FileTime.Uno.ViewModels
|
||||
_tabs.Add(new TabControlViewModel(1, tabContainer));
|
||||
|
||||
var driveInfos = new List<RootDriveInfo>();
|
||||
foreach (var drive in DriveInfo.GetDrives())
|
||||
foreach (var drive in DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed))
|
||||
{
|
||||
var container = (await LocalContentProvider.GetRootContainers()).FirstOrDefault(d => d.Name == drive.Name.TrimEnd(Path.DirectorySeparatorChar));
|
||||
var container = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
||||
? await GetContainerForWindowsDrive(drive)
|
||||
: await GetContainerForLinuxDrive(drive);
|
||||
if (container != null)
|
||||
{
|
||||
var driveInfo = new RootDriveInfo(drive, container);
|
||||
@@ -91,9 +94,20 @@ namespace FileTime.Uno.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: order by
|
||||
RootDriveInfos = driveInfos;
|
||||
}
|
||||
|
||||
private async Task<IContainer> GetContainerForWindowsDrive(DriveInfo drive)
|
||||
{
|
||||
return (await LocalContentProvider.GetRootContainers()).FirstOrDefault(d => d.Name == drive.Name.TrimEnd(Path.DirectorySeparatorChar));
|
||||
}
|
||||
|
||||
private async Task<IContainer> GetContainerForLinuxDrive(DriveInfo drive)
|
||||
{
|
||||
return await LocalContentProvider.GetByPath(drive.Name) as IContainer;
|
||||
}
|
||||
|
||||
public async Task OpenContainer()
|
||||
{
|
||||
AppState.RapidTravelText = "";
|
||||
|
||||
@@ -15,9 +15,15 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
|
||||
<PackageReference Include="MvvmGen" Version="1.1.2" />
|
||||
<PackageReference Include="Uno.WinUI.Skia.Gtk" Version="4.0.11" />
|
||||
<PackageReference Include="Uno.WinUI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" />
|
||||
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\FileTime.Uno.Shared\FileTime.Uno.Shared.projitems" Label="Shared" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\AppCommon\FileTime.App.Core\FileTime.App.Core.csproj" />
|
||||
<ProjectReference Include="..\..\..\AppCommon\FileTime.App.DependencyInjection\FileTime.App.DependencyInjection.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -15,9 +15,15 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
|
||||
<PackageReference Include="MvvmGen" Version="1.1.2" />
|
||||
<PackageReference Include="Uno.WinUI.Skia.Linux.FrameBuffer" Version="4.0.11" />
|
||||
<PackageReference Include="Uno.WinUI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" />
|
||||
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\FileTime.Uno.Shared\FileTime.Uno.Shared.projitems" Label="Shared" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\AppCommon\FileTime.App.Core\FileTime.App.Core.csproj" />
|
||||
<ProjectReference Include="..\..\..\AppCommon\FileTime.App.DependencyInjection\FileTime.App.DependencyInjection.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -45,6 +45,9 @@ namespace FileTime.Providers.Local
|
||||
public async Task<IItem?> GetByPath(string path)
|
||||
{
|
||||
var pathParts = (IsCaseInsensitive ? path.ToLower() : path).TrimStart(Constants.SeparatorChar).Split(Constants.SeparatorChar);
|
||||
|
||||
if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && pathParts.Length == 1 && pathParts[0] == "") return this;
|
||||
|
||||
var rootContainer = _rootContainers.FirstOrDefault(c => NormalizePath(c.Name) == NormalizePath(pathParts[0]));
|
||||
|
||||
if (rootContainer == null)
|
||||
@@ -53,7 +56,8 @@ namespace FileTime.Providers.Local
|
||||
return null;
|
||||
}
|
||||
|
||||
return await rootContainer.GetByPath(string.Join(Constants.SeparatorChar, pathParts.Skip(1)));
|
||||
var remainingPath = string.Join(Constants.SeparatorChar, pathParts.Skip(1));
|
||||
return remainingPath.Length == 0 ? rootContainer : await rootContainer.GetByPath(remainingPath);
|
||||
}
|
||||
|
||||
public async Task Refresh() => await Refreshed.InvokeAsync(this, AsyncEventArgs.Empty);
|
||||
|
||||
Reference in New Issue
Block a user