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

Skip to content
Snippets Groups Projects
Commit cdf8c580 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

[HashingTool] Changed help directory

parent 6bdcb217
No related branches found
No related tags found
No related merge requests found
/*
* This file is part of VECTO.
*
* Copyright © 2012-2019 European Union
*
* Developed by Graz University of Technology,
* Institute of Internal Combustion Engines and Thermodynamics,
* Institute of Technical Informatics
*
* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved
* by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use VECTO except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* https://joinup.ec.europa.eu/community/eupl/og_page/eupl
*
* Unless required by applicable law or agreed to in writing, VECTO
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* Authors:
* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology
* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology
* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology
* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology
* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using Microsoft.Win32;
namespace HashingTool.Helper
{
public static 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;
}
}
}
}
......@@ -34,7 +34,6 @@ using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Input;
using HashingTool.Helper;
using HashingTool.ViewModel;
using HashingTool.Views;
......@@ -53,8 +52,7 @@ namespace HashingTool
private void About_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
var dialog = new AboutDialog();
var applicationViewModel = DataContext as ApplicationViewModel;
if (applicationViewModel != null) {
if (DataContext is ApplicationViewModel applicationViewModel) {
dialog.Title = applicationViewModel.VersionInformation;
}
dialog.ShowDialog();
......@@ -62,10 +60,9 @@ namespace HashingTool
private void Help_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
var myAppPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..");
if (File.Exists(myAppPath + @"User Manual\HashingToolHelp.html")) {
var defaultBrowserPath = BrowserHelper.GetDefaultBrowserPath();
Process.Start(defaultBrowserPath, $"\"file://{Path.Combine(myAppPath, @"User Manual\HashingToolHelp.html")}\"");
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", @"User Manual\HashingToolHelp.html");
if (File.Exists(path)) {
Process.Start(new ProcessStartInfo(path) { UseShellExecute = true});
} else {
MessageBox.Show("User Manual not found!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
......
......@@ -30,7 +30,6 @@
*/
using System.Diagnostics;
using System.Windows;
using System.Windows.Input;
namespace HashingTool.Views
......@@ -38,22 +37,15 @@ namespace HashingTool.Views
/// <summary>
/// Interaction logic for AboutDialog.xaml
/// </summary>
public partial class AboutDialog : Window
public partial class AboutDialog
{
public AboutDialog()
{
public AboutDialog() =>
InitializeComponent();
}
private void EUPL_Link(object sender, MouseButtonEventArgs e)
{
Process.Start("https://joinup.ec.europa.eu/community/eupl/og_page/eupl");
private void EUPL_Link(object sender, MouseButtonEventArgs e) =>
Process.Start(new ProcessStartInfo("https://joinup.ec.europa.eu/community/eupl/og_page/eupl") { UseShellExecute = true});
}
private void Supportmail(object sender, MouseButtonEventArgs e)
{
Process.Start("mailto:JRC-VECTO@ec.europa.eu");
}
private void Supportmail(object sender, MouseButtonEventArgs e) =>
Process.Start(new ProcessStartInfo("mailto:JRC-VECTO@ec.europa.eu") {UseShellExecute = true});
}
}
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