Skip to content

Commit

Permalink
Merge pull request #14 from valnoxy/develop
Browse files Browse the repository at this point in the history
🛫 v1.3.0
  • Loading branch information
valnoxy committed Feb 18, 2024
2 parents bb660a4 + 5278075 commit 309a916
Show file tree
Hide file tree
Showing 38 changed files with 1,888 additions and 773 deletions.
4 changes: 2 additions & 2 deletions GoAwayEdge.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33020.496
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoAwayEdge", "GoAwayEdge\GoAwayEdge.csproj", "{95F3960E-372B-45F3-85D8-CD06F4D8B271}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoAwayEdge", "GoAwayEdge\GoAwayEdge.csproj", "{95F3960E-372B-45F3-85D8-CD06F4D8B271}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
216 changes: 143 additions & 73 deletions GoAwayEdge/App.xaml.cs

Large diffs are not rendered by default.

Binary file added GoAwayEdge/Assets/SetupBannerIcon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
133 changes: 131 additions & 2 deletions GoAwayEdge/Common/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace GoAwayEdge.Common
using System.IO;
using System.Windows;
using Microsoft.Win32;

namespace GoAwayEdge.Common
{
internal enum SearchEngine
{
Expand All @@ -10,6 +14,7 @@ internal enum SearchEngine
Ecosia,
Ask,
Qwant,
Perplexity,
Custom
}

Expand All @@ -26,7 +31,45 @@ internal class Configuration
public static EdgeChannel Channel { get; set; }
public static SearchEngine Search { get; set; }
public static bool Uninstall { get; set; }
public static bool UninstallEdge { get; set; }
public static bool NoEdgeInstalled { get; set; }
public static string? CustomQueryUrl { get; set; }

public static string InstallDir = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
"valnoxy",
"GoAwayEdge");

/// <summary>
/// Initialize the current environment.
/// </summary>
/// <returns>
/// Boolean status of the initialization.
/// </returns>
public static bool InitialEnvironment()
{
// Check if Edge is installed
try
{
NoEdgeInstalled = !File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
"Microsoft", "Edge", "Application", "msedge.exe"));
RegistryConfig.SetKey("NoEdgeInstalled", NoEdgeInstalled);

if (NoEdgeInstalled)
return true;

FileConfiguration.EdgePath = RegistryConfig.GetKey("EdgeFilePath");
FileConfiguration.NonIfeoPath = RegistryConfig.GetKey("EdgeNonIEFOFilePath");
return true;
}
catch (Exception ex)
{
var errorMessage = LocalizationManager.LocalizeValue("FailedInitialization", ex.Message);
var messageUi = new MessageUi("GoAwayEdge", errorMessage, "OK", null, true);
messageUi.ShowDialog();
return false;
}
}
}

internal enum ModifyAction
Expand All @@ -38,6 +81,92 @@ internal enum ModifyAction
internal class FileConfiguration
{
public static string EdgePath = string.Empty;
public static string IfeoPath = string.Empty;
public static string NonIfeoPath = string.Empty;
}

public class RegistryConfig
{
private const string Company = "valnoxy";
private const string Product = "GoAwayEdge";
private const string RegistryPath = @$"SOFTWARE\{Company}\{Product}";

/// <summary>
/// Create a Key in the Registry
/// </summary>
/// <param name="option">Key Name</param>
/// <param name="value">Key Value</param>
public static void SetKey(string option, object value)
{
try
{
using var key = Registry.LocalMachine.CreateSubKey(RegistryPath, RegistryKeyPermissionCheck.ReadWriteSubTree);
key.SetValue(option, value);
}
catch (Exception ex)
{
Console.WriteLine("An error has occurred while writing to the registry: " + ex.Message);
}
}

/// <summary>
/// Retrieves the value of a key from the Registry.
/// </summary>
/// <param name="option">Name of the key.</param>
/// <returns>The value of the key if it exists, otherwise null.</returns>
public static string GetKey(string option)
{
try
{
using var key = Registry.LocalMachine.OpenSubKey(RegistryPath);
if (key != null)
{
var value = key.GetValue(option);
if (value != null)
{
return value.ToString()!;
}
else
{
Console.WriteLine($"Value for key '{option}' not found in the registry.");
return "";
}
}
else
{
Console.WriteLine($"Registry key '{RegistryPath}' not found.");
return "";
}
}
catch (Exception ex)
{
Console.WriteLine("An error has occurred while reading the registry: " + ex.Message);
return "";
}
}

/// <summary>
/// Create a Key in the Registry
/// </summary>
/// <param name="option">Key Name</param>
public static bool RemoveKey(string option)
{
try
{
using var key = Registry.LocalMachine.OpenSubKey(RegistryPath, RegistryKeyPermissionCheck.ReadWriteSubTree);
var value = key?.GetValue(option);
if (value != null)
{
key?.DeleteValue(option);
}

return true;
}
catch (Exception ex)
{
Console.WriteLine("An error has occurred while reading the registry: " + ex.Message);
}

return false;
}
}
}
33 changes: 0 additions & 33 deletions GoAwayEdge/Common/ConsoleUtil.cs

This file was deleted.

0 comments on commit 309a916

Please sign in to comment.