Skip to content

Commit

Permalink
Merge pull request #528 from Leo-Corporation/vNext
Browse files Browse the repository at this point in the history
Version 8.0.0.2401
  • Loading branch information
lpeyr authored Jan 1, 2024
2 parents 6cce28f + eb548b9 commit f0fc692
Show file tree
Hide file tree
Showing 81 changed files with 2,972 additions and 3,841 deletions.
1 change: 1 addition & 0 deletions BuildPortable.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cd InternetTest\InternetTest && dotnet publish -r win-x64 -c Release --self-contained false -p:DefineConstants=PORTABLE
186 changes: 142 additions & 44 deletions InternetTest/InternetTest/App.xaml

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions InternetTest/InternetTest/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/
using InternetTest.Classes;
using InternetTest.Windows;
using Synethia;
using System.Windows;

namespace InternetTest;
Expand All @@ -41,9 +42,7 @@ private void Application_Startup(object sender, StartupEventArgs e)
Global.HomePage = new();
Global.HistoryPage = new();
Global.SettingsPage = new();
Global.StatusPage = new();
Global.DownDetectorPage = new();
Global.MyIpPage = new();
Global.LocateIpPage = new();
Global.PingPage = new();
Global.IpConfigPage = new();
Expand All @@ -69,7 +68,7 @@ private void Application_Startup(object sender, StartupEventArgs e)

private void Application_Exit(object sender, ExitEventArgs e)
{
SynethiaManager.Save(Global.SynethiaConfig);
SynethiaManager.Save(Global.SynethiaConfig, Global.SynethiaPath);
HistoryManager.Save(Global.History);
SettingsManager.Save();
}
Expand Down
1 change: 0 additions & 1 deletion InternetTest/InternetTest/Classes/AdapterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

using System;
using System.Net.NetworkInformation;

namespace InternetTest.Classes
Expand Down
107 changes: 62 additions & 45 deletions InternetTest/InternetTest/Classes/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using InternetTest.Pages;
using ManagedNativeWifi;
using Microsoft.Win32;
using PeyrSharp.Core.Maths;
using PeyrSharp.Enums;
using PeyrSharp.Env;
using Synethia;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.NetworkInformation;
Expand All @@ -48,23 +47,47 @@ public static class Global
#if NIGHTLY
private static DateTime Date => System.IO.File.GetLastWriteTime(System.Reflection.Assembly.GetEntryAssembly().Location);

public static string Version => $"7.9.1.2310-nightly{Date:yyMM.dd@HHmm}";
public static string Version => $"8.0.0.2401-nightly{Date:yyMM.dd@HHmm}";

#else
public static string Version => "7.9.1.2310";
public static string Version => "8.0.0.2401";
#endif
public static string LastVersionLink => "https://raw.githubusercontent.com/Leo-Corporation/LeoCorp-Docs/master/Liens/Update%20System/InternetTest/7.0/Version.txt";
internal static string SynethiaPath => $@"{FileSys.AppDataPath}\Léo Corporation\InternetTest Pro\NewSynethiaConfig.json";
public static bool IsConfidentialModeEnabled { get; set; } = false;
public static Settings Settings { get; set; } = SettingsManager.Load();
public static SynethiaConfig SynethiaConfig { get; set; } = SynethiaManager.Load();
public static SynethiaConfig SynethiaConfig { get; set; } = SynethiaManager.Load(SynethiaPath, DefaultConfig);
public static SynethiaConfig DefaultConfig => new()
{
PagesInfo = new()
{
new("DownDetector"),
new("DNS"),
new("WiFiNetworks"),
new("LocateIP"),
new("IPConfig"),
new("Ping"),
new("Traceroute"),
new("WiFiPasswords"),
},
ActionsInfo = new()
{
new(0, "DownDetector.Test"),
new(1, "DNS.GetInfo"),
new(2, "WiFiNetworks.Scan"),
new(3, "LocateIP.Locate"),
new(4, "IPConfig.Get"),
new(5, "Ping.Execute"),
new(6, "Traceroute.Execute"),
new(7, "WiFiPasswords.Get"),
}
};
public static History History { get; set; } = HistoryManager.Load();

public static HomePage? HomePage { get; set; }
public static HistoryPage? HistoryPage { get; set; }
public static SettingsPage? SettingsPage { get; set; }
public static StatusPage? StatusPage { get; set; }
public static DownDetectorPage? DownDetectorPage { get; set; }
public static MyIpPage? MyIpPage { get; set; }
public static LocateIpPage? LocateIpPage { get; set; }
public static PingPage? PingPage { get; set; }
public static IpConfigPage? IpConfigPage { get; set; }
Expand All @@ -73,8 +96,6 @@ public static class Global
public static TraceroutePage? TraceroutePage { get; set; }
public static WiFiNetworksPage? WiFiNetworksPage { get; set; }

internal static string SynethiaPath => $@"{FileSys.AppDataPath}\Léo Corporation\InternetTest Pro\SynethiaConfig.json";

public static string GetHiSentence
{
get
Expand Down Expand Up @@ -139,43 +160,26 @@ public static List<AppPages> GetMostRelevantPages(SynethiaConfig synethiaConfig)
{
Dictionary<AppPages, double> appScores = new()
{
{ AppPages.Status, synethiaConfig.StatusPageInfo.Score },
{ AppPages.DownDetector, synethiaConfig.DownDetectorPageInfo.Score },
{ AppPages.MyIP, synethiaConfig.MyIPPageInfo.Score },
{ AppPages.LocateIP, synethiaConfig.LocateIPPageInfo.Score },
{ AppPages.Ping, synethiaConfig.PingPageInfo.Score },
{ AppPages.IPConfig, synethiaConfig.IPConfigPageInfo.Score },
{ AppPages.WiFiPasswords, synethiaConfig.WiFiPasswordsPageInfo.Score },
{ AppPages.DnsTool, synethiaConfig.DnsPageInfo.Score },
{ AppPages.TraceRoute, synethiaConfig.TraceRoutePageInfo.Score },
{ AppPages.WiFiNetworks, synethiaConfig.WiFiNetworksPageInfo.Score },
{ AppPages.DownDetector, synethiaConfig.PagesInfo[0].Score },
{ AppPages.DnsTool, synethiaConfig.PagesInfo[1].Score },
{ AppPages.WiFiNetworks, synethiaConfig.PagesInfo[2].Score },
{ AppPages.LocateIP, synethiaConfig.PagesInfo[3].Score },
{ AppPages.IPConfig, synethiaConfig.PagesInfo[4].Score },
{ AppPages.Ping, synethiaConfig.PagesInfo[5].Score },
{ AppPages.TraceRoute, synethiaConfig.PagesInfo[6].Score },
{ AppPages.WiFiPasswords, synethiaConfig.PagesInfo[7].Score },
};

var sorted = appScores.OrderByDescending(x => x.Value);

return (from item in sorted select item.Key).ToList();
}

public static List<ActionInfo> GetMostRelevantActions(SynethiaConfig synethiaConfig)
{
Dictionary<ActionInfo, int> relevantActions = new();
for (int i = 0; i < synethiaConfig.ActionInfos.Count; i++)
{
relevantActions.Add(synethiaConfig.ActionInfos[i], synethiaConfig.ActionInfos[i].UsageCount);
}

// Sort each action with its usage count descending
var sorted = relevantActions.OrderByDescending(x => x.Value);
return (from item in sorted select item.Key).ToList();
}

public static List<AppPages> DefaultRelevantPages => new()
{
AppPages.Status,
AppPages.LocateIP,
AppPages.WiFiPasswords,
AppPages.DownDetector,
AppPages.MyIP,
AppPages.WiFiNetworks,
AppPages.Ping,
AppPages.TraceRoute,
Expand All @@ -185,16 +189,14 @@ public static List<ActionInfo> GetMostRelevantActions(SynethiaConfig synethiaCon

public static List<ActionInfo> DefaultRelevantActions => new()
{
new() { Action = AppActions.MyIP, UsageCount = 0 },
new() { Action = AppActions.Test, UsageCount = 0 },
new() { Action = AppActions.DownDetectorRequest, UsageCount = 0 },
new() { Action = AppActions.Ping, UsageCount = 0 },
new() { Action = AppActions.LocateIP, UsageCount = 0 },
new() { Action = AppActions.GetIPConfig, UsageCount = 0 },
new() { Action = AppActions.GetWiFiPasswords, UsageCount = 0 },
new() { Action = AppActions.ConnectWiFi, UsageCount = 0 },
new() { Action = AppActions.GetDnsInfo, UsageCount = 0 },
new() { Action = AppActions.TraceRoute, UsageCount = 0 },
new(4, "IPConfig.Get"),
new(2, "WiFiNetworks.Scan"),
new(3, "LocateIP.Locate"),
new(7, "WiFiPasswords.Get"),
new(0, "DownDetector.Test"),
new(5, "Ping.Execute"),
new(1, "DNS.GetInfo"),
new(6, "Traceroute.Execute"),
};

public static Dictionary<AppActions, string> ActionsIcons => new()
Expand Down Expand Up @@ -225,7 +227,7 @@ public static List<ActionInfo> GetMostRelevantActions(SynethiaConfig synethiaCon
{ AppActions.ConnectWiFi, Properties.Resources.ConnectWiFi },
};

public static Color GetColorFromResource(string resourceName) => (Color)ColorConverter.ConvertFromString(Application.Current.Resources[resourceName].ToString());
public static SolidColorBrush GetBrushFromResource(string resourceName) => (SolidColorBrush)Application.Current.Resources[resourceName];

public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
{
Expand Down Expand Up @@ -578,4 +580,19 @@ public static string GetInterfaceTypeName(NetworkInterfaceType networkInterfaceT
return "";
}
}

public static string GetCurrentWifiSSID()
{
var connections = NativeWifi.EnumerateInterfaceConnections();

foreach (var connection in connections)
{
if (connection.IsConnected)
{
return connection.ProfileName;
}
}
return null;

Check warning on line 595 in InternetTest/InternetTest/Classes/Global.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 595 in InternetTest/InternetTest/Classes/Global.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.
}

}
26 changes: 25 additions & 1 deletion InternetTest/InternetTest/Classes/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using InternetTest.Enums;
using PeyrSharp.Env;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows;
Expand Down Expand Up @@ -74,6 +75,9 @@ public Settings()
public int? TraceRouteMaxTimeOut { get; set; }
public (double, double)? MainWindowSize { get; set; }
public bool? LaunchIpLocationOnStart { get; set; }
public List<string>? DownDetectorWebsites { get; set; }
public int? DefaultTimeInterval { get; set; }
public bool? HideDisabledAdapters { get; set; }
}

public static class SettingsManager
Expand Down Expand Up @@ -114,6 +118,10 @@ public static Settings Load()
settings.TraceRouteMaxTimeOut ??= 5000;
settings.MainWindowSize ??= (950, 600);
settings.LaunchIpLocationOnStart ??= true;
settings.DefaultPage = (settings.DefaultPage == AppPages.Status || settings.DefaultPage == AppPages.MyIP) ? AppPages.Home : settings.DefaultPage;
settings.DownDetectorWebsites ??= new();
settings.DefaultTimeInterval ??= 10;
settings.HideDisabledAdapters ??= false;

return settings;
}
Expand Down Expand Up @@ -163,7 +171,23 @@ public static void Import(string path)
XmlSerializer xmlSerializer = new(typeof(Settings)); // XML Serializer
StreamReader streamReader = new(path); // Where the file is going to be read

Global.Settings = (Settings)xmlSerializer.Deserialize(streamReader); // Read
var settings = (Settings?)xmlSerializer.Deserialize(streamReader) ?? new();

// Upgrade the settings file if it comes from an older version
settings.IsMaximized ??= false; // Set the default value if none is specified.
settings.ToggleConfidentialMode ??= false; // Set the default value if none is specified.
settings.Pinned ??= false; // Set the default value if none is specified.
settings.RememberPinnedState ??= true; // Set the default value if none is specified.
settings.TraceRouteMaxHops ??= 30;
settings.TraceRouteMaxTimeOut ??= 5000;
settings.MainWindowSize ??= (950, 600);
settings.LaunchIpLocationOnStart ??= true;
settings.DefaultPage = (settings.DefaultPage == AppPages.Status || settings.DefaultPage == AppPages.MyIP) ? AppPages.Home : settings.DefaultPage;
settings.DownDetectorWebsites ??= new();
settings.DefaultTimeInterval ??= 10;
settings.HideDisabledAdapters ??= false;

Global.Settings = settings;

streamReader.Dispose();
Save(); // Save
Expand Down
83 changes: 0 additions & 83 deletions InternetTest/InternetTest/Classes/SynethiaConfig.cs

This file was deleted.

Loading

0 comments on commit f0fc692

Please sign in to comment.