diff --git a/Documentation/VectoHashingTool/help.html b/Documentation/VectoHashingTool/HashingToolHelp.html similarity index 100% rename from Documentation/VectoHashingTool/help.html rename to Documentation/VectoHashingTool/HashingToolHelp.html diff --git a/Documentation/VectoHashingTool/convert.bat b/Documentation/VectoHashingTool/convert.bat index 0859ac62f3f5c0313d8fcc8ac873c4420185d810..bcd246ff8656ff80b39976c0c11fc33e8df4c56c 100644 --- a/Documentation/VectoHashingTool/convert.bat +++ b/Documentation/VectoHashingTool/convert.bat @@ -9,7 +9,7 @@ for /f %%f in (files.txt) do set LIST=!LIST! "%%f" REM pandoc --verbose -f markdown+raw_html %LIST% -s -S --toc --toc-depth=2 --self-contained --email-obfuscation=none --section-divs --mathjax=includes/mathjax.js -c includes/style.css -c includes/print.css -B includes/header.html -A includes/footer.html -o help.html -H includes/jquery.js -H includes/jquery-ui.js -H includes/include.js -%LOCALAPPDATA%\Pandoc\pandoc --verbose -f markdown+raw_html %LIST% -s -S --toc --toc-depth=2 --self-contained --email-obfuscation=none --section-divs --webtex -c includes/style.css -c includes/print.css -B includes/header.html -A includes/footer.html -o help.html -H includes/jquery.js -H includes/jquery-ui.js -H includes/include.js +%LOCALAPPDATA%\Pandoc\pandoc --verbose -f markdown+raw_html %LIST% -s -S --toc --toc-depth=2 --self-contained --email-obfuscation=none --section-divs --webtex -c includes/style.css -c includes/print.css -B includes/header.html -A includes/footer.html -o HashingToolHelp.html -H includes/jquery.js -H includes/jquery-ui.js -H includes/include.js REM pandoc %LIST% -s -S --toc --toc-depth=2 --self-contained --email-obfuscation=none --section-divs --webtex -c includes/style.css -B includes/header.html -A includes/footer.html -o help.html -H includes/jquery.js -H includes/jquery-ui.js -H includes/include.js REM pandoc %LIST% -s -S --toc --toc-depth=2 --self-contained --email-obfuscation=none --section-divs --webtex="https://latex.codecogs.com/svg.latex?\large " -c includes/style.css -B includes/header.html -A includes/footer.html -o help.html -H includes/jquery.js -H includes/jquery-ui.js -H includes/include.js diff --git a/Documentation/VectoHashingTool/includes/header.html b/Documentation/VectoHashingTool/includes/header.html index f29ca04835a41fe97114f8ccf314282bd7424984..ad3d93a37551fed3918b691c89c0c30c95c22e91 100644 --- a/Documentation/VectoHashingTool/includes/header.html +++ b/Documentation/VectoHashingTool/includes/header.html @@ -1,7 +1,7 @@ <div id="HEADER"> <div style="float:left"> - <a href="help.html"><img style="vertical-align:middle" alt="VECTO-Logo" src="images/VECTO_Hashing-small.png"></a> - <a href="help.html">User Manual</a> + <a href="HashingToolHelp.html"><img style="vertical-align:middle" alt="VECTO-Logo" src="images/VECTO_Hashing-small.png"></a> + <a href="HashingToolHelp.html">User Manual</a> </div> <div style="text-align: right"> <a href="https://ec.europa.eu/jrc/" target="_blank"><img style="border: 0px solid; width: 173px; height: 36px;" alt="JRC-Logo" src="images/JRC.png" hspace="5"></a> diff --git a/HashingTool/HashingTool.csproj b/HashingTool/HashingTool.csproj index 043b5f7e02fb851cfafa768b60b63d65737f7077..94b078c10c96fd7cb1e74050e9f5ba2f1b9b360e 100644 --- a/HashingTool/HashingTool.csproj +++ b/HashingTool/HashingTool.csproj @@ -66,6 +66,7 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </ApplicationDefinition> + <Compile Include="Helper\BrowserHelper.cs" /> <Compile Include="Helper\CollectionConverter.cs" /> <Compile Include="Helper\CultureAwareBinding.cs" /> <Compile Include="Helper\HashingHelper.cs" /> diff --git a/HashingTool/Helper/BrowserHelper.cs b/HashingTool/Helper/BrowserHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..93c8dc1a64e300b70b03ccd304085469f5926ff0 --- /dev/null +++ b/HashingTool/Helper/BrowserHelper.cs @@ -0,0 +1,53 @@ +using Microsoft.Win32; + +namespace HashingTool.Helper +{ + public class BrowserHelper + { + public static string GetDefaultBrowserPath() + { + var urlAssociation = @"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http"; + var browserPathKey = @"$BROWSER$\shell\open\command"; + + // Dim browserPath As String + + // 'Read default browser path from userChoiceLKey + var userChoiceKey = Registry.CurrentUser.OpenSubKey(urlAssociation + @"\UserChoice", false); + + if (userChoiceKey == null) { + // 'If user choice was not found, try machine default + // 'Read default browser path from Win XP registry key, or try Win Vista (and newer) registry key + var browserKey = Registry.ClassesRoot.OpenSubKey(@"HTTP\shell\open\command", false) ?? + Registry.CurrentUser.OpenSubKey(urlAssociation, false); + if (browserKey == null) { + return ""; + } + + var path = browserKey.GetValue("").ToString(); + browserKey.Close(); + if (path.Contains(".exe")) { + return path.Substring(1, path.IndexOf(".exe") + 3); + } else { + return path; + } + } + // ' user defined browser choice was found + var progId = userChoiceKey.GetValue("ProgId").ToString(); + userChoiceKey.Close(); + + // ' now look up the path of the executable + var concreteBrowserKey = browserPathKey.Replace("$BROWSER$", progId); + var kp = Registry.ClassesRoot.OpenSubKey(concreteBrowserKey, false); + if (kp == null) { + return ""; + } + var browserPath = kp.GetValue("").ToString(); + kp.Close(); + if (browserPath.Contains(".exe")) { + return browserPath.Substring(1, browserPath.IndexOf(".exe") + 3); + } else { + return browserPath; + } + } + } +} diff --git a/HashingTool/MainWindow.xaml b/HashingTool/MainWindow.xaml index 14a2e02c5a8710024b0bb16f7ce7f35872bdaa83..2b6ad1f7dd5f38a6518d565e7d967574d2bfbc6f 100644 --- a/HashingTool/MainWindow.xaml +++ b/HashingTool/MainWindow.xaml @@ -4,7 +4,7 @@ xmlns:viewModel="clr-namespace:HashingTool.ViewModel" xmlns:views="clr-namespace:HashingTool.Views" x:Class="HashingTool.MainWindow" - Title="VECTO Hashing Tool" Height="590" Width="800" MinWidth="800" MinHeight="600" Icon="Resources/HashingIcon.ico"> + Title="{Binding VersionInformation}" Height="590" Width="800" MinWidth="800" MinHeight="600" Icon="Resources/HashingIcon.ico"> <Window.DataContext> <viewModel:ApplicationViewModel /> </Window.DataContext> diff --git a/HashingTool/MainWindow.xaml.cs b/HashingTool/MainWindow.xaml.cs index 9c954fd61e13dd3b17f44874f5daa7fd4f4d3866..595ac0c005784d990b325cef7267a071be8d6cca 100644 --- a/HashingTool/MainWindow.xaml.cs +++ b/HashingTool/MainWindow.xaml.cs @@ -29,8 +29,13 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; +using System.Diagnostics; +using System.IO; using System.Windows; using System.Windows.Input; +using HashingTool.Helper; +using HashingTool.ViewModel; using HashingTool.Views; namespace HashingTool @@ -48,13 +53,22 @@ namespace HashingTool private void About_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { var dialog = new AboutDialog(); - + var applicationViewModel = DataContext as ApplicationViewModel; + if (applicationViewModel != null) { + dialog.Title = applicationViewModel.VersionInformation; + } dialog.ShowDialog(); } private void Help_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { - throw new System.NotImplementedException(); + var myAppPath = AppDomain.CurrentDomain.BaseDirectory; + if (File.Exists(myAppPath + @"User Manual\HashingToolHelp.html")) { + var defaultBrowserPath = BrowserHelper.GetDefaultBrowserPath(); + Process.Start(defaultBrowserPath, string.Format("\"file://{0}{1}\"", myAppPath, @"User Manual\HashingToolHelp.html")); + } else { + MessageBox.Show("User Manual not found!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } } } } diff --git a/HashingTool/ViewModel/ApplicationViewModel.cs b/HashingTool/ViewModel/ApplicationViewModel.cs index bd6d998a9af783e9f85addc558be037f8bf158e1..3de5a76f30e38918d5b69780fb2e221864cd9021 100644 --- a/HashingTool/ViewModel/ApplicationViewModel.cs +++ b/HashingTool/ViewModel/ApplicationViewModel.cs @@ -32,7 +32,9 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.IO; using System.Linq; +using System.Reflection; using System.Windows; using System.Windows.Input; using HashingTool.Views; @@ -46,6 +48,8 @@ namespace HashingTool.ViewModel private IMainView _currentView; public static List<IMainView> AvailableViews; + private string _hashingLib; + private string _myVersion; public ApplicationViewModel() { @@ -60,6 +64,18 @@ namespace HashingTool.ViewModel CurrentViewModel = homeView; HomeView = new RelayCommand(() => CurrentViewModel = homeView); + + try { + _hashingLib = Assembly.LoadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VectoHashing.dll")) + .GetName().Version.ToString(); + } catch (Exception) { + _hashingLib = "NOT FOUND"; + } + try { + _myVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + } catch (Exception) { + _myVersion = "NOT FOUND"; + } } public List<IMainView> MainViewModels @@ -98,5 +114,10 @@ namespace HashingTool.ViewModel CurrentViewModel = MainViewModels.FirstOrDefault(mv => mv == mainView); } + + public string VersionInformation + { + get { return string.Format("Vecto Hashing Tool {0} / Hashing Library {1}", _myVersion, _hashingLib); } + } } }