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

82
.vscode/launch.json vendored
View File

@@ -1,24 +1,62 @@
{ {
// Use IntelliSense to learn about possible attributes. // Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes. // Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": ".NET Core Launch (console)", "name": ".NET Core Launch (console)",
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "build", "preLaunchTask": "build",
"program": "${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI/bin/Debug/net6.0/FileTime.ConsoleUI.dll", "program": "${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI/bin/Debug/net6.0/FileTime.ConsoleUI.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI", "cwd": "${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI",
"console": "internalConsole", "console": "internalConsole",
"stopAtEntry": false "stopAtEntry": false
}, },
{ {
"name": ".NET Core Attach", "name": ".NET Core Attach",
"type": "coreclr", "type": "coreclr",
"request": "attach" "request": "attach"
} },
] {
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": "Skia.GTK (Debug)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-skia-gtk",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/GuiApp/FileTime.Uno/FileTime.Uno.Skia.Gtk/bin/Debug/net6.0/FileTime.Uno.Skia.Gtk.dll",
"args": [],
"env": {
"DOTNET_MODIFIABLE_ASSEMBLIES": "debug"
},
"cwd": "${workspaceFolder}/src/GuiApp/FileTime.Uno/FileTime.Uno.Skia.Gtk",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": "Skia.Linux.FrameBuffer (Debug)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-skia-gtk",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/GuiApp/FileTime.Uno/FileTime.Uno.Skia.Linux.FrameBuffer/bin/Debug/net6.0/FileTime.Uno.Skia.Linux.FrameBuffer.dll",
"args": [],
"env": {
"DOTNET_MODIFIABLE_ASSEMBLIES": "debug"
},
"cwd": "${workspaceFolder}/src/GuiApp/FileTime.Uno/FileTime.Uno.Skia.Linux.FrameBuffer",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
}
]
} }

184
.vscode/tasks.json vendored
View File

@@ -1,76 +1,112 @@
{ {
"version": "2.0.0", "version": "2.0.0",
"tasks": [ "tasks": [
{ {
"label": "build", "label": "build",
"command": "dotnet", "command": "dotnet",
"type": "process", "type": "process",
"args": [ "args": [
"build", "build",
"${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI/FileTime.ConsoleUI.csproj", "${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI/FileTime.ConsoleUI.csproj",
"/property:GenerateFullPaths=true", "/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary" "/consoleloggerparameters:NoSummary"
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{ {
"label": "publish", "label": "publish",
"command": "dotnet", "command": "dotnet",
"type": "process", "type": "process",
"args": [ "args": [
"publish", "publish",
"${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI/FileTime.ConsoleUI.csproj", "${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI/FileTime.ConsoleUI.csproj",
"/property:GenerateFullPaths=true", "/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary" "/consoleloggerparameters:NoSummary"
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{ {
"label": "publish singlefile linux", "label": "publish singlefile linux",
"command": "dotnet", "command": "dotnet",
"type": "process", "type": "process",
"args": [ "args": [
"publish", "publish",
"${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI/FileTime.ConsoleUI.csproj", "${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI/FileTime.ConsoleUI.csproj",
"-p:PublishSingleFile=true", "-p:PublishSingleFile=true",
"-c", "-c",
"Release", "Release",
"-r", "-r",
"linux-x64", "linux-x64",
"--self-contained", "--self-contained",
"true" "true"
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{ {
"label": "publish singlefile windows", "label": "publish singlefile windows",
"command": "dotnet", "command": "dotnet",
"type": "process", "type": "process",
"args": [ "args": [
"publish", "publish",
"${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI/FileTime.ConsoleUI.csproj", "${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI/FileTime.ConsoleUI.csproj",
"-p:PublishSingleFile=true", "-p:PublishSingleFile=true",
"-c", "-c",
"Release", "Release",
"-r", "-r",
"win-x64", "win-x64",
"--self-contained", "--self-contained",
"true" "true"
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{ {
"label": "watch", "label": "watch",
"command": "dotnet", "command": "dotnet",
"type": "process", "type": "process",
"args": [ "args": [
"watch", "watch",
"run", "run",
"${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI/FileTime.ConsoleUI.csproj", "${workspaceFolder}/src/ConsoleApp/FileTime.ConsoleUI/FileTime.ConsoleUI.csproj",
"/property:GenerateFullPaths=true", "/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary" "/consoleloggerparameters:NoSummary"
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
} },
] {
"label": "build-skia-gtk",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/GuiApp/FileTime.Uno/FileTime.Uno.Skia.Gtk/FileTime.Uno.Skia.Gtk.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish-skia-gtk",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src//GuiApp/FileTime.Uno/FileTime.Uno.Skia.Gtk/FileTime.Uno.Skia.Gtk.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "build-skia-framebuffer",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/GuiApp/FileTime.Uno/FileTime.Uno.Skia.Linux.FrameBuffer/FileTime.Uno.Skia.Linux.FrameBuffer.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
]
} }

View File

@@ -16,6 +16,9 @@ namespace FileTime.Uno.Models
[Property] [Property]
private string _name; private string _name;
[Property]
private string _fullName;
[Property] [Property]
private long _size; private long _size;
@@ -35,6 +38,7 @@ namespace FileTime.Uno.Models
_container = container; _container = container;
Name = container.Name; Name = container.Name;
FullName = container.FullName;
Size = driveInfo.TotalSize; Size = driveInfo.TotalSize;
Free = driveInfo.AvailableFreeSpace; Free = driveInfo.AvailableFreeSpace;
Used = driveInfo.TotalSize - driveInfo.AvailableFreeSpace; Used = driveInfo.TotalSize - driveInfo.AvailableFreeSpace;

View File

@@ -15,6 +15,7 @@ using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using Windows.System; using Windows.System;
@@ -81,9 +82,11 @@ namespace FileTime.Uno.ViewModels
_tabs.Add(new TabControlViewModel(1, tabContainer)); _tabs.Add(new TabControlViewModel(1, tabContainer));
var driveInfos = new List<RootDriveInfo>(); 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) if (container != null)
{ {
var driveInfo = new RootDriveInfo(drive, container); var driveInfo = new RootDriveInfo(drive, container);
@@ -91,9 +94,20 @@ namespace FileTime.Uno.ViewModels
} }
} }
//TODO: order by
RootDriveInfos = driveInfos; 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() public async Task OpenContainer()
{ {
AppState.RapidTravelText = ""; AppState.RapidTravelText = "";

View File

@@ -15,9 +15,15 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" 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.Skia.Gtk" Version="4.0.11" />
<PackageReference Include="Uno.WinUI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" /> <PackageReference Include="Uno.WinUI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" /> <PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" />
</ItemGroup> </ItemGroup>
<Import Project="..\FileTime.Uno.Shared\FileTime.Uno.Shared.projitems" Label="Shared" /> <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> </Project>

View File

@@ -15,9 +15,15 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" 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.Skia.Linux.FrameBuffer" Version="4.0.11" />
<PackageReference Include="Uno.WinUI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" /> <PackageReference Include="Uno.WinUI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" /> <PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" />
</ItemGroup> </ItemGroup>
<Import Project="..\FileTime.Uno.Shared\FileTime.Uno.Shared.projitems" Label="Shared" /> <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> </Project>

View File

@@ -45,6 +45,9 @@ namespace FileTime.Providers.Local
public async Task<IItem?> GetByPath(string path) public async Task<IItem?> GetByPath(string path)
{ {
var pathParts = (IsCaseInsensitive ? path.ToLower() : path).TrimStart(Constants.SeparatorChar).Split(Constants.SeparatorChar); 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])); var rootContainer = _rootContainers.FirstOrDefault(c => NormalizePath(c.Name) == NormalizePath(pathParts[0]));
if (rootContainer == null) if (rootContainer == null)
@@ -53,7 +56,8 @@ namespace FileTime.Providers.Local
return null; 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); public async Task Refresh() => await Refreshed.InvokeAsync(this, AsyncEventArgs.Empty);