diff --git a/HashingTool/Helper/BrowserHelper.cs b/HashingTool/Helper/BrowserHelper.cs deleted file mode 100644 index 884163cbd47cc40d873642995a2216e67010976a..0000000000000000000000000000000000000000 --- a/HashingTool/Helper/BrowserHelper.cs +++ /dev/null @@ -1,84 +0,0 @@ -/* -* 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; - } - } - } -} diff --git a/HashingTool/MainWindow.xaml.cs b/HashingTool/MainWindow.xaml.cs index 6df0c8c1fc2d74bf1bae9392e0387d4ef0bb3295..c664137f8c979bd66a25471aed9d8d26517c72cd 100644 --- a/HashingTool/MainWindow.xaml.cs +++ b/HashingTool/MainWindow.xaml.cs @@ -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); } diff --git a/HashingTool/Views/AboutDialog.xaml.cs b/HashingTool/Views/AboutDialog.xaml.cs index 0291d0cf5c0c83d7b27356ab2101b5caa5f621f6..2b00369fadc4a74e2abae6612ec9c96c9d546b62 100644 --- a/HashingTool/Views/AboutDialog.xaml.cs +++ b/HashingTool/Views/AboutDialog.xaml.cs @@ -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}); } }