Skip to content

Commit e92928d

Browse files
committed
Commit inicial
1 parent 51e7686 commit e92928d

10 files changed

Lines changed: 212 additions & 24 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
obj/
2+
bin/
3+
.vs

App.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="get_files_hash_checksum.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:get_files_hash_checksum"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>

App.xaml.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace get_files_hash_checksum
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}

AssemblyInfo.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]

LICENSE

Lines changed: 0 additions & 24 deletions
This file was deleted.

MainWindow.xaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Window x:Class="get_files_hash_checksum.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
mc:Ignorable="d"
7+
Title="File hash checksum" Height="450" Width="800">
8+
9+
<Grid>
10+
<DockPanel Margin="10">
11+
<WrapPanel HorizontalAlignment="Center" Orientation="Horizontal" DockPanel.Dock="Top" Margin="0,0,0,10">
12+
<Button Name="btnGetDirectory" Click="btnGetDirectory_Click" Width="145" Height="25" Margin="10">Select files/directories</Button>
13+
<WrapPanel Orientation="Vertical">
14+
<WrapPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="5">
15+
<CheckBox Content="Start Patch" Margin="5,0,0,0" VerticalContentAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding startPathCkecked}"/>
16+
<TextBox TextWrapping="Wrap" Width="365" Margin="5,0,0,0" VerticalContentAlignment="Center" VerticalAlignment="Center" Text="{Binding startPath}"/>
17+
</WrapPanel>
18+
<WrapPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="5">
19+
<CheckBox Content="Base Download Link" Margin="5,0,0,0" VerticalContentAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding startDlLinkCkecked}"/>
20+
<TextBox TextWrapping="Wrap" Width="315" Margin="5,0,0,0" VerticalContentAlignment="Center" VerticalAlignment="Center" Text="{Binding startDlLink}"/>
21+
</WrapPanel>
22+
</WrapPanel>
23+
</WrapPanel>
24+
<TextBox Name="textBoxResult" Text="{Binding stringResult}" />
25+
</DockPanel>
26+
</Grid>
27+
</Window>

MainWindow.xaml.cs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
using Microsoft.Win32;
2+
using Newtonsoft.Json;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.ComponentModel;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using System.Windows;
11+
using System.Windows.Controls;
12+
using System.Windows.Data;
13+
using System.Windows.Documents;
14+
using System.Windows.Input;
15+
using System.Windows.Media;
16+
using System.Windows.Media.Imaging;
17+
using System.Windows.Navigation;
18+
19+
20+
namespace get_files_hash_checksum
21+
{
22+
/// <summary>
23+
/// Interaction logic for MainWindow.xaml
24+
/// </summary>
25+
public partial class MainWindow : Window
26+
{
27+
public MainWindow()
28+
{
29+
InitializeComponent();
30+
DataContext = this;
31+
}
32+
33+
public bool startPathCkecked { get; set; } = false;
34+
public bool startDlLinkCkecked { get; set; } = false;
35+
public string startPath { get; set; } = @"C:\";
36+
public string startDlLink { get; set; } = @"https://";
37+
public OpenFileDialog selectedFiles { get; set; } = null;
38+
public string stringResult { get; set; } = "Select files to show result";
39+
40+
41+
private void btnGetDirectory_Click(object sender, RoutedEventArgs e)
42+
{
43+
ListOfFiles.Clear();
44+
45+
OpenFileDialog openFileDialog = new OpenFileDialog() { Multiselect = true, CheckFileExists = true, CheckPathExists = true, Title = "Select what you want to checksum", InitialDirectory = startPathCkecked && Directory.Exists(startPath) ? startPath : null};
46+
if (openFileDialog.ShowDialog() == true)
47+
{
48+
selectedFiles = openFileDialog;
49+
50+
foreach(string filePath in openFileDialog.FileNames)
51+
{
52+
ListOfFiles.Add(new FileParameters() { DlLink = startDlLinkCkecked && Uri.IsWellFormedUriString(startDlLink, UriKind.Absolute) && File.Exists(filePath) && startPathCkecked && Directory.Exists(startPath) ? new Uri(new Uri(startDlLink, UriKind.Absolute), Path.GetRelativePath(startPath + '/', filePath), false).AbsoluteUri : null, FileName = Path.GetFileName(filePath), Path = startPathCkecked ? Directory.Exists(startPath) ? Path.GetRelativePath(startPath, filePath).Replace(@"//", @"/").Replace(@"\\", @"\").Replace(@"\", @"/") : null : Directory.Exists(startPath) ? Path.GetFullPath(filePath) : null, Sha256 = File.Exists(filePath) ? FileSHA256(filePath) : null }); ;
53+
}
54+
55+
textBoxResult.Text = JsonConvert.SerializeObject(ListOfFiles, Formatting.Indented);
56+
MessageBox.Show(JsonConvert.SerializeObject(ListOfFiles, Formatting.Indented));
57+
}
58+
}
59+
60+
public static string FileSHA256(string filePath)
61+
{
62+
using System.Security.Cryptography.SHA256 hashAlgorithm = System.Security.Cryptography.SHA256.Create();
63+
using (FileStream stream = System.IO.File.OpenRead(filePath))
64+
{
65+
return BitConverter.ToString(hashAlgorithm.ComputeHash(stream)).Replace("-", "").ToUpper();
66+
}
67+
}
68+
69+
70+
public static List<FileParameters> ListOfFiles { get; set; } = new();
71+
public partial class FileParameters
72+
{
73+
[JsonProperty("dlLink", NullValueHandling = NullValueHandling.Ignore)]
74+
public string DlLink { get; set; }
75+
76+
[JsonProperty("path", NullValueHandling = NullValueHandling.Ignore)]
77+
public string Path { get; set; }
78+
79+
[JsonProperty("fileName", NullValueHandling = NullValueHandling.Ignore)]
80+
public string FileName { get; set; }
81+
82+
[JsonProperty("sha256", NullValueHandling = NullValueHandling.Ignore)]
83+
public string Sha256 { get; set; }
84+
}
85+
}
86+
}

get-files-hash-checksum.csproj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net5.0-windows</TargetFramework>
6+
<RootNamespace>get_files_hash_checksum</RootNamespace>
7+
<UseWPF>true</UseWPF>
8+
9+
</PropertyGroup>
10+
11+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
12+
<PlatformTarget>x86</PlatformTarget>
13+
<Prefer32Bit>true</Prefer32Bit>
14+
<DefineConstants />
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
<ItemGroup>
5+
<ApplicationDefinition Update="App.xaml">
6+
<SubType>Designer</SubType>
7+
</ApplicationDefinition>
8+
</ItemGroup>
9+
<ItemGroup>
10+
<Page Update="MainWindow.xaml">
11+
<SubType>Designer</SubType>
12+
</Page>
13+
</ItemGroup>
14+
</Project>

get-files-hash-checksum.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31402.337
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "get-files-hash-checksum", "get-files-hash-checksum.csproj", "{75CBD968-A7D1-4789-9623-7211AA908147}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{75CBD968-A7D1-4789-9623-7211AA908147}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{75CBD968-A7D1-4789-9623-7211AA908147}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{75CBD968-A7D1-4789-9623-7211AA908147}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{75CBD968-A7D1-4789-9623-7211AA908147}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {C152D84E-E966-4CCA-917A-4B4F7652A954}
24+
EndGlobalSection
25+
EndGlobal

0 commit comments

Comments
 (0)