Linux GUI preparations

This commit is contained in:
2022-01-24 10:32:09 +01:00
parent aacbaa3a02
commit 896b58f542
7 changed files with 209 additions and 101 deletions

View File

@@ -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 = "";