Skip to content

Commit

Permalink
Merge pull request #372 from Leo-Corporation/vNext
Browse files Browse the repository at this point in the history
Version 7.1.0.2209
  • Loading branch information
lpeyr authored Sep 18, 2022
2 parents 9af7cd3 + ad089af commit 65804a9
Show file tree
Hide file tree
Showing 20 changed files with 809 additions and 494 deletions.
4 changes: 2 additions & 2 deletions InternetTest.Setup/Setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "InternetTest Pro"
#define MyAppVersion "7.0.1.2208"
#define MyAppFullVersion "7.0.1.2208"
#define MyAppVersion "7.1.0.2209"
#define MyAppFullVersion "7.1.0.2209"
#define MyAppPublisher "Léo Corporation"
#define MyAppURL "https://leocorporation.dev/"
#define MyAppExeName "InternetTest.exe"
Expand Down
13 changes: 12 additions & 1 deletion InternetTest/InternetTest/Classes/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace InternetTest.Classes;
public static class Global
{
public static string Version => "7.0.1.2208";
public static string Version => "7.1.0.2209";
public static string LastVersionLink => "https://raw.githubusercontent.com/Leo-Corporation/LeoCorp-Docs/master/Liens/Update%20System/InternetTest/7.0/Version.txt";
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 History History { get; set; } = HistoryManager.Load();
Expand Down Expand Up @@ -320,4 +322,13 @@ public static string GetGoogleMapsPoint(double lat, double lon)
return $"{deg}° {sD}' {fDir}, {deg2}° {sD2}' {sDir}".Replace("-", "");
}

public static string ReplaceAllCharactersByAnotherOne(string chars, string replaceChar)
{
string r = "";
for (int i = 0; i < chars.Length; i++)
{
r += replaceChar;
}
return r;
}
}
9 changes: 8 additions & 1 deletion InternetTest/InternetTest/Classes/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public Settings()
TestSite = "https://leocorporation.dev";
UseSynethia = true;
TestOnStart = true;
IsMaximized = false;
}

public Themes Theme { get; set; }
Expand All @@ -58,6 +59,7 @@ public Settings()
public bool IsFirstRun { get; set; }
public bool TestOnStart { get; set; }
public string? TestSite { get; set; }
public bool? IsMaximized { get; set; }
}

public static class SettingsManager
Expand Down Expand Up @@ -87,7 +89,12 @@ public static Settings Load()
XmlSerializer xmlDeserializer = new(typeof(Settings));

StreamReader streamReader = new(SettingsPath);
return (Settings)xmlDeserializer.Deserialize(streamReader);
var settings = (Settings)xmlDeserializer.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.

return settings;
}

public static void Save()
Expand Down
2 changes: 1 addition & 1 deletion InternetTest/InternetTest/InternetTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<UseWindowsForms>True</UseWindowsForms>
<Version>7.0.1.2208</Version>
<Version>7.1.0.2209</Version>
<Copyright>© 2022</Copyright>
<Company>Léo Corporation</Company>
<Description>Taking you to another level. InternetTest can locate IP addresses, send ping request, recover your WiFi passwords and more!</Description>
Expand Down
439 changes: 223 additions & 216 deletions InternetTest/InternetTest/MainWindow.xaml

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion InternetTest/InternetTest/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ namespace InternetTest;
/// </summary>
public partial class MainWindow : Window
{

public MainWindow()
{
InitializeComponent();
Expand Down Expand Up @@ -132,8 +131,12 @@ private void InitUI()
break;
}

// Register event handlers
PageCard.OnCardClick += PageCard_OnCardClick;
ActionCard.OnCardClick += PageCard_OnCardClick;

// Restore the previous Window state
WindowState = Global.Settings.IsMaximized ?? false ? WindowState.Maximized : WindowState.Normal;
}

private void PageCard_OnCardClick(object? sender, PageEventArgs e)
Expand Down Expand Up @@ -195,6 +198,7 @@ private void MinimizeBtn_Click(object sender, RoutedEventArgs e)
private void MaximizeRestoreBtn_Click(object sender, RoutedEventArgs e)
{
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;

HandleWindowStateChanged();
}

Expand All @@ -217,6 +221,10 @@ private void HandleWindowStateChanged()

WindowBorder.Margin = WindowState == WindowState.Maximized ? new(10, 10, 0, 0) : new(10); // Set
WindowBorder.CornerRadius = WindowState == WindowState.Maximized ? new(0) : new(5); // Set

// Update settings information
Global.Settings.IsMaximized = WindowState == WindowState.Maximized;
SettingsManager.Save();
}

private void DefineMaximumSize()
Expand Down Expand Up @@ -469,4 +477,17 @@ private void LeavePage()
Global.SynethiaConfig.WiFiPasswordsPageInfo.Score = Global.SynethiaConfig.WiFiPasswordsPageInfo.TotalTimeSpent * (Global.SynethiaConfig.WiFiPasswordsPageInfo.InteractionCount > 0 ? Global.SynethiaConfig.WiFiPasswordsPageInfo.InteractionCount / 2d : 1d); // Calculate the score
}
}

private void ConfidentialModeBtn_Click(object sender, RoutedEventArgs e)
{
Global.IsConfidentialModeEnabled = !Global.IsConfidentialModeEnabled; // Toggle

RegularLockTxt.Visibility = Global.IsConfidentialModeEnabled ? Visibility.Collapsed : Visibility.Visible;
FilledLockTxt.Visibility = !Global.IsConfidentialModeEnabled ? Visibility.Collapsed : Visibility.Visible;

Global.MyIpPage?.ToggleConfidentialMode(Global.IsConfidentialModeEnabled);
Global.LocateIpPage?.ToggleConfidentialMode(Global.IsConfidentialModeEnabled);
Global.IpConfigPage?.ToggleConfidentialMode(Global.IsConfidentialModeEnabled);
Global.WiFiPasswordsPage?.ToggleConfidentialMode();
}
}
15 changes: 15 additions & 0 deletions InternetTest/InternetTest/Pages/IpConfigPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ private void InitUI()
}
}

internal void ToggleConfidentialMode(bool toggle)
{
try
{
for (int i = 0; i < IpConfigDisplayer.Children.Count; i++)
{
if (IpConfigDisplayer.Children[i] is IpConfigItem ipConfigItem)
{
ipConfigItem.InitUI();
}
}
}
catch { }
}

internal void RefreshBtn_Click(object sender, RoutedEventArgs e)
{
InitUI(); // Refresh the UI
Expand Down
11 changes: 7 additions & 4 deletions InternetTest/InternetTest/Pages/LocateIpPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@
<Border.Effect>
<DropShadowEffect Color="{Binding Source={StaticResource AccentColor}}" BlurRadius="15" Opacity="0.2" ShadowDepth="0"/>
</Border.Effect>
<TextBox x:Name="IpTxt" Padding="5" Margin="5" BorderThickness="0" FontWeight="Bold" Foreground="{Binding Source={StaticResource DarkGray}}" d:Text="123.54.132.56" Background="Transparent"/>
</Border>
<Grid>
<TextBox x:Name="IpTxt" Padding="5" Margin="5" BorderThickness="0" FontWeight="Bold" Foreground="{Binding Source={StaticResource DarkGray}}" d:Text="123.54.132.56" Background="Transparent"/>
<PasswordBox x:Name="IpPassword" Padding="5" Margin="5" BorderThickness="0" FontWeight="Bold" Foreground="{Binding Source={StaticResource DarkGray}}" Background="Transparent" Visibility="Collapsed"/>
</Grid>
</Border>
</StackPanel>

<StackPanel Margin="10" Orientation="Horizontal" Grid.Row="2">
<TextBlock Text="&#xF4A4;" FontSize="16" FontFamily="../Fonts/#FluentSystemIcons-Regular" Foreground="{Binding Source={StaticResource AccentColor}}" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static lang:Resources.Details}" FontSize="14" VerticalAlignment="Center" FontWeight="ExtraBold" Margin="5,0,0,0"/>
<TextBlock x:Name="DetailsInfoTxt" Text="{x:Static lang:Resources.Details}" FontSize="14" VerticalAlignment="Center" FontWeight="ExtraBold" Margin="5,0,0,0"/>
</StackPanel>

<WrapPanel Grid.Row="3" Margin="0,0,0,20" Orientation="Horizontal">
<WrapPanel x:Name="DetailsWrap" Grid.Row="3" Margin="0,0,0,20" Orientation="Horizontal">
<Border MinWidth="150" CornerRadius="5" Margin="5" Padding="5" Background="{Binding Source={StaticResource CardBackground}}" HorizontalAlignment="Left">
<Border.Effect>
<DropShadowEffect BlurRadius="15" Color="#000" Direction="135" Opacity="0.2" ShadowDepth="0" />
Expand Down
36 changes: 31 additions & 5 deletions InternetTest/InternetTest/Pages/LocateIpPage.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.Enums;
using LeoCorpLibrary;
using Microsoft.Win32;
using System;
using System.Diagnostics;
Expand All @@ -47,10 +48,17 @@ public LocateIpPage()
InjectSynethiaCode();
}

private void InitUI()
private async void InitUI()
{
TitleTxt.Text = $"{Properties.Resources.IPTools} > {Properties.Resources.LocateIP}";
LocateIP(""); // Get the current IP of the user
try
{
if (await NetworkConnection.IsAvailableAsync())
{
LocateIP(""); // Get the current IP of the user
}
}
catch (Exception) { } // Cancel if there is no internet connection
}

private void InjectSynethiaCode()
Expand Down Expand Up @@ -100,10 +108,26 @@ private void InjectSynethiaCode()
}
}

internal void ToggleConfidentialMode(bool toggle)
{
// Change the text
MyIPTxt.Text = toggle ? Properties.Resources.ConfidentialModeEnabled : lIp;
DetailsInfoTxt.Text = !toggle ? Properties.Resources.Details : Properties.Resources.DetailsNotAvailableCM;

// Toggle visibility
IpTxt.Visibility = toggle ? Visibility.Collapsed : Visibility.Visible;
IpPassword.Visibility = !toggle ? Visibility.Collapsed : Visibility.Visible;
DetailsWrap.Visibility = toggle ? Visibility.Collapsed : Visibility.Visible;

// Toggle the password box
if (toggle) IpPassword.Password = IpTxt.Text;
else IpTxt.Text = IpPassword.Password;
}

internal void LocateIPBtn_Click(object sender, RoutedEventArgs e)
{
if (!Global.IsIpValid(IpTxt.Text)) return; // Cancel if the IP isn't valid
LocateIP(IpTxt.Text); // Locate IP
if (!Global.IsIpValid(Global.IsConfidentialModeEnabled ? IpPassword.Password : IpTxt.Text)) return; // Cancel if the IP isn't valid
LocateIP(Global.IsConfidentialModeEnabled ? IpPassword.Password : IpTxt.Text); // Locate IP

// Increment the interaction count of the ActionInfo in Global.SynethiaConfig
Global.SynethiaConfig.ActionInfos.First(a => a.Action == Enums.AppActions.LocateIP).UsageCount++;
Expand All @@ -126,6 +150,7 @@ private void MapBtn_Click(object sender, RoutedEventArgs e)
});
}

string lIp = "";
internal async void LocateIP(string ip)
{
try
Expand All @@ -138,7 +163,8 @@ internal async void LocateIP(string ip)
CurrentIP = ipInfo;
if (ipInfo is not null)
{
MyIPTxt.Text = ipInfo.Query;
lIp = ipInfo.Query ?? "";
MyIPTxt.Text = Global.IsConfidentialModeEnabled ? Properties.Resources.ConfidentialModeEnabled : lIp;
CountryTxt.Text = ipInfo.Country;
RegionTxt.Text = ipInfo.RegionName;
CityTxt.Text = ipInfo.City;
Expand Down
4 changes: 2 additions & 2 deletions InternetTest/InternetTest/Pages/MyIpPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

<StackPanel Margin="10" Orientation="Horizontal" Grid.Row="2">
<TextBlock Text="&#xF4A4;" FontSize="16" FontFamily="../Fonts/#FluentSystemIcons-Regular" Foreground="{Binding Source={StaticResource AccentColor}}" VerticalAlignment="Center"/>
<TextBlock Text="{x:Static lang:Resources.Details}" FontSize="14" VerticalAlignment="Center" FontWeight="ExtraBold" Margin="5,0,0,0"/>
<TextBlock x:Name="DetailsInfoTxt" Text="{x:Static lang:Resources.Details}" FontSize="14" VerticalAlignment="Center" FontWeight="ExtraBold" Margin="5,0,0,0"/>
</StackPanel>

<WrapPanel Grid.Row="3" Margin="0,0,0,20" Orientation="Horizontal">
<WrapPanel x:Name="DetailsWrap" Grid.Row="3" Margin="0,0,0,20" Orientation="Horizontal">
<Border MinWidth="150" CornerRadius="5" Margin="5" Padding="5" Background="{Binding Source={StaticResource CardBackground}}" HorizontalAlignment="Left">
<Border.Effect>
<DropShadowEffect BlurRadius="15" Color="#000" Direction="135" Opacity="0.2" ShadowDepth="0" />
Expand Down
26 changes: 23 additions & 3 deletions InternetTest/InternetTest/Pages/MyIpPage.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.Enums;
using LeoCorpLibrary;
using System;
using System.Diagnostics;
using System.Linq;
Expand All @@ -44,9 +45,16 @@ public MyIpPage()
InjectSynethiaCode();
}

private void InitUI()
private async void InitUI()
{
GetMyIP(); // Locate the current IP
try
{
if (await NetworkConnection.IsAvailableAsync())
{
GetMyIP(); // Locate the current IP
}
}
catch (Exception) { } // Cancel if there is no internet connection
TitleTxt.Text = $"{Properties.Resources.IPTools} > {Properties.Resources.MyIP}";
}

Expand Down Expand Up @@ -105,6 +113,17 @@ internal void GetMyIPBtn_Click(object sender, RoutedEventArgs e)
Global.SynethiaConfig.ActionInfos.First(a => a.Action == Enums.AppActions.MyIP).UsageCount++;
}

internal void ToggleConfidentialMode(bool toggle)
{
// Change text
MyIPTxt.Text = toggle ? Properties.Resources.ConfidentialModeEnabled : ip;
DetailsInfoTxt.Text = !toggle ? Properties.Resources.Details : Properties.Resources.DetailsNotAvailableCM;

// Toggle the details panel
DetailsWrap.Visibility = toggle ? Visibility.Collapsed : Visibility.Visible;
}

string ip = "";
internal async void GetMyIP()
{
try
Expand All @@ -116,7 +135,8 @@ internal async void GetMyIP()
var ipInfo = await Global.GetIPInfoAsync(""); // Giving an empty IP returns the user's current IP
if (ipInfo is not null)
{
MyIPTxt.Text = ipInfo.Query;
ip = ipInfo.Query ?? "";
MyIPTxt.Text = Global.IsConfidentialModeEnabled ? Properties.Resources.ConfidentialModeEnabled : ip;
CountryTxt.Text = ipInfo.Country;
RegionTxt.Text = ipInfo.RegionName;
CityTxt.Text = ipInfo.City;
Expand Down
4 changes: 2 additions & 2 deletions InternetTest/InternetTest/Pages/WiFiPasswordsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
</Border>
<Button x:Name="GetWiFiBtn" Click="GetWiFiBtn_Click" Cursor="Hand" Content="{x:Static lang:Resources.GetWiFi}" Padding="5" Background="{Binding Source={StaticResource LightAccentColor}}" Margin="5" Style="{DynamicResource PrimaryButton}" Grid.Row="1" FontWeight="ExtraBold" Foreground="{Binding Source={StaticResource AccentColor}}" HorizontalAlignment="Right"/>

<Grid x:Name="PlaceholderGrid" Grid.Row="2"/>
<StackPanel x:Name="WiFiItemDisplayer" Grid.Row="2" VerticalAlignment="Stretch">
<Grid x:Name="PlaceholderGrid" Grid.Row="2"/>
<StackPanel x:Name="WiFiItemDisplayer" Grid.Row="2" VerticalAlignment="Stretch">

</StackPanel>
</Grid>
Expand Down
15 changes: 15 additions & 0 deletions InternetTest/InternetTest/Pages/WiFiPasswordsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,19 @@ private void DismissBtn_Click(object sender, RoutedEventArgs e)
PlaceholderGrid.Visibility = Visibility.Visible;
}
}

internal void ToggleConfidentialMode()
{
try
{
for (int i = 0; i < WiFiItemDisplayer.Children.Count; i++)
{
if (WiFiItemDisplayer.Children[i] is WiFiInfoItem wiFiInfoItem)
{
wiFiInfoItem.InitUI();
}
}
}
catch { }
}
}
Loading

0 comments on commit 65804a9

Please sign in to comment.