-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Feature: Added hashes tab to properties window #11521
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
Merged
Merged
Changes from 18 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
5879194
Introduce Hash page
0x5bfa 8406d90
Update src/Files.App/Strings/en-US/Resources.resw
0x5bfa ba8290e
Merge branch 'main' into 5bfa/introduce-hashprops
0x5bfa 1a1caf7
Revert unrelated changes
0x5bfa e599cb0
Merge branch '5bfa/introduce-hashprops' of https://github.com/onein52…
0x5bfa 62e2139
Merge branch 'main' into 5bfa/introduce-hashprops
0x5bfa 1e1f24c
Fix build issues
0x5bfa 8949bc7
Merge branch '5bfa/introduce-hashprops' of https://github.com/onein52…
0x5bfa cb88e71
Added some mockup code
0x5bfa b3c6288
Merge branch 'main' into 5bfa/introduce-hashprops
0x5bfa 96ddf12
Add collection for listing hashes
0x5bfa c64c71b
Merge branch '5bfa/introduce-hashprops' of https://github.com/onein52…
0x5bfa 9da531a
Merge branch 'main' into 5bfa/introduce-hashprops
0x5bfa 6f79819
Merge branch 'main' into 5bfa/introduce-hashprops
0x5bfa f3c0807
Update hashes page and fix NavigationStoreStyle
0x5bfa 8b2c25d
Merge branch '5bfa/introduce-hashprops' of https://github.com/onein52…
0x5bfa cecac16
Merge branch 'main' into 5bfa/introduce-hashprops
0x5bfa 9dac8dc
Merge branch 'main' into 5bfa/introduce-hashprops
yaira2 b0da4c1
Added tooltip
yaira2 615ea90
Fixed copy button
yaira2 38879d5
Try to make the file loader being high performance when loading large…
0x5bfa da51c14
Merge branch '5bfa/introduce-hashprops' of https://github.com/onein52…
0x5bfa 9ed28f5
Fix: Fix an issue where hash copy button doesn't work
0x5bfa ec681a9
Merge branch 'main' into 5bfa/introduce-hashprops
0x5bfa 1ba83f4
Feature: Add loading button on hashes page
0x5bfa d48b772
Merge branch '5bfa/introduce-hashprops' of https://github.com/onein52…
0x5bfa 104e159
Fix: Update the behaviour when loading hashes and displaying error on…
0x5bfa 101bba7
Feature: Introduce CancellationToken to hashes page
0x5bfa 9fcffc8
Fix: Change the way of firing file content loader method
0x5bfa 8979965
Trial and error 1
0x5bfa 541cbbe
Trial and error 2
0x5bfa 0d39d79
Fix up
0x5bfa e51a28f
Fix up again
0x5bfa 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 hidden or 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 hidden or 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 hidden or 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,137 @@ | ||
| using CommunityToolkit.Mvvm.ComponentModel; | ||
| using CommunityToolkit.Mvvm.Input; | ||
| using Files.App.DataModels.NavigationControlItems; | ||
| using Files.App.Extensions; | ||
| using Files.App.Filesystem; | ||
| using Files.App.Filesystem.Permissions; | ||
| using Files.App.Helpers; | ||
| using Files.Backend.Models; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Collections.ObjectModel; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using System.Security.Cryptography; | ||
| using Windows.ApplicationModel.DataTransfer; | ||
|
|
||
| namespace Files.App.ViewModels.Properties | ||
| { | ||
| public class HashesViewModel : ObservableObject | ||
| { | ||
| public HashesViewModel(ListedItem item) | ||
| { | ||
| Item = item; | ||
|
|
||
| Hashes = new(); | ||
|
|
||
| CopyHashValueCommand = new(ExecuteCopyHashValue, () => SelectedItem is not null); | ||
|
|
||
| try | ||
| { | ||
| _fileStream = File.OpenRead(item.ItemPath); | ||
| CanAccessFile = true; | ||
|
|
||
| GetHashes(); | ||
| } | ||
| catch | ||
| { | ||
| CanAccessFile = false; | ||
| } | ||
| } | ||
|
|
||
| public ListedItem Item { get; } | ||
|
|
||
| private readonly FileStream _fileStream; | ||
|
|
||
| private bool _canAccessFile; | ||
| public bool CanAccessFile | ||
| { | ||
| get => _canAccessFile; | ||
| set => SetProperty(ref _canAccessFile, value); | ||
| } | ||
|
|
||
| private HashInfoItem _selectedItem; | ||
| public HashInfoItem SelectedItem | ||
| { | ||
| get => _selectedItem; | ||
| set => SetProperty(ref _selectedItem, value); | ||
| } | ||
|
|
||
| public ObservableCollection<HashInfoItem> Hashes { get; set; } | ||
|
|
||
| public RelayCommand CopyHashValueCommand { get; set; } | ||
|
|
||
| private void GetHashes() | ||
| { | ||
| Hashes.Add(new() | ||
| { | ||
| Algorithm = "MD5", | ||
| HashValue = CreateMD5(), | ||
| }); | ||
| Hashes.Add(new() | ||
| { | ||
| Algorithm = "SHA1", | ||
| HashValue = CreateSHA1(), | ||
| }); | ||
| Hashes.Add(new() | ||
| { | ||
| Algorithm = "SHA256", | ||
| HashValue = CreateSHA256(), | ||
| }); | ||
| Hashes.Add(new() | ||
| { | ||
| Algorithm = "SHA384", | ||
| HashValue = CreateSHA384(), | ||
| }); | ||
| Hashes.Add(new() | ||
| { | ||
| Algorithm = "SHA512", | ||
| HashValue = CreateSHA512(), | ||
| }); | ||
| } | ||
|
|
||
| private string CreateMD5() | ||
| { | ||
| var hashBytes = MD5.HashData(_fileStream); | ||
|
|
||
| return Convert.ToHexString(hashBytes); | ||
| } | ||
|
|
||
| private string CreateSHA1() | ||
| { | ||
| var hashBytes = SHA1.HashData(_fileStream); | ||
|
|
||
| return Convert.ToHexString(hashBytes); | ||
| } | ||
|
|
||
| private string CreateSHA256() | ||
| { | ||
| var hashBytes = SHA256.HashData(_fileStream); | ||
|
|
||
| return Convert.ToHexString(hashBytes); | ||
| } | ||
|
|
||
| private string CreateSHA384() | ||
| { | ||
| var hashBytes = SHA384.HashData(_fileStream); | ||
|
|
||
| return Convert.ToHexString(hashBytes); | ||
| } | ||
|
|
||
| private string CreateSHA512() | ||
| { | ||
| var hashBytes = SHA512.HashData(_fileStream); | ||
|
|
||
| return Convert.ToHexString(hashBytes); | ||
| } | ||
|
|
||
| private void ExecuteCopyHashValue() | ||
| { | ||
| var dp = new DataPackage(); | ||
| dp.SetText(SelectedItem.HashValue); | ||
| Clipboard.SetContent(dp); | ||
| } | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.