del /Q /S /F "%~dp0\%%i\*.*"
)
+for %%i in (bin,MHashDotNet384.Example\obj,MHashDotNet384.Wrapper\obj) do (
+ del /Q /S /F "%~dp0\bindings\Microsoft.NET\%%i\*.*"
+)
+
REM ///////////////////////////////////////////////////////////////////////////
REM // Build the binaries
"%~dp0\tools\cecho" YELLOW "\n========[ COMPILE ]========\n"
call "%MSVC_PATH%\vcvarsall.bat"
-for %%p in (x86,x64) do (
- MSBuild.exe /property:Platform=%%p /property:Configuration=Release /target:Clean "%~dp0\MHashLib.sln"
- if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
- MSBuild.exe /property:Platform=%%p /property:Configuration=Release /target:Rebuild "%~dp0\MHashLib.sln"
- if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
+for %%q in (MHashLib.sln,bindings\Microsoft.NET\MHashDotNet384.sln) do (
+ for %%p in (x86,x64) do (
+ MSBuild.exe /property:Platform=%%p /property:Configuration=Release /target:Clean "%~dp0\%%~q"
+ if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
+ MSBuild.exe /property:Platform=%%p /property:Configuration=Release /target:Rebuild "%~dp0\%%~q"
+ if not "!ERRORLEVEL!"=="0" goto BuildHasFailed
+ )
)
set REVISON=
:GenerateOutfileNameNext
-set "OUT_PATH_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.msvc-x86.zip"
-set "OUT_PATH_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.msvc-x64.zip"
-set "OUT_PATH_SRC=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.src.tar.gz"
+set "OUT_PATH_BIN_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.bin-msvc-x86.zip"
+set "OUT_PATH_BIN_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.bin-msvc-x64.zip"
+set "OUT_PATH_NET_X86=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.dotnet-x86.zip"
+set "OUT_PATH_NET_X64=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.dotnet-x64.zip"
+set "OUT_PATH_SRC_GEN=%~dp0\out\mhash_384.%ISO_DATE%%REVISON%.src.tar.gz"
set /a COUNTER=COUNTER+1
set REVISON=.update-%COUNTER%
-if exist "%OUT_PATH_X86%" goto GenerateOutfileNameNext
-if exist "%OUT_PATH_X64%" goto GenerateOutfileNameNext
-if exist "%OUT_PATH_SRC%" goto GenerateOutfileNameNext
+if exist "%OUT_PATH_BIN_X86%" goto GenerateOutfileNameNext
+if exist "%OUT_PATH_BIN_X64%" goto GenerateOutfileNameNext
+if exist "%OUT_PATH_NET_X86%" goto GenerateOutfileNameNext
+if exist "%OUT_PATH_NET_X64%" goto GenerateOutfileNameNext
+if exist "%OUT_PATH_SRC_GEN%" goto GenerateOutfileNameNext
REM ///////////////////////////////////////////////////////////////////////////
"%~dp0\tools\cecho" YELLOW "\n========[ PACKAGING ]========\n"
-"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_X86%" "%~dp0\bin\Win32\Release\mhash_384.x86.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
-"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_X64%" "%~dp0\bin\x64\.\Release\mhash_384.x64.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
+"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_BIN_X86%" "%~dp0\bin\Win32\Release\mhash_384.x86.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
+"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_BIN_X64%" "%~dp0\bin\x64\.\Release\mhash_384.x64.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
+
+"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_NET_X86%" "%~dp0\bindings\Microsoft.NET\bin\x86\Release\MHashDotNet384.x86.dll" "%~dp0\bindings\Microsoft.NET\bin\x86\Release\MHashDotNet384.Example.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
+"%~dp0\tools\zip.exe" -j -9 -z "%OUT_PATH_NET_X64%" "%~dp0\bindings\Microsoft.NET\bin\x64\Release\MHashDotNet384.x64.dll" "%~dp0\bindings\Microsoft.NET\bin\x64\Release\MHashDotNet384.Example.exe" "%~dp0\README.html" "%~dp0\COPYING.txt" < "%~dp0\COPYING.txt"
-"%GIT2_PATH%\git.exe" archive --format tar.gz -9 --verbose --output "%OUT_PATH_SRC%" HEAD
+"%GIT2_PATH%\git.exe" archive --format tar.gz -9 --verbose --output "%OUT_PATH_SRC_GEN%" HEAD
REM ///////////////////////////////////////////////////////////////////////////
<PropertyGroup>
<ApplicationIcon>exe.ico</ApplicationIcon>
</PropertyGroup>
+ <PropertyGroup>
+ <StartupObject>MHashDotNet384.Example.App</StartupObject>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MHashDotNet384.Example"
- StartupUri="MainWindow.xaml">
+ StartupUri="src/MainWindow.xaml">
<Application.Resources>
</Application.Resources>
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MHashDotNet384.Example"
mc:Ignorable="d"
- Title="MHashDotNet384 - Example App" Height="192" Width="768"
- WindowStartupLocation="CenterScreen" WindowStyle="ToolWindow" ResizeMode="CanMinimize" Loaded="Window_Loaded">
+ Title="MHashDotNet384 - Example App" Height="224" Width="768"
+ WindowStartupLocation="CenterScreen" WindowStyle="ToolWindow" ResizeMode="CanMinimize"
+ Loaded="Window_Loaded" Closing="Window_Closing">
<DockPanel Margin="8">
<TextBlock DockPanel.Dock="Top" FontWeight="Bold">Input File:</TextBlock>
<TextBox DockPanel.Dock="Top" IsReadOnly="True" Name="Edit_FileName"></TextBox>
<TextBlock DockPanel.Dock="Top" FontWeight="Bold" Margin="0,12,0,0">Hash Value (Digest):</TextBlock>
<TextBox DockPanel.Dock="Top" Name="Edit_HashValue" FontFamily="Courier New" IsReadOnly="True"></TextBox>
+ <ProgressBar DockPanel.Dock="Top" Height="18" Name="ProgressIndicator" Margin="0,16,0,0" Minimum="0" Maximum="1"></ProgressBar>
<Grid DockPanel.Dock="Bottom" Margin="0,16,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
using Microsoft.Win32;
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.IO;
using System.Text;
using System.Windows;
Title += String.Format(" v{0:D}.{1:D}.{2:D}", major, minor, patch);
}
+ private void Window_Closing(object sender, CancelEventArgs e)
+ {
+ if(!(Button_Browse.IsEnabled && Button_Compute.IsEnabled))
+ {
+ e.Cancel = true;
+ }
+ }
+
private void Button_BrowseClick(object sender, RoutedEventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
private void Button_ComputeClick(object sender, RoutedEventArgs e)
{
- Edit_HashValue.Text = String.Empty;
- Label_Working.Visibility = Visibility.Visible;
- Button_Browse.IsEnabled = Button_Compute.IsEnabled = false;
- Mouse.OverrideCursor = Cursors.Wait;
+ if(String.IsNullOrWhiteSpace(Edit_FileName.Text))
+ {
+ MessageBox.Show("Please select an input file first!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
try
{
- byte[] buffer = new byte[4096];
- using (FileStream fs = File.OpenRead(Edit_FileName.Text))
+ Edit_HashValue.Text = String.Empty;
+ ProgressIndicator.Value = 0.0;
+ Label_Working.Visibility = Visibility.Visible;
+ Button_Browse.IsEnabled = Button_Compute.IsEnabled = false;
+ Mouse.OverrideCursor = Cursors.Wait; FileInfo info = new FileInfo(Edit_FileName.Text);
+ using (FileStream fs = info.OpenRead())
{
using (MHashDotNet.MHash384 digest = new MHashDotNet.MHash384())
{
+ short update = 0;
+ byte[] buffer = new byte[4096];
while (true)
{
- Dispatcher.Invoke(new Action(() => {}), DispatcherPriority.ContextIdle, null);
+ if((update++ & 0x3FF) == 0)
+ {
+ ProgressIndicator.Value = (double)fs.Position / (double)info.Length;
+ DispatchPendingEvents();
+ }
int count = fs.Read(buffer, 0, buffer.Length);
if (count > 0)
{
}
finally
{
+ ProgressIndicator.Value = 1.0;
Label_Working.Visibility = Visibility.Hidden;
Button_Browse.IsEnabled = Button_Compute.IsEnabled = true;
Mouse.OverrideCursor = null;
}
}
+
+ private readonly Action dummyAction = new Action(() => { });
+
+ private void DispatchPendingEvents()
+ {
+ Dispatcher.Invoke(dummyAction, DispatcherPriority.ContextIdle, null);
+ }
}
}
<Keyword>ManagedCProj</Keyword>
<RootNamespace>MHashDotNet384</RootNamespace>
<ProjectName>MHashDotNet384.Wrapper</ProjectName>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
- <OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
- <IntDir>$(ProjectDir)\obj\$(Platform)\$(Configuration)\</IntDir>
- <TargetName>MHashDotNet384.$(Platform)</TargetName>
+ <OutDir>$(SolutionDir)\bin\$(PlatformShortName)\$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)\obj\$(PlatformShortName)\$(Configuration)\</IntDir>
+ <TargetName>MHashDotNet384.$(PlatformShortName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
- <OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
- <IntDir>$(ProjectDir)\obj\$(Platform)\$(Configuration)\</IntDir>
- <TargetName>MHashDotNet384.$(Platform)</TargetName>
+ <OutDir>$(SolutionDir)\bin\$(PlatformShortName)\$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)\obj\$(PlatformShortName)\$(Configuration)\</IntDir>
+ <TargetName>MHashDotNet384.$(PlatformShortName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
- <OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
- <IntDir>$(ProjectDir)\obj\$(Platform)\$(Configuration)\</IntDir>
- <TargetName>MHashDotNet384.$(Platform)</TargetName>
+ <OutDir>$(SolutionDir)\bin\$(PlatformShortName)\$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)\obj\$(PlatformShortName)\$(Configuration)\</IntDir>
+ <TargetName>MHashDotNet384.$(PlatformShortName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
- <OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir>
- <IntDir>$(ProjectDir)\obj\$(Platform)\$(Configuration)\</IntDir>
- <TargetName>MHashDotNet384.$(Platform)</TargetName>
+ <OutDir>$(SolutionDir)\bin\$(PlatformShortName)\$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)\obj\$(PlatformShortName)\$(Configuration)\</IntDir>
+ <TargetName>MHashDotNet384.$(PlatformShortName)</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>