Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 10af773f authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

HahsingTool: show version information, link user manual

parent 037c2e8f
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
<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>
......
......@@ -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" />
......
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;
}
}
}
}
......@@ -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>
......
......@@ -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);
}
}
}
}
......@@ -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); }
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment