diff --git a/BuildPortable.bat b/BuildPortable.bat new file mode 100644 index 00000000..284e7c78 --- /dev/null +++ b/BuildPortable.bat @@ -0,0 +1 @@ +cd InternetTest\InternetTest && dotnet publish -r win-x64 -c Release --self-contained false -p:DefineConstants=PORTABLE diff --git a/InternetTest/InternetTest/App.xaml b/InternetTest/InternetTest/App.xaml index 185f26e5..a766fcf8 100644 --- a/InternetTest/InternetTest/App.xaml +++ b/InternetTest/InternetTest/App.xaml @@ -33,24 +33,24 @@ - + - + - + - + @@ -82,20 +82,20 @@ - + - + - + @@ -127,7 +127,7 @@ - + @@ -140,7 +140,61 @@ - + + + + + + + + + - + - + - + @@ -1047,7 +1145,7 @@ Color="Transparent"> @@ -1134,7 +1232,7 @@ Color="Transparent"> @@ -1210,7 +1308,7 @@ + + + + + + + + + + + + + + + @@ -178,8 +178,8 @@ @@ -293,7 +293,7 @@ @@ -332,9 +332,9 @@ HorizontalAlignment="Left" VerticalAlignment="Center" Background="Transparent" - BorderBrush="{Binding Source={StaticResource AccentColor}}" + BorderBrush="{DynamicResource Accent}" BorderThickness="2" - Foreground="{Binding Source={StaticResource Foreground1}}" + Foreground="{DynamicResource Foreground1}" SelectionChanged="MapProviderComboBox_SelectionChanged" Style="{DynamicResource ComboBoxStyle1}"> @@ -348,8 +348,8 @@ @@ -382,7 +382,7 @@ BorderThickness="2" Checked="UpdateNotifChk_Checked" Content="{x:Static lang:Resources.NotifyUpdates}" - Foreground="{Binding Source={StaticResource Foreground1}}" + Foreground="{DynamicResource Foreground1}" Style="{DynamicResource CheckBoxStyle1}" Unchecked="UpdateNotifChk_Checked" /> @@ -390,8 +390,8 @@ @@ -429,14 +429,13 @@ HorizontalAlignment="Left" VerticalAlignment="Center" Background="Transparent" - BorderBrush="{Binding Source={StaticResource AccentColor}}" + BorderBrush="{DynamicResource Accent}" BorderThickness="2" - Foreground="{Binding Source={StaticResource Foreground1}}" + Foreground="{DynamicResource Foreground1}" SelectionChanged="PageComboBox_SelectionChanged" Style="{DynamicResource ComboBoxStyle1}"> - @@ -454,7 +453,7 @@ BorderThickness="2" Checked="UpdateOnStartChk_Checked" Content="{x:Static lang:Resources.CheckUpdatesOnStart}" - Foreground="{Binding Source={StaticResource Foreground1}}" + Foreground="{DynamicResource Foreground1}" Style="{DynamicResource CheckBoxStyle1}" Unchecked="UpdateOnStartChk_Checked" /> @@ -510,7 +509,7 @@ VerticalAlignment="Center" FontFamily="..\Fonts\#FluentSystemIcons-Regular" FontSize="22" - Text="" /> + Text="" /> @@ -547,11 +546,11 @@ x:Name="HttpRadio" VerticalAlignment="Center" Background="Transparent" - BorderBrush="{Binding Source={StaticResource AccentColor}}" + BorderBrush="{DynamicResource Accent}" Checked="HttpRadio_Checked" Content="{x:Static lang:Resources.HTTP}" FontWeight="Bold" - Foreground="{Binding Source={StaticResource Foreground1}}" + Foreground="{DynamicResource Foreground1}" GroupName="Protocol" Style="{DynamicResource RadioButtonStyle1}" Unchecked="HttpRadio_Checked" /> @@ -561,14 +560,14 @@ + Color="{DynamicResource AccentColor}" /> + Foreground="{DynamicResource Foreground1}" /> @@ -609,8 +608,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -642,14 +723,14 @@ + Color="{DynamicResource AccentColor}" /> @@ -665,11 +746,11 @@ x:Name="HopsApplyBtn" Padding="10 5 10 5" VerticalAlignment="Center" - Background="{Binding Source={StaticResource AccentColor}}" + Background="{DynamicResource Accent}" Click="HopsApplyBtn_Click" Cursor="Hand" FontWeight="ExtraBold" - Foreground="{Binding Source={StaticResource WindowButtonsHoverForeground1}}" + Foreground="{DynamicResource WindowButtonsHoverForeground1}" Style="{StaticResource PrimaryButton}" Visibility="Visible"> + Foreground="{DynamicResource Foreground1}" /> @@ -692,14 +773,14 @@ + Color="{DynamicResource AccentColor}" /> @@ -715,11 +796,11 @@ x:Name="TimeOutApplyBtn" Padding="10 5 10 5" VerticalAlignment="Center" - Background="{Binding Source={StaticResource AccentColor}}" + Background="{DynamicResource Accent}" Click="TimeOutApplyBtn_Click" Cursor="Hand" FontWeight="ExtraBold" - Foreground="{Binding Source={StaticResource WindowButtonsHoverForeground1}}" + Foreground="{DynamicResource WindowButtonsHoverForeground1}" Style="{StaticResource PrimaryButton}" Visibility="Visible"> + Foreground="{DynamicResource Foreground1}" /> @@ -742,8 +823,50 @@ + + + + + + + + + + + + + + + @@ -775,11 +898,11 @@ Margin="0 0 10 0" Padding="10 5 10 5" VerticalAlignment="Center" - Background="{Binding Source={StaticResource AccentColor}}" + Background="{DynamicResource Accent}" Click="ImportBtn_Click" Cursor="Hand" FontWeight="ExtraBold" - Foreground="{Binding Source={StaticResource WindowButtonsHoverForeground1}}" + Foreground="{DynamicResource WindowButtonsHoverForeground1}" Style="{StaticResource PrimaryButton}"> @@ -834,7 +957,7 @@ Cursor="Hand" FontSize="14" FontWeight="ExtraBold" - Foreground="{Binding Source={StaticResource AccentColor}}" + Foreground="{DynamicResource Accent}" Style="{DynamicResource StandardButton}"> + diff --git a/InternetTest/InternetTest/Pages/SettingsPage.xaml.cs b/InternetTest/InternetTest/Pages/SettingsPage.xaml.cs index a756c7eb..41bcb434 100644 --- a/InternetTest/InternetTest/Pages/SettingsPage.xaml.cs +++ b/InternetTest/InternetTest/Pages/SettingsPage.xaml.cs @@ -26,6 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using Microsoft.Win32; using PeyrSharp.Core; using PeyrSharp.Env; +using Synethia; using System; using System.Diagnostics; using System.IO; @@ -52,7 +53,7 @@ public SettingsPage() string lastVersion = await Update.GetLastVersionAsync(Global.LastVersionLink); // Get last version if (MessageBox.Show(Properties.Resources.InstallConfirmMsg, $"{Properties.Resources.InstallVersion} {lastVersion}", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { - SynethiaManager.Save(Global.SynethiaConfig); + SynethiaManager.Save(Global.SynethiaConfig, Global.SynethiaPath); HistoryManager.Save(Global.History); SettingsManager.Save(); @@ -69,7 +70,11 @@ public SettingsPage() private async void InitUI() { // About section - VersionTxt.Text = Global.Version; // Update the current version label +#if PORTABLE + VersionTxt.Text = Global.Version + " (Portable)"; +#else + VersionTxt.Text = Global.Version; +#endif // Select the default theme border ThemeSelectedBorder = Global.Settings.Theme switch @@ -107,10 +112,16 @@ private async void InitUI() HttpRadio.IsChecked = !Global.Settings.UseHttps; SiteTxt.Text = Global.Settings.TestSite; + // DownDetector section + IntervalTxt.Text = Global.Settings.DefaultTimeInterval.ToString(); + // Trace route section HopsTxt.Text = Global.Settings.TraceRouteMaxHops.ToString(); TimeOutTxt.Text = Global.Settings.TraceRouteMaxTimeOut.ToString(); + // Adapters section + HideNetworkAdaptersChk.IsChecked = Global.Settings.HideDisabledAdapters; + // Data section UseSynethiaChk.IsChecked = Global.Settings.UseSynethia; @@ -141,14 +152,17 @@ private async void CheckUpdateBtn_Click(object sender, RoutedEventArgs e) if (Update.IsAvailable(Global.Version, lastVersion)) { UpdateTxt.Text = Properties.Resources.AvailableUpdates; - +#if PORTABLE + MessageBox.Show(Properties.Resources.PortableNoAutoUpdates, $"{Properties.Resources.InstallVersion} {lastVersion}", MessageBoxButton.OK, MessageBoxImage.Information); + return; +#else if (MessageBox.Show(Properties.Resources.InstallConfirmMsg, $"{Properties.Resources.InstallVersion} {lastVersion}", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.No) { return; } - +#endif // If the user wants to proceed. - SynethiaManager.Save(Global.SynethiaConfig); + SynethiaManager.Save(Global.SynethiaConfig, Global.SynethiaPath); HistoryManager.Save(Global.History); SettingsManager.Save(); @@ -164,7 +178,7 @@ private async void CheckUpdateBtn_Click(object sender, RoutedEventArgs e) Border ThemeSelectedBorder; private void Border_MouseEnter(object sender, MouseEventArgs e) { - ((Border)sender).BorderBrush = new SolidColorBrush { Color = Global.GetColorFromResource("AccentColor") }; + ((Border)sender).BorderBrush = Global.GetBrushFromResource("Accent"); } private void Border_MouseLeave(object sender, MouseEventArgs e) @@ -184,60 +198,42 @@ private void LightBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e { ResetBorders(); ThemeSelectedBorder = (Border)sender; - ((Border)sender).BorderBrush = new SolidColorBrush { Color = Global.GetColorFromResource("AccentColor") }; + ((Border)sender).BorderBrush = Global.GetBrushFromResource("Accent"); Global.Settings.Theme = Themes.Light; SettingsManager.Save(); - if (MessageBox.Show(Properties.Resources.NeedRestartToApplyChanges, Properties.Resources.Settings, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) - { - return; - } - - SynethiaManager.Save(Global.SynethiaConfig); + SynethiaManager.Save(Global.SynethiaConfig, Global.SynethiaPath); HistoryManager.Save(Global.History); - Process.Start(Directory.GetCurrentDirectory() + @"\InternetTest.exe"); - Application.Current.Shutdown(); + Global.ChangeTheme(); } private void DarkBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { ResetBorders(); ThemeSelectedBorder = (Border)sender; - ((Border)sender).BorderBrush = new SolidColorBrush { Color = Global.GetColorFromResource("AccentColor") }; + ((Border)sender).BorderBrush = Global.GetBrushFromResource("Accent"); Global.Settings.Theme = Themes.Dark; SettingsManager.Save(); - if (MessageBox.Show(Properties.Resources.NeedRestartToApplyChanges, Properties.Resources.Settings, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) - { - return; - } - - SynethiaManager.Save(Global.SynethiaConfig); + SynethiaManager.Save(Global.SynethiaConfig, Global.SynethiaPath); HistoryManager.Save(Global.History); - Process.Start(Directory.GetCurrentDirectory() + @"\InternetTest.exe"); - Application.Current.Shutdown(); + Global.ChangeTheme(); } private void SystemBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { ResetBorders(); ThemeSelectedBorder = (Border)sender; - ((Border)sender).BorderBrush = new SolidColorBrush { Color = Global.GetColorFromResource("AccentColor") }; + ((Border)sender).BorderBrush = Global.GetBrushFromResource("Accent"); Global.Settings.Theme = Themes.System; SettingsManager.Save(); - if (MessageBox.Show(Properties.Resources.NeedRestartToApplyChanges, Properties.Resources.Settings, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) - { - return; - } - - SynethiaManager.Save(Global.SynethiaConfig); + SynethiaManager.Save(Global.SynethiaConfig, Global.SynethiaPath); HistoryManager.Save(Global.History); - Process.Start(Directory.GetCurrentDirectory() + @"\InternetTest.exe"); - Application.Current.Shutdown(); + Global.ChangeTheme(); } private void LangComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) @@ -256,7 +252,7 @@ private void LangApplyBtn_Click(object sender, RoutedEventArgs e) return; } - SynethiaManager.Save(Global.SynethiaConfig); + SynethiaManager.Save(Global.SynethiaConfig, Global.SynethiaPath); HistoryManager.Save(Global.History); Process.Start(Directory.GetCurrentDirectory() + @"\InternetTest.exe"); @@ -349,7 +345,7 @@ private void ResetSettingsLink_Click(object sender, RoutedEventArgs e) return; } - SynethiaManager.Save(Global.SynethiaConfig); + SynethiaManager.Save(Global.SynethiaConfig, Global.SynethiaPath); HistoryManager.Save(Global.History); Process.Start(Directory.GetCurrentDirectory() + @"\InternetTest.exe"); Application.Current.Shutdown(); @@ -377,7 +373,7 @@ private void ResetSynethiaLink_Click(object sender, RoutedEventArgs e) // If the user wants to proceed, reset Syenthia config file. Global.SynethiaConfig = new(); - SynethiaManager.Save(Global.SynethiaConfig); + SynethiaManager.Save(Global.SynethiaConfig, Global.SynethiaPath); // Ask the user if they want to restart the application to apply changes. if (MessageBox.Show(Properties.Resources.NeedRestartToApplyChanges, Properties.Resources.Settings, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) @@ -427,4 +423,33 @@ private void LocateIpOnStartChk_Checked(object sender, RoutedEventArgs e) Global.Settings.LaunchIpLocationOnStart = LocateIpOnStartChk.IsChecked; SettingsManager.Save(); } + + private void EraseWiFisLink_Click(object sender, RoutedEventArgs e) + { + if (!Directory.Exists(FileSys.AppDataPath + @"\Léo Corporation\InternetTest Pro\WiFis")) return; + + if (MessageBox.Show(Properties.Resources.EraseWiFiPasswordsFilesMsg, Properties.Resources.InternetTestPro, MessageBoxButton.YesNoCancel, MessageBoxImage.Question) != MessageBoxResult.Yes) return; + + string path = FileSys.AppDataPath + @"\Léo Corporation\InternetTest Pro\WiFis"; + string[] files = Directory.GetFiles(path); + for (int i = 0; i < files.Length; i++) + { + File.Delete(files[i]); // Remove the temp file + } + Directory.Delete(path); // Delete the temp directory + } + + private void IntervalApplyBtn_Click(object sender, RoutedEventArgs e) + { + if (string.IsNullOrEmpty(IntervalTxt.Text)) return; + + Global.Settings.DefaultTimeInterval = int.Parse(IntervalTxt.Text); + SettingsManager.Save(); + } + + private void NetworkAdaptersChk_Checked(object sender, RoutedEventArgs e) + { + Global.Settings.HideDisabledAdapters = HideNetworkAdaptersChk.IsChecked; + SettingsManager.Save(); + } } diff --git a/InternetTest/InternetTest/Pages/StatusPage.xaml b/InternetTest/InternetTest/Pages/StatusPage.xaml deleted file mode 100644 index b85de151..00000000 --- a/InternetTest/InternetTest/Pages/StatusPage.xaml +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -