Skip to content

Commit

Permalink
Added Weather service support
Browse files Browse the repository at this point in the history
- Default, Weather.com, AccuWeather & Custom
  • Loading branch information
valnoxy committed Dec 16, 2024
1 parent 60646ca commit bd36fd5
Show file tree
Hide file tree
Showing 21 changed files with 552 additions and 108 deletions.
6 changes: 3 additions & 3 deletions GoAwayEdge/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* GoAwayEdge
* Copyright (c) 2018 - 2024 valnoxy.
* Copyright (c) 2018 - 2025 Exploitox (valnoxy).
*
* GoAwayEdge is licensed under MIT License (https://github.com/valnoxy/GoAwayEdge/blob/main/LICENSE).
* So you are allowed to use freely and modify the application.
Expand Down Expand Up @@ -93,10 +93,10 @@ public void Application_Startup(object sender, StartupEventArgs e)
{
Configuration.InitialEnvironment();

if (Configuration.Provider != AiProvider.Copilot)
if (Configuration.AiProvider != AiProvider.Copilot)
{
DebugMessage.DisplayDebugMessage("GoAwayEdge",
$"Opening AI Provider '{Configuration.Provider}' (Triggered with argument) ...");
$"Opening AI Provider '{Configuration.AiProvider}' (Triggered with argument) ...");
UserInterface.CopilotDock.InterfaceManager.ShowDock();
Environment.Exit(0);
}
Expand Down
10 changes: 0 additions & 10 deletions GoAwayEdge/Assets/CopilotWhite.xaml

This file was deleted.

7 changes: 0 additions & 7 deletions GoAwayEdge/Assets/EdgeIcon.xaml

This file was deleted.

13 changes: 13 additions & 0 deletions GoAwayEdge/Assets/Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,17 @@
</DrawingGroup>
</DrawingGroup>
<DrawingImage x:Key="EdgeSettings" Drawing="{StaticResource EdgeSettingsDrawingGroup}" />
<Geometry x:Key="EdgeLogoGeometry">F1 M37,36z M0,0z M18.3169,1.6453E-05C10.5041,1.6453E-05 3.85789,4.6666 1.13039,11.9701 3.35676,9.52188 6.30504,8.21538 9.73085,8.21538L9.75652,8.21538C15.0719,8.2236,20.6898,11.5841,22.5465,15.8643L22.5385,15.8643C23.2039,17.1624 23.0489,18.5017 22.8353,19.3478 22.5889,20.309 22.2192,20.7604 22.0796,20.9412L22.0042,21.039C21.733,21.3759 21.7752,21.8697 22.0956,22.1655 22.1531,22.2147 22.2436,22.2807 22.3668,22.3628L22.5802,22.4944C23.6236,23.1516 25.9815,23.8246 28.1175,23.8246 29.7524,23.8246 31.8878,23.5701 33.8924,21.5573 37.2607,18.189 35.9622,13.4894 35.4857,12.1257 34.6724,9.81717 31.2968,2.14434 21.8244,0.336961 20.6743,0.115147 19.4917,1.6453E-05 18.3169,1.6453E-05z M9.73085,9.85845C5.45886,9.85845 2.03344,12.2499 0.0617534,16.604 -0.58726,24.1293 3.97176,30.8812 9.39389,33.9044 10.1743,34.3399 12.6551,35.5892 16.1138,36 13.0577,34.5541 10.7331,32.0317 9.66506,28.7538 7.89054,23.307 10.1172,17.4911 15.334,13.9421L15.342,13.9501C16.1307,13.4325 17.0919,13.1366 18.0778,13.1366 18.1928,13.1366 18.2997,13.1362 18.4148,13.1526 16.1062,11.1809 12.8373,9.86667 9.75653,9.85845L9.73085,9.85845z M13.1405,18.2134C10.8567,21.1463 10.1088,24.7865 11.2343,28.2451 12.7213,32.8129 17.0679,35.7044 22.3668,35.7208 26.4909,34.8007 30.0801,32.3926 33.0869,28.5067L33.1607,28.4088C33.3661,28.1048 33.3506,27.7015 33.1206,27.414 32.8823,27.1347 32.4882,27.0367 32.1514,27.1845L31.7567,27.3658C31.5924,27.4398 31.4448,27.4879 31.2641,27.5536 31.0751,27.6193 30.8615,27.7017 30.5821,27.8167 29.5224,28.2521 27.9454,28.4987 26.253,28.4987 24.8318,28.4987 23.4434,28.3186 22.3507,27.99 20.8062,27.53 16.0976,26.1082 13.6412,20.6861 13.3372,20.0124 13.1323,19.15 13.1405,18.2134z</Geometry>
<DrawingGroup x:Key="EdgeLogoDrawingGroup" ClipGeometry="M0,0 V36 H37 V0 H0 Z">
<GeometryDrawing Brush="#FFFFFFFF" Geometry="{StaticResource EdgeLogoGeometry}" />
</DrawingGroup>
<DrawingImage x:Key="EdgeIcon" Drawing="{StaticResource EdgeLogoDrawingGroup}" />
<Geometry x:Key="CopilotLogoGeometry">F1 M37,32z M0,0z M35.9718,9.96262C35.1149,8.80378,33.7888,8.14,32.3347,8.14L30.1805,8.14 28.5052,8.14 26.9512,3.14352C26.4006,1.29278,24.649,0,22.6932,0L22.4105,0 11.6361,0C8.0131,0,4.87994,2.331,3.8395,5.8016L0.190558,17.9642C-0.216442,19.3221 0.0351583,20.7533 0.881718,21.8907 1.72754,23.0273 3.02624,23.68 4.44334,23.68L7.84438,23.68C8.6162,23.9686,9.37174,24.4318,9.6559,26.1079L9.76838,26.7858C10.2242,29.5719 10.5254,31.4123 13.9753,31.8148 14.0041,31.8185 14.033,31.82 14.0604,31.82L25.019,31.82C28.6968,31.82,31.8781,29.4905,32.9348,26.0221L36.6467,13.8587C37.0574,12.5156,36.8109,11.0948,35.9718,9.96262z M22.4105,1.48L22.6932,1.48C24.0001,1.48,25.1678,2.33766,25.5363,3.5742L26.9556,8.14 25.3328,8.14C24.5173,8.14 23.7573,8.39604 23.1357,8.8393 23.0825,8.81858 23.0321,8.7912 22.9722,8.78306 20.8972,8.50482 19.4261,8.81488 18.3923,9.31068L19.623,5.20812C19.9885,3.99156,21.1496,1.48,22.4105,1.48z M21.9858,10.1735C21.8896,10.3637,21.8052,10.5628,21.7416,10.7729L18.3805,21.7878C17.5739,22.1785 15.7424,22.2673 14.2365,22.2585 14.514,21.9025 14.7367,21.4977 14.8729,21.0426L17.6235,11.874C17.8899,11.4064,18.9525,9.99814,21.9858,10.1735z M4.44334,22.2C3.4991,22.2 2.6333,21.7649 2.06868,21.0071 1.5048,20.2494 1.33682,19.2955 1.6084,18.3897L5.25734,6.22636C6.10908,3.38772,8.67244,1.48,11.6361,1.48L19.8575,1.48C18.8371,2.7713,18.2947,4.4844,18.2051,4.78262L16.2449,11.3168C16.2005,11.4056 16.1753,11.467 16.1694,11.4833 16.1442,11.5477 16.142,11.6136 16.1361,11.6794L13.4543,20.6186C13.1709,21.5643,12.3155,22.2,11.3276,22.2L10.7555,22.2 4.44334,22.2z M14.087,30.337C11.8071,30.0581,11.6791,29.3003,11.2284,26.5468L11.1152,25.8608C10.9524,24.8995,10.6431,24.2032,10.2627,23.68L11.3276,23.68C11.3298,23.68,11.332,23.6793,11.3342,23.6793L12.371,23.6785C12.5708,23.6918 13.4033,23.7429 14.4415,23.7429 15.5219,23.7429 16.8198,23.6844 17.8655,23.4743L16.9094,26.6082C16.6149,27.5702,15.4656,30.3015,14.087,30.337z M35.2318,13.4273L31.5199,25.5907C30.6667,28.3864,27.9938,30.34,25.019,30.34L16.6489,30.34C17.6827,29.0502,18.2347,27.3386,18.325,27.0411L23.1565,11.2058C23.4421,10.2719,24.3368,9.62,25.3321,9.62L27.9605,9.62 30.1805,9.62 32.3347,9.62C33.3144,9.62 34.2069,10.0662 34.7826,10.8425 35.3398,11.5951 35.5026,12.5363 35.2318,13.4273z</Geometry>
<DrawingGroup x:Key="CopilotLogoDrawingGroup" ClipGeometry="M0,0 V32 H37 V0 H0 Z">
<DrawingGroup.Transform>
<TranslateTransform X="3.2934769933490315E-07" Y="0" />
</DrawingGroup.Transform>
<GeometryDrawing Brush="#FFFFFFFF" Geometry="{StaticResource CopilotLogoGeometry}" />
</DrawingGroup>
<DrawingImage x:Key="CopilotIcon" Drawing="{StaticResource CopilotLogoDrawingGroup}" />
</ResourceDictionary>
115 changes: 106 additions & 9 deletions GoAwayEdge/Common/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.ComponentModel;
using System.IO;
using System.IO.Pipes;
using System.Windows;
using GoAwayEdge.Common.Debugging;
Expand Down Expand Up @@ -39,24 +40,39 @@ public enum EdgeChannel
Canary
}

public enum WeatherProvider
{
Default,

[Description("https://weather.com/{country-code}/weather/today/l/{latitude},{longitude}")]
WeatherCom,

[Description("https://www.accuweather.com/{short-country-code}/search-locations?query={latitude},{longitude}")]
AccuWeather,

Custom
}

internal class Configuration
{
public static EdgeChannel Channel { get; set; }
public static SearchEngine Search { get; set; }
public static AiProvider Provider { get; set; }
public static AiProvider AiProvider { get; set; }
public static WeatherProvider WeatherProvider { get; set; }
public static bool LicenseAccepted { get; set; }
public static bool Uninstall { get; set; }
public static bool UninstallEdge { get; set; }
public static bool NoEdgeInstalled { get; set; }
public static bool InstallControlPanel { get; set; }
public static string? CustomQueryUrl { get; set; }
public static string? CustomProviderUrl { get; set; }
public static string? CustomAiProviderUrl { get; set; }
public static string? CustomWeatherProviderUrl { get; set; }

public static string InstallDir = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
"valnoxy",
"GoAwayEdge");
public static ShellManager ShellManager { get; set; }
public static ShellManager? ShellManager { get; set; }
public static bool AppBarIsAttached { get; set; }


Expand Down Expand Up @@ -98,14 +114,19 @@ public static bool InitialEnvironment(bool setupRunning = false)
{
Channel = Runtime.ArgumentParse.ParseEdgeChannel(RegistryConfig.GetKey("EdgeChannel"));
Search = Runtime.ArgumentParse.ParseSearchEngine(RegistryConfig.GetKey("SearchEngine"));
Provider = Runtime.ArgumentParse.ParseAiProvider(RegistryConfig.GetKey("AiProvider", userSetting: true));
AiProvider = Runtime.ArgumentParse.ParseAiProvider(RegistryConfig.GetKey("AiProvider", userSetting: true));
WeatherProvider = Runtime.ArgumentParse.ParseWeatherProvider(RegistryConfig.GetKey("WeatherProvider", userSetting: true));
if (Search == SearchEngine.Custom)
{
CustomQueryUrl = RegistryConfig.GetKey("CustomQueryUrl");
}
if (Provider == AiProvider.Custom)
if (AiProvider == AiProvider.Custom)
{
CustomAiProviderUrl = RegistryConfig.GetKey("CustomAiProviderUrl", userSetting: true);
}
if (WeatherProvider == WeatherProvider.Custom)
{
CustomProviderUrl = RegistryConfig.GetKey("CustomProviderUrl", userSetting: true);
CustomWeatherProviderUrl = RegistryConfig.GetKey("CustomWeatherProviderUrl", userSetting: true);
}
}
catch (Exception ex)
Expand All @@ -116,9 +137,11 @@ public static bool InitialEnvironment(bool setupRunning = false)
Logging.Log($"Value of NonIfeoPath: {FileConfiguration.NonIfeoPath}");
Logging.Log($"Value of Channel: {Channel}");
Logging.Log($"Value of Search: {Search}");
Logging.Log($"Value of Provider: {Provider}");
Logging.Log($"Value of AiProvider: {AiProvider}");
Logging.Log($"Value of WeatherProvider: {WeatherProvider}");
Logging.Log($"Value of CustomQueryUrl: {CustomQueryUrl}");
Logging.Log($"Value of CustomProviderUrl: {CustomProviderUrl}");
Logging.Log($"Value of CustomAiProviderUrl: {CustomAiProviderUrl}");
Logging.Log($"Value of CustomWeatherProviderUrl: {CustomWeatherProviderUrl}");
return true;
}
catch (Exception ex)
Expand Down Expand Up @@ -219,6 +242,80 @@ public static List<string> GetAiProviders()

return list;
}

/// <summary>
/// Get a list of all available AI Providers.
/// </summary>
/// <returns>
/// List of AI Providers.
/// </returns>
public static List<string> GetWeatherProviders()
{
var list = (from weatherProvider in (WeatherProvider[])Enum.GetValues(typeof(WeatherProvider))
where (weatherProvider != WeatherProvider.Custom && weatherProvider != WeatherProvider.Default)
select weatherProvider.ToString().Replace("_", " ")).ToList();

try
{
var resourceValueCustom =
(string)Application.Current.MainWindow!.FindResource("SettingsSearchEngineCustomItem");
list.Add(!string.IsNullOrEmpty(resourceValueCustom) ? resourceValueCustom : "Custom");
}
catch
{
list.Add("Custom");
}

try
{
var resourceValueDefault =
(string)Application.Current.MainWindow!.FindResource("Default");
list.Insert(0, !string.IsNullOrEmpty(resourceValueDefault) ? resourceValueDefault : "Default");
}
catch
{
list.Insert(0, "Default");
}

return list;
}

/// <summary>
/// Retrieves the description of an enumeration value based on the <see cref="DescriptionAttribute"/>.
/// </summary>
/// <param name="value">The enumeration value for which to retrieve the description.</param>
/// <returns>
/// The description defined by the <see cref="DescriptionAttribute"/> if it exists;
/// otherwise, the string representation of the enumeration value.
/// </returns>
/// <example>
/// Example usage:
/// <code>
/// public enum SampleEnum
/// {
/// [Description("First Value")]
/// First,
///
/// [Description("Second Value")]
/// Second,
///
/// Third // No DescriptionAttribute
/// }
///
/// var value = SampleEnum.First;
/// string description = GetEnumDescription(value); // "First Value"
///
/// value = SampleEnum.Third;
/// description = GetEnumDescription(value); // "Third"
/// </code>
/// </example>
public static string GetEnumDescription(Enum value)
{
var fieldInfo = value.GetType().GetField(value.ToString());
var attributes = (DescriptionAttribute[])fieldInfo!.GetCustomAttributes(typeof(DescriptionAttribute), false);

return attributes.Length > 0 ? attributes[0].Description : value.ToString();
}
}

internal enum ModifyAction
Expand Down
Loading

0 comments on commit bd36fd5

Please sign in to comment.