diff --git a/GoAwayEdge/App.xaml.cs b/GoAwayEdge/App.xaml.cs index 561283b..b473f96 100644 --- a/GoAwayEdge/App.xaml.cs +++ b/GoAwayEdge/App.xaml.cs @@ -62,7 +62,7 @@ public void Application_Startup(object sender, StartupEventArgs e) Updater.InitialEnvironment(); #if DEBUG - var w = new MessageUI("GoAwayEdge", + var w = new MessageUi("GoAwayEdge", $"The following args are redirected (CTRL+C to copy):\n\n{argumentJoin}", "OK", null, true); w.ShowDialog(); #endif @@ -90,7 +90,7 @@ public void Application_Startup(object sender, StartupEventArgs e) case 1: // failed validation if (IsAdministrator() == false) { - var ifeoMessageUi = new MessageUI("GoAwayEdge", + var ifeoMessageUi = new MessageUi("GoAwayEdge", "The IFEO exclusion file needs to be updated. Update now?", "No", "Yes"); ifeoMessageUi.ShowDialog(); @@ -118,7 +118,7 @@ public void Application_Startup(object sender, StartupEventArgs e) case 2: // missing if (IsAdministrator() == false) { - var ifeoMessageUi = new MessageUI("GoAwayEdge", + var ifeoMessageUi = new MessageUi("GoAwayEdge", "The IFEO exclusion file is missing and need to be copied. Copy now?", "No", "Yes"); ifeoMessageUi.ShowDialog(); @@ -170,7 +170,7 @@ public void Application_Startup(object sender, StartupEventArgs e) if (!args.Contains("--profile-directory") && !ContainsParsedData(args) && args.Length != 2) continue; // Start Edge (default browser on this system) #if DEBUG - var messageUi = new MessageUI("GoAwayEdge", + var messageUi = new MessageUi("GoAwayEdge", $"Microsoft Edge will now start normally via IFEO application.", "OK", null, true); messageUi.ShowDialog(); #endif @@ -198,7 +198,7 @@ public void Application_Startup(object sender, StartupEventArgs e) p.StartInfo.Arguments = "microsoft-edge://?ux=copilot&tcp=1&source=taskbar"; Output.WriteLine("Opening Windows Copilot", ConsoleColor.Gray); #if DEBUG - var copilotMessageUi = new MessageUI("GoAwayEdge", + var copilotMessageUi = new MessageUi("GoAwayEdge", "Opening Windows Copilot ...", "OK", null, true); copilotMessageUi.ShowDialog(); #endif @@ -208,7 +208,7 @@ public void Application_Startup(object sender, StartupEventArgs e) var parsed = ParseUrl(_url); Output.WriteLine("Opening URL in default browser:\n\n" + parsed + "\n", ConsoleColor.Gray); #if DEBUG - var defaultUrlMessageUi = new MessageUI("GoAwayEdge", + var defaultUrlMessageUi = new MessageUi("GoAwayEdge", "Opening URL in default browser:\n\n" + parsed + "\n", "OK", null, true); defaultUrlMessageUi.ShowDialog(); #endif @@ -259,7 +259,7 @@ private static string ParseUrl(string encodedUrl) encodedUrl = encodedUrl.Replace("https://www.bing.com/search?q=", DefineEngine(_engine)); #if DEBUG - var uriMessageUi = new MessageUI("GoAwayEdge", + var uriMessageUi = new MessageUi("GoAwayEdge", "New Uri: " + encodedUrl, "OK", null, true); uriMessageUi.ShowDialog(); #endif diff --git a/GoAwayEdge/Common/Updater.cs b/GoAwayEdge/Common/Updater.cs index e00e60d..4e7e922 100644 --- a/GoAwayEdge/Common/Updater.cs +++ b/GoAwayEdge/Common/Updater.cs @@ -39,7 +39,7 @@ public static bool InitialEnvironment() } catch (Exception ex) { - var messageUi = new MessageUI("GoAwayEdge", + var messageUi = new MessageUi("GoAwayEdge", $"Initialization failed!\n{ex.Message}", "OK", null, true); messageUi.ShowDialog(); return false; @@ -81,7 +81,7 @@ public static int ValidateIfeoBinary() var ifeoHash = CalculateMd5(ifeoBinaryPath); #if DEBUG if (edgeHash != ifeoHash) { - var messageUi = new MessageUI("GoAwayEdge", + var messageUi = new MessageUi("GoAwayEdge", $"The Edge Hash ({edgeHash}) and Ifeo Hash ({ifeoHash}) are not identical. Validation failed!", "OK", null,true); messageUi.ShowDialog(); } @@ -113,7 +113,7 @@ public static void ModifyIfeoBinary(ModifyAction action) } catch (Exception ex) { - var messageUi = new MessageUI("GoAwayEdge", + var messageUi = new MessageUi("GoAwayEdge", $"Update failed!\n{ex.Message}!", "OK", null, true); messageUi.ShowDialog(); } diff --git a/GoAwayEdge/GoAwayEdge.csproj b/GoAwayEdge/GoAwayEdge.csproj index c450032..629a34e 100644 --- a/GoAwayEdge/GoAwayEdge.csproj +++ b/GoAwayEdge/GoAwayEdge.csproj @@ -13,7 +13,7 @@ GoAwayEdge Exploitox valnoxy - 1.1.1.42 + 1.2.0.62 Copyright (c) 2018 - 2023 Exploitox. All rights reserved. https://github.com/valnoxy/GoAwayEdge https://github.com/valnoxy/GoAwayEdge diff --git a/GoAwayEdge/GoAwayEdge.csproj.user b/GoAwayEdge/GoAwayEdge.csproj.user index d04c88f..0fe83d1 100644 --- a/GoAwayEdge/GoAwayEdge.csproj.user +++ b/GoAwayEdge/GoAwayEdge.csproj.user @@ -1,7 +1,7 @@  - <_LastSelectedProfileId>C:\Users\jonas\source\repos\GoAwayEdge\GoAwayEdge\Properties\PublishProfiles\FolderProfile.pubxml + <_LastSelectedProfileId>C:\Users\jonas\Documents\Git\GoAwayEdge\GoAwayEdge\Properties\PublishProfiles\FolderProfile.pubxml diff --git a/GoAwayEdge/Installer.xaml.cs b/GoAwayEdge/Installer.xaml.cs index caa648c..78f7380 100644 --- a/GoAwayEdge/Installer.xaml.cs +++ b/GoAwayEdge/Installer.xaml.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using System.Reflection; using System.Windows; +using GoAwayEdge.Common; using GoAwayEdge.Pages; namespace GoAwayEdge @@ -13,7 +14,7 @@ public partial class Installer internal static Installer? ContentWindow; private static License? _licensePage; private static Settings? _settingPage; - + public Installer() { InitializeComponent(); @@ -39,9 +40,10 @@ public Installer() } catch (Exception ex) { - // TODO: Implement message box - // Failed to load language: {ex.Message} - return; + var messageUi = new MessageUi("GoAwayEdge", + $"Failed to load language: {ex.Message}", "OK", null, true); + messageUi.ShowDialog(); + Environment.Exit(1); } _licensePage = new License(); diff --git a/GoAwayEdge/MessageUI.xaml b/GoAwayEdge/MessageUI.xaml index 4020090..7ea1a74 100644 --- a/GoAwayEdge/MessageUI.xaml +++ b/GoAwayEdge/MessageUI.xaml @@ -1,4 +1,4 @@ - /// Interaktionslogik für MessageUI.xaml /// - public partial class MessageUI + public partial class MessageUi { public virtual string? Summary => _buttonPressed; private static string? _buttonPressed; private static bool _mainThread; - private readonly DispatcherTimer _timer; + private readonly DispatcherTimer _timer = null!; - public MessageUI(string title, string message, string? btn1 = null, string? btn2 = null, bool isMainThread = false, int timer = 0) + public MessageUi(string title, string message, string? btn1 = null, string? btn2 = null, bool isMainThread = false, int timer = 0) { InitializeComponent(); @@ -41,10 +38,10 @@ public MessageUI(string title, string message, string? btn1 = null, string? btn2 _timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate { - LbTimer.Text = $"{time.ToString("%s")}s before auto-selecting '{this.Btn2.Content}'."; + LbTimer.Text = $"{time:%s}s before auto-selecting '{this.Btn2.Content}'."; if (time == TimeSpan.Zero) { - _timer?.Stop(); + _timer.Stop(); _buttonPressed = "Btn2"; if (_mainThread) this.Hide(); else this.Close(); diff --git a/GoAwayEdge/Pages/Installation.xaml.cs b/GoAwayEdge/Pages/Installation.xaml.cs index 524915e..c7adfaa 100644 --- a/GoAwayEdge/Pages/Installation.xaml.cs +++ b/GoAwayEdge/Pages/Installation.xaml.cs @@ -49,9 +49,7 @@ private static void Install(object? sender, DoWorkEventArgs e) var status = CopyItself(Path.Combine(instDir, "GoAwayEdge.exe"), Path.GetDirectoryName(Process.GetCurrentProcess().MainModule?.FileName) != instDir); if (status == false) { - var messageUi = new MessageUI("GoAwayEdge", - "Installation failed! Please try again.", "OK", null, true); - messageUi.ShowDialog(); + MessageBox.Show("Installation failed! Please try again.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); return; } @@ -104,9 +102,7 @@ private static void Install(object? sender, DoWorkEventArgs e) } catch (Exception ex) { - var messageUi = new MessageUI("GoAwayEdge", - $"Installation failed!\n{ex.Message}", "OK", null, true); - messageUi.ShowDialog(); + MessageBox.Show($"Installation failed!\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); return; } @@ -118,9 +114,7 @@ private static void Install(object? sender, DoWorkEventArgs e) } catch (Exception ex) { - var messageUi = new MessageUI("GoAwayEdge", - $"Installation failed!\n{ex.Message}", "OK", null, true); - messageUi.ShowDialog(); + MessageBox.Show($"Installation failed!\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); return; } @@ -137,9 +131,7 @@ private static void Install(object? sender, DoWorkEventArgs e) } catch (Exception ex) { - var messageUi = new MessageUI("GoAwayEdge", - $"Installation failed!\n{ex.Message}", "OK", null, true); - messageUi.ShowDialog(); + MessageBox.Show($"Installation failed!\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); return; } @@ -166,9 +158,7 @@ private static void Uninstall(object? sender, DoWorkEventArgs e) } catch (Exception ex) { - var messageUi = new MessageUI("GoAwayEdge", - $"Uninstallation failed! Please try again.\n{ex.Message}", "OK", null, true); - messageUi.ShowDialog(); + MessageBox.Show($"Uninstallation failed! Please try again.\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); return; } @@ -182,9 +172,7 @@ private static void Uninstall(object? sender, DoWorkEventArgs e) } catch (Exception ex) { - var messageUi = new MessageUI("GoAwayEdge", - $"Uninstallation failed! Please try again.\n{ex.Message}", "OK", null, true); - messageUi.ShowDialog(); + MessageBox.Show($"Uninstallation failed! Please try again.\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); return; } @@ -225,11 +213,9 @@ public static bool CopyItself(string pathTo, bool overwrite = false) } } - catch (Exception ex) + catch (Exception e) { - var messageUi = new MessageUI("GoAwayEdge", - $"Copy failed: {ex.Message}", "OK", null, true); - messageUi.ShowDialog(); + MessageBox.Show(e.ToString()); return false; } diff --git a/GoAwayEdge/Pages/Settings.xaml.cs b/GoAwayEdge/Pages/Settings.xaml.cs index 44abab3..01ed995 100644 --- a/GoAwayEdge/Pages/Settings.xaml.cs +++ b/GoAwayEdge/Pages/Settings.xaml.cs @@ -83,38 +83,48 @@ private void SearchEngineBox_OnSelectionChanged(object sender, SelectionChangedE case 0: Configuration.Search = SearchEngine.Google; CustomSearchPanel.Visibility = Visibility.Collapsed; + Installer.ContentWindow!.NextBtn.IsEnabled = true; break; case 1: Configuration.Search = SearchEngine.Bing; CustomSearchPanel.Visibility = Visibility.Collapsed; + Installer.ContentWindow!.NextBtn.IsEnabled = true; break; case 2: Configuration.Search = SearchEngine.DuckDuckGo; CustomSearchPanel.Visibility = Visibility.Collapsed; + Installer.ContentWindow!.NextBtn.IsEnabled = true; break; case 3: Configuration.Search = SearchEngine.Yahoo; CustomSearchPanel.Visibility = Visibility.Collapsed; + Installer.ContentWindow!.NextBtn.IsEnabled = true; break; case 4: Configuration.Search = SearchEngine.Yandex; CustomSearchPanel.Visibility = Visibility.Collapsed; + Installer.ContentWindow!.NextBtn.IsEnabled = true; break; case 5: Configuration.Search = SearchEngine.Ecosia; CustomSearchPanel.Visibility = Visibility.Collapsed; + Installer.ContentWindow!.NextBtn.IsEnabled = true; break; case 6: Configuration.Search = SearchEngine.Ask; CustomSearchPanel.Visibility = Visibility.Collapsed; + Installer.ContentWindow!.NextBtn.IsEnabled = true; break; case 7: Configuration.Search = SearchEngine.Qwant; CustomSearchPanel.Visibility = Visibility.Collapsed; + Installer.ContentWindow!.NextBtn.IsEnabled = true; break; case 8: Configuration.Search = SearchEngine.Custom; CustomSearchPanel.Visibility = Visibility.Visible; + if (string.IsNullOrEmpty(Configuration.CustomQueryUrl)) + Installer.ContentWindow!.NextBtn.IsEnabled = false; break; } } @@ -137,6 +147,8 @@ private void UninstallSwitch_OnClick(object sender, RoutedEventArgs e) private void QueryUrlTextBox_OnTextChanged(object sender, TextChangedEventArgs e) { Configuration.CustomQueryUrl = QueryUrlTextBox.Text; + Installer.ContentWindow!.NextBtn.IsEnabled = Uri.TryCreate(QueryUrlTextBox.Text, UriKind.Absolute, out var uriResult) + && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); } } } diff --git a/GoAwayEdge/Properties/PublishProfiles/FolderProfile.pubxml.user b/GoAwayEdge/Properties/PublishProfiles/FolderProfile.pubxml.user index e54ffb3..0096ac4 100644 --- a/GoAwayEdge/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/GoAwayEdge/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - True|2022-11-13T01:33:03.7406004Z;True|2022-11-13T02:19:07.9073988+01:00;True|2022-11-13T02:18:35.3043045+01:00;True|2022-11-12T20:05:07.6366825+01:00;False|2022-11-12T20:04:52.3576134+01:00;True|2022-11-12T19:36:12.8480978+01:00; + True|2023-10-18T22:00:28.0962969Z;True|2022-11-13T02:33:03.7406004+01:00;True|2022-11-13T02:19:07.9073988+01:00;True|2022-11-13T02:18:35.3043045+01:00;True|2022-11-12T20:05:07.6366825+01:00;False|2022-11-12T20:04:52.3576134+01:00;True|2022-11-12T19:36:12.8480978+01:00; \ No newline at end of file