-
Notifications
You must be signed in to change notification settings - Fork 45
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ac67f0d
added support for shell icons on Windows
iksi4prs befc589
cleanup
iksi4prs 1188739
Refactored using icons to avoid casts
IngvarX f13a258
Fixed tests for Icons
IngvarX b30cae6
Used path service and minor refactoring
IngvarX bf9f947
Adjusted stylings in shell icons files
IngvarX 98f4b77
Camelot.ViewModels.Windows restructuring
IngvarX c7b4e2e
fixed, case where value is wrapped with double-quotes
iksi4prs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/Camelot.Services.Abstractions/IIconsSettingsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
13
src/Camelot.Services.Abstractions/Models/IconsSettingsModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
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
14
src/Camelot.ViewModels.Windows/Camelot.ViewModels.Windows.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
6 changes: 6 additions & 0 deletions
6
src/Camelot.ViewModels.Windows/Interfaces/IShellLinkResolver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.