Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for shell icons for files on Windows #63

Merged
merged 8 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 46 additions & 32 deletions Camelot.sln
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Camelot.WindowsInstaller",
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Installers", "Installers", "{AF27253D-17E1-40F0-A0C2-4BDD3089D71E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Camelot.Ui.Tests", "tests\Camelot.Ui.Tests\Camelot.Ui.Tests.csproj", "{FEB5ABE3-EF9C-4BBC-A398-80058551E91A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Camelot.Ui.Tests", "tests\Camelot.Ui.Tests\Camelot.Ui.Tests.csproj", "{FEB5ABE3-EF9C-4BBC-A398-80058551E91A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionFiles", "SolutionFiles", "{7A44F288-C9F3-4965-892B-CD08B0643C9C}"
ProjectSection(SolutionItems) = preProject
nuget.config = nuget.config
camelot.desktop = camelot.desktop
EndProjectSection
ProjectSection(SolutionItems) = preProject
camelot.desktop = camelot.desktop
nuget.config = nuget.config
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Camelot.Collections", "src\Camelot.Collections\Camelot.Collections.csproj", "{8745C732-67D4-4BCC-9593-71318000EA9F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Camelot.Collections", "src\Camelot.Collections\Camelot.Collections.csproj", "{8745C732-67D4-4BCC-9593-71318000EA9F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Camelot.Collections.Tests", "tests\Camelot.Collections.Tests\Camelot.Collections.Tests.csproj", "{8E2BD3FE-A5E7-4284-A90B-2D1FED4096CA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Camelot.Collections.Tests", "tests\Camelot.Collections.Tests\Camelot.Collections.Tests.csproj", "{8E2BD3FE-A5E7-4284-A90B-2D1FED4096CA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ViewModels", "ViewModels", "{AFFFF1F0-873D-4F22-9581-F6A37E5274B8}"
EndProject
Expand All @@ -108,6 +108,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platform", "Platform", "{AE
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platform", "Platform", "{6364BC20-0498-42EF-BCC5-7F190978D2C2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platform", "Platform", "{8D4F2A1A-12E7-4107-B8C8-E7CE0E670453}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Camelot.ViewModels.Windows", "src\Camelot.ViewModels.Windows\Camelot.ViewModels.Windows.csproj", "{44B7391D-1773-45BB-A3A5-CC535A527B6C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -378,60 +382,70 @@ Global
{8E2BD3FE-A5E7-4284-A90B-2D1FED4096CA}.Release|Any CPU.Build.0 = Release|Any CPU
{8E2BD3FE-A5E7-4284-A90B-2D1FED4096CA}.Release|x86.ActiveCfg = Release|Any CPU
{8E2BD3FE-A5E7-4284-A90B-2D1FED4096CA}.Release|x86.Build.0 = Release|Any CPU
{44B7391D-1773-45BB-A3A5-CC535A527B6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44B7391D-1773-45BB-A3A5-CC535A527B6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44B7391D-1773-45BB-A3A5-CC535A527B6C}.Debug|x86.ActiveCfg = Debug|Any CPU
{44B7391D-1773-45BB-A3A5-CC535A527B6C}.Debug|x86.Build.0 = Debug|Any CPU
{44B7391D-1773-45BB-A3A5-CC535A527B6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44B7391D-1773-45BB-A3A5-CC535A527B6C}.Release|Any CPU.Build.0 = Release|Any CPU
{44B7391D-1773-45BB-A3A5-CC535A527B6C}.Release|x86.ActiveCfg = Release|Any CPU
{44B7391D-1773-45BB-A3A5-CC535A527B6C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C3A2056B-A0A2-44A4-B806-CF1E6B3B4CAB} = {41FE5FEA-BD5A-4286-BF4D-B1B92C6D24A3}
{B6895DB5-6D6A-4924-9789-A76C3C9D3A53} = {D72E4F66-DB0E-44A3-80DE-4E91081B06A5}
{C88C5F76-C3A9-47D8-A901-9FE2C0FEF280} = {D72E4F66-DB0E-44A3-80DE-4E91081B06A5}
{6ED2987C-67F5-4113-9829-75B79827F5D3} = {26C8BADF-C62E-4B8E-9CC6-34BFDD62341E}
{B3997F3B-F0B1-41CD-BCE8-CC3D83BC6FA7} = {26C8BADF-C62E-4B8E-9CC6-34BFDD62341E}
{6D18B985-1860-4A6B-A73A-E7309F7998B5} = {26C8BADF-C62E-4B8E-9CC6-34BFDD62341E}
{35EEA9C8-B6F4-4AF7-9B2A-A3582273D3A8} = {152EE21C-6799-4717-B96C-0DFB5AFA0FF0}
{99551F13-21D8-4577-8A5A-4D5215E90B2E} = {AF9C5BA7-F63A-4ACF-BA5F-D5726F91E928}
{DFADAC4D-BE3D-4975-B0B5-125C7CABB2B2} = {97ECC609-6DEA-4DBF-B0FF-9247763FABC2}
{E5B60907-7712-47AA-AD12-03D8C6B89290} = {AFFFF1F0-873D-4F22-9581-F6A37E5274B8}
{2AFFF0CB-AFE8-4763-86D9-8A8B61641351} = {AF9C5BA7-F63A-4ACF-BA5F-D5726F91E928}
{C48075E8-C406-4A79-A986-3228204A3F78} = {A972B7CB-7CD6-44E8-9EF3-D194134715CE}
{D2D52AF3-4099-4768-B793-D0B2B1D9F92E} = {AE33DB63-D35A-4E10-89DB-4B8FE973487A}
{A649EA2D-1595-4FF1-8159-9CA7B41DE96D} = {AE33DB63-D35A-4E10-89DB-4B8FE973487A}
{11AF1308-99CD-4F46-A24B-358E88BC3633} = {AE33DB63-D35A-4E10-89DB-4B8FE973487A}
{346F4751-DDF2-42D8-AA72-8B0441340793} = {AE33DB63-D35A-4E10-89DB-4B8FE973487A}
{26C8BADF-C62E-4B8E-9CC6-34BFDD62341E} = {3E7B6E0B-F769-48DF-B269-43B747D4A964}
{D72E4F66-DB0E-44A3-80DE-4E91081B06A5} = {3E7B6E0B-F769-48DF-B269-43B747D4A964}
{97ECC609-6DEA-4DBF-B0FF-9247763FABC2} = {3E7B6E0B-F769-48DF-B269-43B747D4A964}
{A67DE010-431F-4400-9137-0FBF610E2527} = {3E7B6E0B-F769-48DF-B269-43B747D4A964}
{152EE21C-6799-4717-B96C-0DFB5AFA0FF0} = {3E7B6E0B-F769-48DF-B269-43B747D4A964}
{AF27253D-17E1-40F0-A0C2-4BDD3089D71E} = {3E7B6E0B-F769-48DF-B269-43B747D4A964}
{085142E8-BC19-4D07-B5C4-6961156D12B6} = {AF9C5BA7-F63A-4ACF-BA5F-D5726F91E928}
{66071AF5-601D-41AC-A8B4-8240A21652CF} = {41FE5FEA-BD5A-4286-BF4D-B1B92C6D24A3}
{88F851D7-C12E-4C4E-AA49-268AC1B9FE18} = {6364BC20-0498-42EF-BCC5-7F190978D2C2}
{8A8B301D-CB87-40AD-A975-14C53CEDBAA0} = {6364BC20-0498-42EF-BCC5-7F190978D2C2}
{E31503D3-2EE2-4F8C-ACFD-7D1B3EBBEAE1} = {6364BC20-0498-42EF-BCC5-7F190978D2C2}
{8019CB6D-1787-4FC0-A75A-1A07A5ECCD41} = {AF9C5BA7-F63A-4ACF-BA5F-D5726F91E928}
{06FBDF39-EF80-44BA-ACF7-F3E0286A06C9} = {41FE5FEA-BD5A-4286-BF4D-B1B92C6D24A3}
{F10B06C5-F0B9-416C-91B6-FB94C22FD82A} = {6364BC20-0498-42EF-BCC5-7F190978D2C2}
{70D6D1F1-BE1D-4425-AE84-F7E9A00C999E} = {46395885-DDEE-490A-BD9B-F94E18F66D1A}
{0EA0C184-6C47-41FC-8B7A-8572B8F39EB5} = {9683B19E-A0F8-4ACD-88A4-B4EB643B504D}
{F45DBF3A-E17D-4855-BAF5-05A8F4C273B1} = {00A3B77D-9F02-4FD5-BCC8-2734A16703EA}
{3601BDA0-04D4-4CCE-96F1-0AA65F4800B2} = {AF9C5BA7-F63A-4ACF-BA5F-D5726F91E928}
{59D6D13A-17F7-4CCB-AAD7-3748BD559F1F} = {41FE5FEA-BD5A-4286-BF4D-B1B92C6D24A3}
{4AF845FA-DAEA-4B6C-A751-09E8DE6EEF0E} = {AF27253D-17E1-40F0-A0C2-4BDD3089D71E}
{AF27253D-17E1-40F0-A0C2-4BDD3089D71E} = {3E7B6E0B-F769-48DF-B269-43B747D4A964}
{FEB5ABE3-EF9C-4BBC-A398-80058551E91A} = {46395885-DDEE-490A-BD9B-F94E18F66D1A}
{7A44F288-C9F3-4965-892B-CD08B0643C9C} = {3E7B6E0B-F769-48DF-B269-43B747D4A964}
{8745C732-67D4-4BCC-9593-71318000EA9F} = {152EE21C-6799-4717-B96C-0DFB5AFA0FF0}
{8E2BD3FE-A5E7-4284-A90B-2D1FED4096CA} = {9683B19E-A0F8-4ACD-88A4-B4EB643B504D}
{AFFFF1F0-873D-4F22-9581-F6A37E5274B8} = {6E54E223-60FD-418C-B6E0-0EB9095C34D0}
{E5B60907-7712-47AA-AD12-03D8C6B89290} = {AFFFF1F0-873D-4F22-9581-F6A37E5274B8}
{00A3B77D-9F02-4FD5-BCC8-2734A16703EA} = {6E54E223-60FD-418C-B6E0-0EB9095C34D0}
{F45DBF3A-E17D-4855-BAF5-05A8F4C273B1} = {00A3B77D-9F02-4FD5-BCC8-2734A16703EA}
{46395885-DDEE-490A-BD9B-F94E18F66D1A} = {6E54E223-60FD-418C-B6E0-0EB9095C34D0}
{70D6D1F1-BE1D-4425-AE84-F7E9A00C999E} = {46395885-DDEE-490A-BD9B-F94E18F66D1A}
{FEB5ABE3-EF9C-4BBC-A398-80058551E91A} = {46395885-DDEE-490A-BD9B-F94E18F66D1A}
{9683B19E-A0F8-4ACD-88A4-B4EB643B504D} = {6E54E223-60FD-418C-B6E0-0EB9095C34D0}
{8E2BD3FE-A5E7-4284-A90B-2D1FED4096CA} = {9683B19E-A0F8-4ACD-88A4-B4EB643B504D}
{0EA0C184-6C47-41FC-8B7A-8572B8F39EB5} = {9683B19E-A0F8-4ACD-88A4-B4EB643B504D}
{41FE5FEA-BD5A-4286-BF4D-B1B92C6D24A3} = {6E54E223-60FD-418C-B6E0-0EB9095C34D0}
{59D6D13A-17F7-4CCB-AAD7-3748BD559F1F} = {41FE5FEA-BD5A-4286-BF4D-B1B92C6D24A3}
{66071AF5-601D-41AC-A8B4-8240A21652CF} = {41FE5FEA-BD5A-4286-BF4D-B1B92C6D24A3}
{06FBDF39-EF80-44BA-ACF7-F3E0286A06C9} = {41FE5FEA-BD5A-4286-BF4D-B1B92C6D24A3}
{C3A2056B-A0A2-44A4-B806-CF1E6B3B4CAB} = {41FE5FEA-BD5A-4286-BF4D-B1B92C6D24A3}
{A972B7CB-7CD6-44E8-9EF3-D194134715CE} = {A67DE010-431F-4400-9137-0FBF610E2527}
{C48075E8-C406-4A79-A986-3228204A3F78} = {A972B7CB-7CD6-44E8-9EF3-D194134715CE}
{AF9C5BA7-F63A-4ACF-BA5F-D5726F91E928} = {A67DE010-431F-4400-9137-0FBF610E2527}
{99551F13-21D8-4577-8A5A-4D5215E90B2E} = {AF9C5BA7-F63A-4ACF-BA5F-D5726F91E928}
{3601BDA0-04D4-4CCE-96F1-0AA65F4800B2} = {AF9C5BA7-F63A-4ACF-BA5F-D5726F91E928}
{2AFFF0CB-AFE8-4763-86D9-8A8B61641351} = {AF9C5BA7-F63A-4ACF-BA5F-D5726F91E928}
{085142E8-BC19-4D07-B5C4-6961156D12B6} = {AF9C5BA7-F63A-4ACF-BA5F-D5726F91E928}
{8019CB6D-1787-4FC0-A75A-1A07A5ECCD41} = {AF9C5BA7-F63A-4ACF-BA5F-D5726F91E928}
{AE33DB63-D35A-4E10-89DB-4B8FE973487A} = {AF9C5BA7-F63A-4ACF-BA5F-D5726F91E928}
{D2D52AF3-4099-4768-B793-D0B2B1D9F92E} = {AE33DB63-D35A-4E10-89DB-4B8FE973487A}
{11AF1308-99CD-4F46-A24B-358E88BC3633} = {AE33DB63-D35A-4E10-89DB-4B8FE973487A}
{A649EA2D-1595-4FF1-8159-9CA7B41DE96D} = {AE33DB63-D35A-4E10-89DB-4B8FE973487A}
{346F4751-DDF2-42D8-AA72-8B0441340793} = {AE33DB63-D35A-4E10-89DB-4B8FE973487A}
{6364BC20-0498-42EF-BCC5-7F190978D2C2} = {41FE5FEA-BD5A-4286-BF4D-B1B92C6D24A3}
{F10B06C5-F0B9-416C-91B6-FB94C22FD82A} = {6364BC20-0498-42EF-BCC5-7F190978D2C2}
{8A8B301D-CB87-40AD-A975-14C53CEDBAA0} = {6364BC20-0498-42EF-BCC5-7F190978D2C2}
{E31503D3-2EE2-4F8C-ACFD-7D1B3EBBEAE1} = {6364BC20-0498-42EF-BCC5-7F190978D2C2}
{88F851D7-C12E-4C4E-AA49-268AC1B9FE18} = {6364BC20-0498-42EF-BCC5-7F190978D2C2}
{8D4F2A1A-12E7-4107-B8C8-E7CE0E670453} = {97ECC609-6DEA-4DBF-B0FF-9247763FABC2}
{44B7391D-1773-45BB-A3A5-CC535A527B6C} = {8D4F2A1A-12E7-4107-B8C8-E7CE0E670453}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5C51E5E2-AA78-45DF-89AC-640A29AFB2DF}
Expand Down
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ignore:
- "src/Camelot.WindowsInstaller/**/*"
- "src/Camelot.DataAccess.Models/*"
- "src/Camelot.ViewModels/Configuration/*"
- "src/Camelot.ViewModels.Windows/WinApi/*"
- "src/Camelot.Services.Abstractions/**/*"
- "src/Camelot.DataAccess.LiteDb/**/*"
- "src/Camelot.DataAccess.LiteDb/*"
Expand Down
10 changes: 10 additions & 0 deletions src/Camelot.Services.Abstractions/IIconsSettingsService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Camelot.Services.Abstractions.Models;

namespace Camelot.Services.Abstractions;

public interface IIconsSettingsService
{
IconsSettingsModel GetIconsSettings();

void SaveIconsSettings(IconsSettingsModel iconsSettingsModel);
}
7 changes: 7 additions & 0 deletions src/Camelot.Services.Abstractions/Models/Enums/IconsType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Camelot.Services.Abstractions.Models.Enums;

public enum IconsType
{
Builtin,
Shell
}
13 changes: 13 additions & 0 deletions src/Camelot.Services.Abstractions/Models/IconsSettingsModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Camelot.Services.Abstractions.Models.Enums;

namespace Camelot.Services.Abstractions.Models;

public class IconsSettingsModel
{
public IconsType SelectedIconsType { get; }

public IconsSettingsModel(IconsType selectedIconsType)
{
SelectedIconsType = selectedIconsType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="System.Drawing.Common" Version="4.5.0" />
<PackageReference Update="Packaging.Targets">
<Version>0.1.220</Version>
</PackageReference>
Expand Down
4 changes: 3 additions & 1 deletion src/Camelot.Services.Windows/WinApi/Win32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public enum AssocStr
{
Command = 1,
Executable = 2,
FriendlyAppName = 4
FriendlyAppName = 4,
DefaultIcon = 15,
AppIconRreference = 23
}

[Flags]
Expand Down
59 changes: 59 additions & 0 deletions src/Camelot.Services/IconsSettingsService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using Camelot.DataAccess.UnitOfWork;
using Camelot.Services.Abstractions;
using Camelot.Services.Abstractions.Models;
using Camelot.Services.Abstractions.Models.Enums;
using Camelot.Services.Environment.Enums;
using Camelot.Services.Environment.Interfaces;

namespace Camelot.Services;

public class IconsSettingsService : IIconsSettingsService
{
private const string SettingsId = "IconsSettings";

private readonly IUnitOfWorkFactory _unitOfWorkFactory;

private readonly Platform _platform;
private readonly IconsSettingsModel _default;
private readonly IconsSettingsModel _builtin;

public IconsSettingsService(
IUnitOfWorkFactory unitOfWorkFactory,
IPlatformService platformService)
{
_unitOfWorkFactory = unitOfWorkFactory;

_platform = platformService.GetPlatform();
_default = new IconsSettingsModel(IconsType.Shell);
_builtin = new IconsSettingsModel(IconsType.Builtin);
}


public IconsSettingsModel GetIconsSettings()
{
if (_platform != Platform.Windows)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend to avoid platform-specific code here. Just allow to read/save as usual. See my comment regarding settings for more info

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept this as lower level possible, so implementers of feature for linux/mac, will have less to do.

return _builtin;

using var uow = _unitOfWorkFactory.Create();
var repository = uow.GetRepository<IconsSettingsModel>();

return repository.GetById(SettingsId) ?? _default;
}

public void SaveIconsSettings(IconsSettingsModel iconsSettingsModel)
{
if (_platform != Platform.Windows)
return;

if (iconsSettingsModel is null)
{
throw new ArgumentNullException(nameof(iconsSettingsModel));
}

using var uow = _unitOfWorkFactory.Create();
var repository = uow.GetRepository<IconsSettingsModel>();

repository.Upsert(SettingsId, iconsSettingsModel);
}
}
14 changes: 14 additions & 0 deletions src/Camelot.ViewModels.Windows/Camelot.ViewModels.Windows.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Camelot.Services.Windows\Camelot.Services.Windows.csproj" />
<ProjectReference Include="..\Camelot.ViewModels\Camelot.ViewModels.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Camelot.ViewModels.Windows.Interfaces;

public interface IShellLinkResolver
{
string ResolveLink(string path);
}
Loading
Loading